Commit Graph

3032 Commits

Author SHA1 Message Date
Chris Lattner cc5d1c2e4e implement -Wformat-security properly, which is enabled by default.
This enables one specific class of non-literal format warnings.

llvm-svn: 70368
2009-04-29 04:59:47 +00:00
Chris Lattner 941153afcd tweak warning options to be more like gcc:
1. All all variants of -Wformat*, make them imply -Wformat.  GCC warns 
   if you use -Wformatfoo without -Wformat.  We just make one imply the 
   other.
2. Make -Wformat-nonliteral default to off, like gcc.  It is an incredible
   nuisance.
3. Accept but currently ignore -Wformat-extra-args.

llvm-svn: 70362
2009-04-29 04:15:07 +00:00
Zhongxing Xu 892a5f78eb Update test case.
llvm-svn: 70359
2009-04-29 02:37:26 +00:00
Zhongxing Xu c14f097f58 XFAIL the test case.
llvm-svn: 70356
2009-04-29 01:50:12 +00:00
Mike Stump d00bc1a275 Implement sema checking for noreturn.
llvm-svn: 70353
2009-04-29 00:43:21 +00:00
Ted Kremenek ebc6d91f4e Add regression test case provided by <rdar://problem/6833332>.
llvm-svn: 70350
2009-04-29 00:41:31 +00:00
Douglas Gregor c1547eb338 Force driver's PTH test to use PTH
llvm-svn: 70338
2009-04-28 22:43:20 +00:00
Ted Kremenek 869292d5b6 Implement ownership attribute 'objc_ownership_make_collectable'. This allows one
to add 'CFMakeCollectable' semantics to a method.

llvm-svn: 70336
2009-04-28 22:32:26 +00:00
Chris Lattner 8577f62622 Implement -Wfour-char-constants, which is an extension, not an extwarn,
and apparently not part of -Wall

llvm-svn: 70329
2009-04-28 21:51:46 +00:00
Ted Kremenek 89c3861061 Improve retain/release test cases for ownership attributes.
llvm-svn: 70327
2009-04-28 21:43:40 +00:00
Douglas Gregor e6648fb79e Implement checking for macro definitions that occur on the command
line when using a PCH that were not provided when building the PCH
file. If those names were used as identifiers somewhere in the PCH
file, reject the PCH file.

llvm-svn: 70321
2009-04-28 20:33:11 +00:00
Eli Friedman a38da57cd6 PR4097: add logic to Evaluate to handle pointer equality comparisons.
llvm-svn: 70317
2009-04-28 19:17:36 +00:00
Douglas Gregor c379c07240 Allow some differences between the predefines buffer used to build a
PCH file and the predefines buffer used when including the PCH
file. We (explicitly) detect conflicting macro definitions (rejecting
the PCH file) and about missing macro definitions (they'll be
automatically pulled from the PCH file anyway).

We're missing some checking to make sure that new macro definitions
won't have any impact on the PCH file itself (e.g., #define'ing an
identifier that the PCH file used).

llvm-svn: 70316
2009-04-28 18:58:38 +00:00
Chris Lattner 74c95e20af implement -Wmultichar
llvm-svn: 70315
2009-04-28 18:52:02 +00:00
Chris Lattner 0cd56890ef merge number.c into constants.c and start running it in -verify mode.
llvm-svn: 70310
2009-04-28 18:43:12 +00:00
Eli Friedman 4058a842e6 Fix a minor edge case in C89 mode related to the definition of a
"function designator".

(This causes a minor glitch in the 
diagnostics for C++ member pointers, but we weren't printing the 
right diagnostic there anyway.)

llvm-svn: 70307
2009-04-28 17:59:09 +00:00
Zhongxing Xu 3c3fee0fb8 Add test case.
llvm-svn: 70294
2009-04-28 13:52:13 +00:00
Douglas Gregor 76fe50c654 Improve compatibility with GCC regarding inline semantics in GNU89
mode and in the presence of __gnu_inline__ attributes. This should fix
both PR3989 and PR4069.

As part of this, we now keep track of all of the attributes attached
to each declaration even after we've performed declaration
merging. This fixes PR3264.

llvm-svn: 70292
2009-04-28 06:37:30 +00:00
Eli Friedman 6bba2adc95 Emit keyword extension warning in all modes, not just C99 mode.
llvm-svn: 70283
2009-04-28 03:59:15 +00:00
Eli Friedman 2b680b43e9 Simplify the scheme used for keywords, and change the classification
scheme to be more useful.

The new scheme introduces a set of categories that should be more 
readable, and also reflects what we want to consider as an extension 
more accurately.  Specifically, it makes the "what is a keyword" 
determination accurately reflect whether the keyword is a GNU or 
Microsoft extension.

