Commit Graph

1717 Commits

Author SHA1 Message Date
Eli Friedman 6b9c41ea68 Add list initialization for complex numbers in C. Essentially, this allows "_Complex float x = {1.0f, 2.0f};". See changes to docs/LanguageExtensions.html for a longer description.
<rdar://problem/9397672>.

llvm-svn: 140090
2011-09-19 23:17:44 +00:00
Hans Wennborg be207b3c74 Silence ?: precendence warning when parenthesis are present.
Fixes PR10898. The warning should be silent when there are parenthesis
around the condition expression.

llvm-svn: 139492
2011-09-12 12:07:30 +00:00
David Blaikie e5f9a9e603 Show either a location or a fixit note, not both, for uninitialized variable warnings.
llvm-svn: 139463
2011-09-10 05:35:08 +00:00
Julien Lerouge 5a6b6987dc Bring llvm.annotation* intrinsics support back to where it was in llvm-gcc: can
annotate global, local variables, struct fields, or arbitrary statements (using
the __builtin_annotation), rdar://8037476.

llvm-svn: 139423
2011-09-09 22:41:49 +00:00
Richard Smith 3ab15558d7 PR10867: Work around a bug in lit. Multiple RUN: lines are joined with &&, so:
RUN: foo
  RUN: bar || true

is equivalent to:

  RUN: foo && bar || true

which is equivalent to:

  RUN: (foo && bar) || true

This resulted in several of the fixit tests not really testing anything.

llvm-svn: 139132
2011-09-06 03:01:15 +00:00
Ted Kremenek aed4677a1c -Wuninitialized: fix insidious bug resulting from interplay of blocks and dead code. Fixes <rdar://problem/10060250>.
llvm-svn: 139027
2011-09-02 19:39:26 +00:00
Chandler Carruth c841b6e598 Improve the diagnostic text for -Wmissing-noreturn to include the name
of the function in question when applicable (that is, not for blocks).
Patch by Joerg Sonnenberger with some stylistic tweaks by me.

When discussing this weth Joerg, streaming the decl directly into the
diagnostic didn't work because we have a pointer-to-const, and the
overload doesn't accept such. In order to make my style tweaks to the
patch, I first changed the overload to accept a pointer-to-const, and
then changed the diagnostic printing layer to also use
a pointer-to-const, cleaning up a gross line of code along the way.

llvm-svn: 138854
2011-08-31 09:01:53 +00:00
Ted Kremenek 183875f671 Control 'invalid conversion specifier' warnings under a subflag (-Wformat-invalid-specifier) of -Wformat. Fixes <rdar://problem/10031930>.
llvm-svn: 138686
2011-08-27 00:16:45 +00:00
Ted Kremenek 1b7f49c2d6 Teach -Wunreachable-code about dead code caused by macro expansions. This should suppress false positives resulting from 'assert' and friends.
llvm-svn: 138576
2011-08-25 19:28:55 +00:00
Eli Friedman 3fa64df543 Refactor and fix checking for initialization of flexible array members. The old version had the checks scattered across the code, missed some checks, and had a couple nasty bugs in existing checks.
Fixes PR10648 and another similar accepts-invalid bug.

llvm-svn: 138398
2011-08-23 22:24:57 +00:00
Ted Kremenek ee9848e20d Fix regression in -Wuninitialized involving VLAs. It turns out that we were modeling sizeof(VLAs)
incorrectly in the CFG, and also the static analyzer.  This patch regresses the analyzer a bit, but
that needs to be followed up with a better solution.

Fixes <rdar://problem/10008112>.

llvm-svn: 138372
2011-08-23 20:30:50 +00:00
Ted Kremenek 369b3fa752 Rename -Wstrl-incorrect-size to -Wstrlcpy-strlcat-size. This warning really is just specific to strlcpy and strlcat.
llvm-svn: 138038
2011-08-19 14:35:32 +00:00
Ted Kremenek 18db5d4e9d Enhance -Wstrl-incorrect-size to not report a FIXIT for destinations that are flexible arrays or have size 1.
llvm-svn: 138004
2011-08-18 22:48:41 +00:00
Ted Kremenek 6865f77fdd Reapply r137903, but fix the definition of size_t in the test case to use __SIZE_TYPE__ (and hence be portable).
Also, change the warning to -Wstrl-incorrect-size.