I also introduced separate flags for keyword aliases; this is useful 
because the classification of the aliases is mostly unrelated to the 
classification of the original keyword.

This patch treats anything that's in the implementation 
namespace (prefixed with "__", or "_X" where "X" is any upper-case 
letter) as a keyword without marking it as an extension.  This is 
consistent with the standards in that an implementation is allowed to define 
arbitrary extensions in the implementation namespace without violating 
the standard. This gets rid of all the nasty "extension used" warnings 
for stuff like __attribute__ in -pedantic mode.  We still warn for 
extensions outside of the the implementation namespace, like typeof.
If someone wants to implement -Wextensions or something like that, we 
could add additional information to the keyword table.

This also removes processing for the unused "Boolean" language option; 
such an extension isn't supported on any other C implementation, so I 
don't see any point to adding it.

The changes to test/CodeGen/inline.c are required because previously, we 
weren't actually disabling the "inline" keyword in -std=c89 mode.

I'll remove Boolean and NoExtensions from LangOptions in a follow-up 
commit.

llvm-svn: 70281
2009-04-28 03:13:54 +00:00
Mike Stump d456c48568 Don't allow blocks to be declared as returning an array. Radar 6441502
llvm-svn: 70277
2009-04-28 01:10:27 +00:00
Sebastian Redl 4c018663b2 Track down return statements in the handlers of a function-try-block of constructors. Meh ...
llvm-svn: 70256
2009-04-27 21:33:24 +00:00
Sebastian Redl 2f38ba57c8 Don't allow catch declarations to name an abstract class
llvm-svn: 70248
2009-04-27 21:03:30 +00:00
Sebastian Redl 4de47b445b Improve validation of C++ exception handling: diagnose throwing incomplete types and jumps into protected try-catch scopes.
llvm-svn: 70242
2009-04-27 20:27:31 +00:00
Douglas Gregor 61cac2b295 Add Sema::ExtVectorDecls and Sema::ObjCCategoryImpls to the PCH file. Since these vectors are very, very rarely used and, when used in headers, and even when used are relatively small, we load them eagerly.
llvm-svn: 70240
2009-04-27 20:06:05 +00:00
Ted Kremenek 84bfa2c2dc Add two new checker-specific attributes: 'objc_ownership_release' and
'objc_ownership_cfrelease'. These are the 'release' equivalents of
'objc_ownership_retain' and 'objc_ownership_cfretain' respectively.

llvm-svn: 70235
2009-04-27 19:36:56 +00:00
Ted Kremenek e6633567e0 Track objects in GC mode returned by 'alloc', 'new', etc. methods. These are
treated as "not owned" objects.

llvm-svn: 70232
2009-04-27 19:14:45 +00:00
Douglas Gregor 988e627f8c Fix a problem with the RUN line of one of the PCH tests
llvm-svn: 70227
2009-04-27 18:49:47 +00:00
Daniel Dunbar 01910a50c4 x86-32 ABI: Fix crash on return of structure with flexible array
member.

Also, spell bitfield more consistently as bit-field.

llvm-svn: 70220
2009-04-27 18:31:32 +00:00
Ted Kremenek ebbef7d0d3 Add new checker-specific attribute 'objc_ownership_cfretain'. This is the same
as 'objc_ownership_cfretain' except that the method acts like a CFRetain instead
of a [... retain] (important in GC modes). Checker support is wired up, but
currently only for Objective-C message expressions (not function calls).

llvm-svn: 70218
2009-04-27 18:27:22 +00:00
Chris Lattner 669e32f8c0 rdar://6827200 - [sema] reject statically allocated arrays of interface types
Upgrade "array of interface" warning to an error.  In addition to being a
terrible idea, this crashes codegen.

llvm-svn: 70178
2009-04-27 01:55:56 +00:00
Chris Lattner 9a84589671 Change our silencing of C typedef redefinition handling to what we had
before r69391: typedef redefinition is an error by default, but if
*either* the old or new definition are from a system header, we silence
it.

llvm-svn: 70177
2009-04-27 01:46:12 +00:00
Chris Lattner 35cfb0544a make -Wtypedef-redefinition an extwarn instead of defaulting
to error, doing this breaks too many programs (e.g. Adium).

llvm-svn: 70170
2009-04-27 00:41:01 +00:00
Eli Friedman 4e2ab55502 Add a bit more handling for declarations like "int a[*]".
llvm-svn: 70162
2009-04-26 21:57:51 +00:00
Sebastian Redl d98ecd615f The mysterious bug turns out to be an incredibly bone-headed mistake.
llvm-svn: 70160
2009-04-26 21:08:36 +00:00
Eli Friedman 64fc3c68e5 Fix for PR4079: make sure to construct the member expressions for
offsetof correctly in the presence of anonymous structs/unions.