llvm-svn: 137980
2011-08-18 20:55:45 +00:00
Ted Kremenek 13fd55d85f Revert r137903, "Add experimental -Wstrlcpy-size warning that looks to see if the size argument for strlcpy/strlcat is the size of the *source*, and not the size of the *destination*. This warning is off by default (for now)."
This currently doesn't work on Windows.

llvm-svn: 137920
2011-08-18 02:18:02 +00:00
Ted Kremenek fbbdcedc2e Implement '-Weverything', which enables all warnings except those explicitly mapped to be ignored.
Currently this includes -pedantic warnings as well; we'll need to consider whether these should
be included.

This works as expected with -Werror.

Test cases were added to Sema/warn-unused-parameters.c, but they should probably be broken off into
their own test file.

llvm-svn: 137910
2011-08-18 01:12:56 +00:00
Ted Kremenek d5fe9e4d97 Add experimental -Wstrlcpy-size warning that looks to see if the size argument for strlcpy/strlcat is the size of the *source*, and not the size of the *destination*. This warning is off by default (for now).
Warning logic provided by Geoff Keating.

llvm-svn: 137903
2011-08-17 23:40:36 +00:00
Chandler Carruth e2669397f1 Treating the unused equality comparisons as something other than part of
-Wunused was a mistake. It resulted in duplicate warnings and lots of
other hacks. Instead, this should be a special sub-category to
-Wunused-value, much like -Wunused-result is.

Moved to -Wunused-comparison, moved the implementation to piggy back on
the -Wunused-value implementation instead of rolling its own, different
mechanism for catching all of the "interesting" statements.

I like the unused-value mechanism for this better, but its currently
missing several top-level statements. For now, I've FIXME-ed out those
test cases. I'll enhance the generic infrastructure to catch these
statements in a subsequent patch.

This patch also removes the cast-to-void fixit hint. This hint isn't
available on any of the other -Wunused-value diagnostics, and if we want
it to be, we should add it generically rather than in one specific case.

llvm-svn: 137822
2011-08-17 09:34:37 +00:00
Matt Beaumont-Gay 0a0ba9d883 Add fixit notes for -Wconstant-logical-operand.
llvm-svn: 137620
2011-08-15 17:50:06 +00:00
Kaelyn Uhrain 0fb0bb179a Add a test case for the divide-by-zero fix in r137234
llvm-svn: 137240
2011-08-10 19:47:25 +00:00
Douglas Gregor 6f47e5cabf For the availability attribute, allow a declaration to be deprecated
in the same version that it is introduced. Stuff happens.

llvm-svn: 137214
2011-08-10 15:31:35 +00:00
Peter Collingbourne 3bc84ca376 Fix an inconsistency in Sema::ConvertArgumentsForCall in that
the callee note diagnostic was not emitted in the case where
there were too few arguments.

llvm-svn: 136437
2011-07-29 00:24:42 +00:00
Peter Collingbourne 8f5f520653 Forbid address-space-qualified function types, per TR 18037
llvm-svn: 136257
2011-07-27 20:30:05 +00:00
Chad Rosier 99ee7829ff After further discussion it has been determined that alignof should report
the preferred alignment.  Thus, revert r135934, r135935, and r135940.

llvm-svn: 136062
2011-07-26 07:03:04 +00:00
Eric Christopher 06b9d065a2 Migrate over 2009-04-22-UnknownSize.c, 2009-07-17-VoidParameter.c,
2009-03-09-WeakDeclarations-1.c, and 2010-05-31-palignr.c from
llvm/test/FrontendC.

llvm-svn: 136033
2011-07-26 00:47:54 +00:00
Chad Rosier b23ee96cd5 Allow target to specify about using minimum alignment vs preferred. Takes care of
FIXME: Override "preferred align" for double and long long for ARM apcs-gnu ABI. 
Also part of rdar://9802874

llvm-svn: 135940
2011-07-25 19:39:39 +00:00
Chad Rosier af83fb773b Fix r135934. Rename was intended, but without additional tests for double.
llvm-svn: 135935
2011-07-25 19:17:48 +00:00
Chad Rosier ccd89122aa Rename an alignment test to be more precise and add another test for the default
ABI.

llvm-svn: 135934
2011-07-25 19:00:00 +00:00
Eric Christopher 279c20fde8 Migrate 2007-10-01-BuildArrayRef.c from llvm/test/FrontendC.
llvm-svn: 135840
2011-07-23 02:16:25 +00:00
Eric Christopher 516a79e32c Bring over a test from llvm/test/FrontendC that is for Sema and not CodeGen.
llvm-svn: 135753
2011-07-22 07:26:22 +00:00
Chandler Carruth 4dd6c043ae Move duplicate uninitialized warning suppression into the
AnalysisBasedWarnings Sema layer and out of the Analysis library itself.
This returns the uninitialized values analysis to a more pure form,
allowing its original logic to correctly detect some categories of
definitely uninitialized values. Fixes PR10358 (again).

Thanks to Ted for reviewing and updating this patch after his rewrite of
several portions of this analysis.

llvm-svn: 135748
2011-07-22 05:27:52 +00:00
Richard Trieu bb43dec255 Remove warning for conditional operands of differend signedness from -Wsign-compare. Cases that previously warn on this will have a different warning emitted from -Wsign-conversion.
llvm-svn: 135664
2011-07-21 02:46:28 +00:00
Ted Kremenek 65b3e0649c Fix false negative in -Wuninitialized involving a () wrapping an lvalue-to-rvalue conversion in a DeclStmt.
llvm-svn: 135525
2011-07-19 21:41:51 +00:00
Ted Kremenek 5d855bf7f2 Fix assertion failure in UninitializedValues.cpp where an lvalue to rvalue conversion is wrapped in a parenthesis.
llvm-svn: 135519
2011-07-19 20:33:49 +00:00
Ted Kremenek 9e100ea1a8 Reduce -Wuninitialized time by 22% (on sqlite) by removing the recursive AST crawl.
This is accomplished by forcing the needed expressions for -Wuninitialized to always be CFGElements in the CFG.
This allows us to remove a fair amount of the code for -Wuninitialized.

Some fallout:
- AnalysisBasedWarnings.cpp now specifically toggles the CFGBuilder to create a CFG that is suitable for -Wuninitialized.  This
is a layering violation, since the logic for -Wuninitialized is in libAnalysis.  This can be fixed with the proper refactoring.
- Some of the source locations for -Wunreachable-code warnings have shifted.  While not ideal, this is okay because that analysis
already needs some serious reworking.

llvm-svn: 135480
2011-07-19 14:18:48 +00:00
Chandler Carruth 7cf5a37605 Revert r135217, which wasn't the correct fix for PR10358. With this
patch, we actually move the state-machine for the value set backwards
one step. This can pretty easily lead to infinite loops where we
continually try to propagate a bit, succeed for one iteration, but then
back up because we find an uninitialized use.

A reduced test case from PR10379 is included.

llvm-svn: 135359
2011-07-16 22:27:02 +00:00
Ted Kremenek f0b28d7fe5 Fix false negative reported in PR 10358 by using 'Unknown' in -Wuninitialized to avoid cascading warnings. Patch by Kaelyn Uhrain.
llvm-svn: 135217
2011-07-14 23:43:06 +00:00
John McCall 5143181ff9 Teach -Wconversion, -Wsign-compare etc. about division and remainder.
llvm-svn: 135208
2011-07-14 22:39:48 +00:00
Ted Kremenek d0c2afd2c3 Revert r135147 and r135075. The consensus was that this wasn't the right thing to do.
llvm-svn: 135152
2011-07-14 17:05:32 +00:00
Ted Kremenek ba84cf53bc Reapply r135075, but modify format-strings.c and format-strings-fixit.c test cases to be more portable with an explicit target triple.
llvm-svn: 135134
2011-07-14 06:49:52 +00:00
NAKAMURA Takumi 91d831bc2d Revert r135075, "format string checking: long and int have the same widths on 32-bit, so we shouldn't warn about using"
It fails on freebsd, mingw and msvc10.

llvm-svn: 135129
2011-07-14 05:16:18 +00:00
Ted Kremenek 60654d697a format string checking: long and int have the same widths on 32-bit, so we shouldn't warn about using
an "int" format specifier with a "long" type in 32-bit.