This could definitely use some cleanup, but I don't really want to mess 
with the anonymous union/struct code.

llvm-svn: 70156
2009-04-26 20:50:44 +00:00
Sebastian Redl a7b98a772c Implement function-try-blocks. However, there's a very subtle bug that I can't track down.
llvm-svn: 70155
2009-04-26 20:35:05 +00:00
Chris Lattner 574428e4db implement PR4077: [Linux kernel] inscrutable error on inline asm input/output constraint mismatch
Before we emitted:

$ clang t.c -S -m64 
llvm: error: Unsupported asm: input constraint with a matching output constraint of incompatible type!

Now we produce:
$ clang t.c -S -m64 
t.c:5:40: error: unsupported inline asm: input with type 'unsigned long' matching output with type 'int'
  asm volatile("foo " : "=a" (a) :"0" (b));
                             ~~~      ~^~

llvm-svn: 70142
2009-04-26 18:22:24 +00:00
Sebastian Redl f79d397081 Make reference class unification in conditional expressions check for validity of the conversion.
llvm-svn: 70121
2009-04-26 11:21:02 +00:00
Eli Friedman bd0e67362c Correct the order of the parameters to CheckAssignmentConstraints in
cleanup attribute checking.  The difference isn't normally visible, but it
can make a difference...

llvm-svn: 70104
2009-04-26 01:30:08 +00:00
Anders Carlsson 6f5c15688d When calling the cleanup function specified by __attribute__((cleanup)), make sure to bitcast the argument so it has the same type as the first argument of the cleanup function. Fixes <rdar://problem/6827047>.
llvm-svn: 70098
2009-04-26 00:34:20 +00:00
Eli Friedman ab2784f2c1 Fix for PR4074: allow subscripting non-lvalue arrays in C90 mode.
I wasn't originally going to use this approach, but cases like 
test/Sema/expr-comma.c make things difficult.

llvm-svn: 70096
2009-04-25 23:46:54 +00:00
Eli Friedman 7524de1da2 Change isNullPointerConstant to be strict; hopefully this won't cause
any issues now that we have our own tgmath.h.

llvm-svn: 70090
2009-04-25 22:37:12 +00:00
Eli Friedman bb967cc98d Make VerifyIntegerConstantExpr print extension warnings for non-ICEs.
Overall, I'm not particularly happy with the current situation regarding 
constant expression diagnostics, but I plan to improve it at some point.

llvm-svn: 70089
2009-04-25 22:26:58 +00:00
Chris Lattner c71d08bc22 fix PR4073 by making designated initializer checking code use
VerifyIntegerConstantExpression instead of isIntegerConstantExpr.
This makes it ext-warn but tolerate things that fold to a constant
but that are not valid i-c-e's.

There must be a bug in the i-c-e computation though, because it
doesn't catch this case even with pedantic.

This also switches the later code to use EvaluateAsInt which is
simpler and handles everything that evaluate does.

llvm-svn: 70081
2009-04-25 21:59:05 +00:00
Chris Lattner a4185c543e fix PR4067: [Linux kernel] cannot aggregate codegen stmtexpr as lvalue
llvm-svn: 70067
2009-04-25 19:35:26 +00:00
Chris Lattner b28fe9eae6 improve a diagnostic to make more sense.
llvm-svn: 70062
2009-04-25 18:52:45 +00:00
Chris Lattner edfa8d4557 Change SemaType's "GetTypeForDeclarator" and "ConvertDeclSpecToType" to
always return a non-null QualType + error bit.  This fixes a bunch of 
cases that didn't check for null result (and could thus crash) and eliminates
some crappy code scattered throughout sema.

This also improves the diagnostics in the recursive struct case to eliminate
a bogus second error.  It also cleans up the case added to function.c by forming
a proper function type even though the declarator is erroneous, allowing the
parameter to be added to the function.  Before:

t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*P)
^
t.c:4:3: error: use of undeclared identifier 'P'
  P+1;
  ^

After:
t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*P)
^

llvm-svn: 70023
2009-04-25 08:47:54 +00:00
Chris Lattner b41df4f622 change a couple more c++ sema methods to be based on isinvalid bits.
llvm-svn: 70022
2009-04-25 08:35:12 +00:00
Chris Lattner 38378bf61f various "is invalid" cleanups for C++ ctors/dtors.
llvm-svn: 70021
2009-04-25 08:28:21 +00:00