llvm-svn: 135075
2011-07-13 20:20:58 +00:00
Ted Kremenek cc47e0fad1 Re-relax conversion specifier checking for printf format strings and conversion specifiers. My recent change was a mistake.
llvm-svn: 135048
2011-07-13 17:35:14 +00:00
Ted Kremenek 1d3fb8af68 Fix inversion in argument type checking for format strings with conversion specifiers for character types.
llvm-svn: 135046
2011-07-13 17:25:47 +00:00
John McCall c368838b20 Make the integer-range analysis recognize ^= correctly,
and (while I'm at it) teach it to grok the results of simple
assignments.

The first is PR10336.

llvm-svn: 135034
2011-07-13 06:35:24 +00:00
Eli Friedman 609ada27ce Silliness with commas, as reported at http://blog.regehr.org/archives/558 . As it turns out, this is my fault for not noticing this was an issue when I was looking at this a long time ago. :(
llvm-svn: 135026
2011-07-13 02:05:57 +00:00
Eli Friedman 6290ae476e Add diagnostic for constructs like "va_arg(l, float)" which have undefined behavior. PR10201.
llvm-svn: 134926
2011-07-11 21:45:59 +00:00
Douglas Gregor 9824aec830 Don't complain about missing return statements for naked
functions. Fixes <rdar://problem/9731999>.

llvm-svn: 134897
2011-07-11 15:24:01 +00:00
Eli Friedman 3346582bca Change -mno-mmx to be more compatible with gcc. Specifically, -mno-mmx should not imply -mno-sse.
Note that because we don't usually touch the MMX registers anyway, all -mno-mmx needs to do is tweak the x86-32 calling convention a little for vectors that look like MMX vectors, and prevent the definition of __MMX__.

clang doesn't actually stop the user from using MMX inline asm operands or MMX builtins in -mno-mmx mode; as a QOI issue, it would be nice to diagnose, but I doubt it really matters much.

<rdar://problem/9694837>

llvm-svn: 134770
2011-07-08 23:31:17 +00:00
Eric Christopher f7d303c541 Add a testcase for the previous commit and update an existing test for an
extra register.

Part of PR10299 and rdar://9740322

llvm-svn: 134657
2011-07-07 23:11:01 +00:00
Hans Wennborg 77d1abef07 Fix off-by-one error in StringLiteral::getLocationOfByte.
This fixes PR10223.

llvm-svn: 134183
2011-06-30 20:17:41 +00:00
Hans Wennborg de7a9c2415 Move test/Sema/return.cpp into test/SemaCXX/return.cpp
llvm-svn: 134171
2011-06-30 17:20:18 +00:00
Hans Wennborg c47ae95f8d Test for errors for returning a value from a ctor or dtor.
This fell out when Chandler landed the patch in r134138.

llvm-svn: 134163
2011-06-30 15:48:23 +00:00
Douglas Gregor a82064ca27 Check for deprecated/unavailable/etc attributes on fields that are
initialized via initializer lists. Fixes <rdar://problem/9694686>.

llvm-svn: 134099
2011-06-29 21:51:31 +00:00
Douglas Gregor 825faf7a4f When redeclaring a local extern in the same scope, make sure that we
replace the existing declaration appropriately. Patch by Jordy Rose,
fixes PR10013 / <rdar://problem/9584157>.

llvm-svn: 134097
2011-06-29 21:22:02 +00:00
Eric Christopher fd9a5f4f66 Split out logic for valid clobbers and valid inline asm registers.
Fixes rdar://9281377

llvm-svn: 134016
2011-06-28 18:20:53 +00:00
Fariborz Jahanian f4aa279ce8 Handle nonnull attribute with optional argument number on
functions with arguments of transparent unions type.
// rdar://9584012

llvm-svn: 133941
2011-06-27 21:12:03 +00:00
Chandler Carruth 4cc3f296a9 Cleanup a fixme by using a specific diagnostic for subscripting
a pointer to void.

llvm-svn: 133912
2011-06-27 16:32:27 +00:00
Chandler Carruth c933221826 Factor out (some of) the checking for invalid forms of pointer
arithmetic into a couple of common routines. Use these to make the
messages more consistent in the various contexts, especially in terms of
consistently diagnosing binary operators with invalid types on both the
left- and right-hand side. Also, improve the grammar and wording of the
messages some, handling both two pointers and two (different) types.

The wording of function pointer arithmetic diagnostics still strikes me
as poorly phrased, and I worry this makes them slightly more awkward if
more consistent. I'm hoping to fix that with a follow-on patch and test
case that will also make them more helpful when a typedef or template
type parameter makes the type completely opaque.

Suggestions on better wording are very welcome, thanks to Richard Smith
for some initial help on that front.

llvm-svn: 133906
2011-06-27 08:02:19 +00:00
John McCall 8766a83a2f Two more test cases which have been long uncommitted.
llvm-svn: 133842
2011-06-24 23:30:52 +00:00
Eli Friedman 1408bc9a55 Fix Sema::CheckVectorOperands so that it doesn't try to insert a cast expression into the LHS of a compound assignment. Fixes compound assignment of various "compatible" vector types, including NEON-vector and gcc-vector types.
<rdar://problem/9640356>

llvm-svn: 133737
2011-06-23 18:10:35 +00:00
Fariborz Jahanian 33e022650a Issue warning if weak_import attribute is added to an already
declared variable and ignore it. // rdar://9538608

llvm-svn: 133654
2011-06-22 22:08:50 +00:00
Manuel Klimek f2b4b69346 Changes ParenListExpr to always require a type.
Removes dead code found in the process.
Adds a test to verify that ParenListExprs do not have NULL types.

llvm-svn: 133637
2011-06-22 20:02:16 +00:00
Chandler Carruth 4352b0b876 Fix a crash when a pointer-to-member function is called in the condition
expression of '?:'. Add a test case for this pattern, and also test the
code that led to the crash in a "working" case as well.

llvm-svn: 133523
2011-06-21 17:22:09 +00:00
Argyrios Kyrtzidis 01bf777597 Warn for un-parenthesized '&' inside '|' (a & b | c), rdar://9553326.
Patch by Henry Mason with tweaks by me.

llvm-svn: 133453
2011-06-20 18:41:26 +00:00
Chandler Carruth 5f380da06f Fix a problem with the diagnostics of invalid arithmetic with function
pointers I found while working on the NULL arithmetic warning. We here
always assuming the LHS was the pointer, instead of using the selected
pointer expression.

llvm-svn: 133428
2011-06-20 07:52:11 +00:00
Argyrios Kyrtzidis c30661f3a8 Don't emit 'unavailable' errors inside an unavailable function. rdar://9623855.
llvm-svn: 133264
2011-06-17 17:28:30 +00:00
Chandler Carruth f8e06c96ca Make the presentation of the warnings on 'x + y ? 1 : 0' a bit more
pretty. In particular this makes it much easier for me to read messages
such as:

  x.cc:42: ?: has lower ...

Where I'm inclined to associate the third ':' with a missing column
number, but in fact column numbers have been turned off. Similar
punctuation collisions happened elsewhere as well.

llvm-svn: 133121
2011-06-16 01:05:12 +00:00
Douglas Gregor 88336839b9 Don't add redundant FormatAttr, ConstAttr, or NoThrowAttr attributes,
either imlicitly (for builtins) or explicitly (due to multiple
specification of the same attributes). Fixes <rdar://problem/9612060>.

llvm-svn: 133045
2011-06-15 05:45:11 +00:00
Nico Weber 0870debb8b Warn on "void f(int a[10]) { sizeof(a); }"
llvm-svn: 133036
2011-06-15 02:47:03 +00:00
Ted Kremenek 70f05fdfee Sema: show shift result in hexadecimal
Change the output for -Wshift-overflow and
-Wshift-sign-overflow to an unsigned hexadecimal. It makes
more sense for looking at bits than a signed decimal does.
Also, change the diagnostic's wording from "overrides"
to "sets".

This uses a new optional argument in APInt::toString()
that adds the '0x' prefix to hexademical numbers.

This fixes PR 9651.

Patch by nobled@dreamwidth.org!

llvm-svn: 133033
2011-06-15 00:54:52 +00:00
Fariborz Jahanian d53eca68f0 Bad table discription of fromat-y2k causes
no-format-y2k turn off -Wformat altogether. 
// rdar://9504680

llvm-svn: 133015
2011-06-14 21:54:00 +00:00
Chris Lattner f35de48c90 when compiling in a GNU mode (e.g. gnu99) treat VLAs with a size that can be folded to a constant
as constant size arrays.  This has slightly different semantics in some insane cases, but allows
us to accept some constructs that GCC does.  Continue to be pedantic in -std=c99 and other
modes.  This addressed rdar://8733881 - error "variable-sized object may not be initialized"; g++ accepts same code

llvm-svn: 132983
2011-06-14 06:38:10 +00:00
David Majnemer c75d1a1098 Properly diagnose using abstract and incomplete types in va_arg
- Move a test from test/SemaTemplate/instantiate-expr-3.cpp, it did not belong there
- Incomplete and abstract types are considered hard errors

llvm-svn: 132979
2011-06-14 05:17:32 +00:00
Chris Lattner ee7286f02d fix rdar://9546171 - -Wshorten-64-to-32 shouldn't warn on vector bitcasts.
llvm-svn: 132975
2011-06-14 04:51:15 +00:00
Eli Friedman 51dd0185d6 Make __gnu_inline__ functions in gnu99 mode work the same way as inline functions in gnu89 mode in terms of redefinitions.
rdar://9559708 .

llvm-svn: 132953
2011-06-13 23:56:42 +00:00
Hans Wennborg de2e67e546 Handle overloaded operators in ?: precedence warning
This is a follow-up to r132565, and should address the rest of PR9969:

Warn about cases such as

int foo(A a, bool b) {
 return a + b ? 1 : 2; // user probably meant a + (b ? 1 : 2);
}

also when + is an overloaded operator call.

llvm-svn: 132784
2011-06-09 17:06:51 +00:00
Bob Wilson 8b51f19ec1 Add isVCVT_N flag to identify Neon VCVT_N intrinsics, which require special
range checking for immediate operands.  Radar 9558930.

llvm-svn: 132783
2011-06-09 17:03:27 +00:00
Eli Friedman 6b3411b2fd Second try at fixing this test, this time without breaking 32-bit Darwin builders.
llvm-svn: 132694
2011-06-06 22:25:48 +00:00
Eli Friedman 9ed3cde1fa Start fixing up clang tests to work on the clang-native-arm-cortex-a9 builder.
llvm-svn: 132691
2011-06-06 21:23:05 +00:00
Hans Wennborg cf9bac4bc9 Warn about missing parentheses for conditional operator.
Warn in cases such as "x + someCondition ? 42 : 0;",
where the condition expression looks arithmetic, and has
a right-hand side that looks boolean.

This (partly) addresses http://llvm.org/bugs/show_bug.cgi?id=9969

llvm-svn: 132565
2011-06-03 18:00:36 +00:00
Ted Kremenek fb43639926 Rename -Wunknown-attributes to -Wattributes to match GCC.
llvm-svn: 132422
2011-06-01 20:09:40 +00:00
Chandler Carruth e54ff6cc3e Expand the coverage of the warning for constants on the RHS of logical operands:
return f() || -1;

where the user meant to write '|'.

This bootstraps without any additional warnings.

Patch by Richard Trieu.

llvm-svn: 132327
2011-05-31 05:41:42 +00:00
Francois Pichet 6f7289d9c5 Add a Microsoft C test following r131201.
llvm-svn: 131202
2011-05-11 22:28:19 +00:00
John McCall dfbf9341ad Use a heralded conversion to bool in inline-asm constraints.
llvm-svn: 131170
2011-05-10 23:39:47 +00:00
Ted Kremenek efdb7fe53b Fix crash in -Wuninitialized when using switch statments whose condition is a logical operation.
llvm-svn: 131158
2011-05-10 22:10:35 +00:00
John McCall e155a3d8aa __builtin_va_list is void* on ARM, not char*.
rdar://problem/9391966

llvm-svn: 131080
2011-05-09 02:19:37 +00:00
Chad Rosier f897d3b88b Fixed test case asserts due to checkin of r130710.
llvm-svn: 130720
2011-05-02 20:39:21 +00:00
Ted Kremenek b5fabb2f9f Convert assertion in memset checking to a runtime check (because real code may provide a deviant definition of memset).
llvm-svn: 130368
2011-04-28 01:38:02 +00:00
John Wiegley 1c0675e155 Parsing/AST support for Structured Exception Handling
Patch authored by Sohail Somani.

Provide parsing and AST support for Windows structured exception handling.

llvm-svn: 130366
2011-04-28 01:08:34 +00:00
Argyrios Kyrtzidis ae40e4e10e Gcc pads the size of an array using the alignment of its elements.
The size of the array may not be aligned according to alignment of its elements if an alignment attribute is
specified in a typedef. Fixes rdar://8665729 & http://llvm.org/PR5637.

llvm-svn: 130242
2011-04-26 21:05:39 +00:00
Fariborz Jahanian 6b4e26bee2 Add ms_struct attribute on record typee
(and ignore it for now) - wip.

llvm-svn: 130224
2011-04-26 17:54:40 +00:00
Argyrios Kyrtzidis a9b630e4d7 Emit a -Wnull-dereference warning for "*null" not just "*null = something". Addresses rdar://9269271.
llvm-svn: 130207
2011-04-26 17:41:22 +00:00
Ted Kremenek 8dcc466886 When generating printf fixits, preserve the original formating for unsigned integers (e.g., 'x', 'o').
llvm-svn: 130164
2011-04-25 22:32:59 +00:00
Fariborz Jahanian 743dda49d9 Recognize gcc's ms_struct pragma (and ignore for now).
This is wip.

llvm-svn: 130138
2011-04-25 18:49:15 +00:00
Eli Friedman ea7b85bfe0 PR4304: Add warning for designators in strict c89 mode.
llvm-svn: 130117
2011-04-24 22:14:22 +00:00
Chandler Carruth b009b14971 There were some frustrating problems with the implementation of
-Wwrite-strings. First and foremost, once the positive form of the flag
was passed, it could never be disabled by passing -Wno-write-strings.
Also, the diagnostic engine couldn't in turn use -Wwrite-strings to
control diagnostics (as GCC does) because it was essentially hijacked to
drive the language semantics.

Fix this by giving CC1 a clean '-fconst-strings' flag to enable
const-qualified strings in C and ObjC compilations. Corresponding
'-fno-const-strings' is also added. Then the driver is taught to
introduce '-fconst-strings' in the CC1 command when '-Wwrite-strings'
dominates.

This entire flag is basically GCC-bug-compatibility driven, so we also
match GCC's bug where '-w' doesn't actually disable -Wwrite-strings. I'm
open to changing this though as it seems insane.

llvm-svn: 130051
2011-04-23 06:30:43 +00:00
Argyrios Kyrtzidis ad8b4d402e For -Wlogical-op-parentheses, point at '&&', not '||'. Fixes rdar://9125333.
llvm-svn: 130009
2011-04-22 19:16:27 +00:00
Argyrios Kyrtzidis 1618023018 We regard a function as 'unused' from the codegen perspective, so our warnings diverge from
gcc's unused warnings which don't get emitted if the function is referenced even in an unevaluated context
(e.g. in templates, sizeof, etc.). Also, saying that a function is 'unused' because it won't get codegen'ed
is somewhat misleading.

- Don't emit 'unused' warnings for functions that are referenced in any part of the user's code.
- A warning that an internal function/variable won't get emitted is useful though, so introduce
  -Wunneeded-internal-declaration which will warn if a function/variable with internal linkage is not
  "needed" ('used' from the codegen perspective), e.g:

  static void foo() { }

  template <int>
  void bar() {
    foo();
  }

test.cpp:1:13: warning: function 'foo' is not needed and will not be emitted
static void foo() { }
            ^

Addresses rdar://8733476.

llvm-svn: 129794
2011-04-19 19:51:10 +00:00
Peter Collingbourne 133587f08b Add a new expression classification, CL_AddressableVoid
CL_AddressableVoid is the expression classification used for void
expressions whose address can be taken, i.e. the result of [], *
or void variable references in C, as opposed to things like the
result of a void function call.

llvm-svn: 129783
2011-04-19 18:51:51 +00:00