Commit Graph

775 Commits

Author SHA1 Message Date
Eli Friedman 94c25c66b5 Fix PR3868 by making Evaluate handle cases like "(long)&a + 4".
llvm-svn: 67593
2009-03-24 01:14:50 +00:00
Eli Friedman 703a77f313 Fix a couple of tests.
llvm-svn: 67592
2009-03-24 01:11:18 +00:00
Ted Kremenek fd14fade2f Implement '#pragma unused'.
llvm-svn: 67569
2009-03-23 22:28:25 +00:00
Douglas Gregor 893c2c963a Fix PR3855. When we encounter an incompatible redeclaration of a
library function, accept this declaration and pretend that we do not
know that this is a library function. autoconf depends on this
(broken) behavior.

llvm-svn: 67541
2009-03-23 17:47:24 +00:00
Douglas Gregor d6b05f705b Tighten up the determination of whether a function declaration has a
prototype. Thanks Eli!

llvm-svn: 67533
2009-03-23 16:26:51 +00:00
Douglas Gregor d4eca014e0 Thanks to Eli for pointing out my misreading of 6.2.2p5
llvm-svn: 67530
2009-03-23 16:17:01 +00:00
Eli Friedman 6400433980 Minor enhancements to Evaluate.
llvm-svn: 67503
2009-03-23 04:38:34 +00:00
Eli Friedman 80160bd483 Partial implementation of PR3342: break out pointer sign
incompatibilities in assignments from other pointer incompatibilities.  
Based off of the patch in PR3342.  (This doesn't implement -Wno-pointer-sign,
but I don't know the driver code very well.)

llvm-svn: 67494
2009-03-22 23:59:44 +00:00
Eli Friedman e8dd7b3228 Adjust isModifiableLvalue to give a slightly more useful diagnostic for
attempting to illegally modify a BlockDeclRefExpr.

llvm-svn: 67491
2009-03-22 23:26:56 +00:00
Eli Friedman 7fa3faa417 Fix code to mark block variables as const to actually work. Fix
isObjCObjectPointerType to work with qualified types.  Adjust test for 
changes.

If the SemaExpr changes are wrong or break existing code, feel free to 
delete the "ExprTy.addConst();" line and revert my changes to 
test/Sema/block-literal.c.

llvm-svn: 67489
2009-03-22 23:00:19 +00:00
Eli Friedman 38f8493752 Add testcase for incomplete call/return types for calls.
llvm-svn: 67486
2009-03-22 22:03:03 +00:00
Ted Kremenek dfd72c2b44 Fix <rdar://problem/6704086> by allowing the format string checking in Sema to
allow non-literal format strings that are variables that (a) permanently bind to
a string constant and (b) whose string constants are resolvable within the same
translation unit.

llvm-svn: 67404
2009-03-20 21:35:28 +00:00
Ted Kremenek 9ffbe41a6c Fix <rdar://problem/6703892> by not warning about self-comparisons of enum
constants.

llvm-svn: 67390
2009-03-20 18:35:45 +00:00
Douglas Gregor 07d8e3a500 Allow flexible array initializers that are not surrounded by
braces. We now build the appropriate fully-structured initializer list
for such things. Per PR3618, verified that we're getting the right
code generation.

llvm-svn: 67353
2009-03-20 00:32:56 +00:00
Douglas Gregor 3731162ade Variables marked as "extern" can actually have internal linkage if
there is a previous declaration marked "static". This fixes PR3645.

llvm-svn: 67336
2009-03-19 22:01:50 +00:00
Douglas Gregor 3729f240af If a function is declared as, e.g.,
F f;

where F is a typedef of a function type, then the function "f" has a
prototype. This is a slight tweak to Chris's suggested fix in
PR3817. Fixes PR3817 and PR3840.

llvm-svn: 67313
2009-03-19 18:14:46 +00:00
Chris Lattner 9363e3106e don't crash when sentinel attribute is used on function without a prototype,
discovered as part of PR3817

llvm-svn: 67127
2009-03-17 23:03:47 +00:00
Anders Carlsson 6caa9dd693 Check signedness of bitfield sizes.
llvm-svn: 67045
2009-03-16 18:19:21 +00:00
Chris Lattner cda4d7e196 introduce a new -fheinous-gnu-extensions flag that enables really
really horrible extensions that are disabled by default but that can
be accepted by -fheinous-gnu-extensions (but which always emit a 
warning when enabled).

As our first instance of this, implement PR3788/PR3794, which allows
non-lvalues in inline asms in contexts where lvalues are required. bleh.

llvm-svn: 66910
2009-03-13 17:38:01 +00:00
Steve Naroff cfb6cf4c02 Reimplement fix for <rdar://problem/6451399> problems with labels and blocks.
This solution is much simpler (and doesn't add any per-scope overhead, which concerned Chris). 

The only downside is the LabelMap is now declared in two places (Sema and BlockSemaInfo). My original fix tried to unify the LabelMap in "Scope" (which would support nested functions in general). In any event, this fixes the bug given the current language definition. If/when we decide to support GCC style nested functions, this will need to be tweaked.

llvm-svn: 66896
2009-03-13 16:03:38 +00:00
Steve Naroff 846b1ec40f Remove ActiveScope (revert http://llvm.org/viewvc/llvm-project?view=rev&revision=65694 and http://llvm.org/viewvc/llvm-project?view=rev&revision=66741).
Will replace with something better today...

llvm-svn: 66893
2009-03-13 15:38:40 +00:00
Chris Lattner 14311925f2 fix PR3258 by rejecting invalid numeric operands.
llvm-svn: 66618
2009-03-11 00:23:13 +00:00
Chris Lattner 3fa25c683f checking for symbolic operands as well as % at end of string.
llvm-svn: 66614
2009-03-11 00:06:36 +00:00
Chris Lattner a41b847401 reject invalid escape characters in extended-asm strings with a nice diagnostic.
llvm-svn: 66605
2009-03-10 23:51:40 +00:00
Douglas Gregor 0760fa1618 Add type checking for tentative definitions at the end of the
translation unit.

Thread the various declarations of variables via
VarDecl::getPreviousDeclaration.

llvm-svn: 66601
2009-03-10 23:43:53 +00:00
Douglas Gregor 8145742349 Partial fix for PR3310, concerning type-checking for tentative
definitions. We were rejecting tentative definitions of incomplete
(which is bad), and now we don't.

This fix is partial because we don't do the end-of-translation-unit
initialization for tentative definitions that don't ever have any
initializers specified.

llvm-svn: 66584
2009-03-10 21:58:27 +00:00
Chris Lattner ed9f14c4c9 do not warn about -=/=- confusion with macros, thanks to rdogra for a testcase.
llvm-svn: 66416
2009-03-09 07:11:10 +00:00
Chris Lattner 40dc267160 undefined -> unspecified. Thanks Mike.
llvm-svn: 66388
2009-03-08 19:52:14 +00:00
Chris Lattner 222b8bd6ad implement PR3753, warning about comparisons with a string literal.
llvm-svn: 66387
2009-03-08 19:39:53 +00:00
Chris Lattner 36c39c9b0a refine the "use of unary operator that may be intended as compound assignment (+=)"
warning to only trigger when there is whitespace or something else after the + as
suggested by Eli.

llvm-svn: 66370
2009-03-08 06:51:10 +00:00
Douglas Gregor 65530cb62e Tweak warning text from the last commit
llvm-svn: 66309
2009-03-06 23:46:13 +00:00
Douglas Gregor 3e06dbf48c Downgrade complaints about the use of variable-sized types within a
struct to an extension warning to match the behavior of GNU C, which
addresses the Sema part of PR3671.

llvm-svn: 66308
2009-03-06 23:41:27 +00:00
Douglas Gregor d9f92e2a06 Clean up some error messages with anonymous structs/unions and member declaration parsing. Fixes PR3680
llvm-svn: 66305
2009-03-06 23:28:18 +00:00
Douglas Gregor 2e7cba6208 Use the 'declaration does not declare anything' error when we see an anonymous struct/union declaration outside of a struct or union in C
llvm-svn: 66303
2009-03-06 23:06:59 +00:00
Douglas Gregor a74a29771f Implement GNU C semantics for K&R function definitions that follow a
prototype of the same function, where the promoted parameter types in
the K&R definition are not compatible with the types in the
prototype. Fixes PR2821.

llvm-svn: 66301
2009-03-06 22:43:54 +00:00
Daniel Dunbar e03c6102cc Handle #pragma pack(0). I left this out of diagnostic because users should
really use pack() instead.
 - <rdar://problem/6650243> clang warns about '#pragma pack(0)'

llvm-svn: 66287
2009-03-06 20:45:54 +00:00
Douglas Gregor d45b93bdd6 Implement the GNU semantics for forward declarations of enum types in
C and C++. Fixes PR3688.

llvm-svn: 66282
2009-03-06 18:34:03 +00:00
Daniel Dunbar 5cb85ebe94 Add Parse/Sema support for weak_import attribute.
- Also, diagnose weak applied to types.

llvm-svn: 66259
2009-03-06 06:39:57 +00:00
Chris Lattner 73bf7b42b6 fix PR3607 and a fixme, by checking bitfield constraints
more consistently.

llvm-svn: 66210
2009-03-05 22:45:59 +00:00
Eli Friedman 9ad7244f5b Check that the return type for function definitions is complete.
llvm-svn: 66027
2009-03-04 07:30:59 +00:00
Eli Friedman 4735374e39 PR3691: Add support for complex modes. I also tossed in support for XF
while I was at it.  There are still a lot of diagnostics missing from 
this code, and it isn't completely correct for anything other than x86, but 
it should work correctly on x86 for valid cases.

llvm-svn: 65935
2009-03-03 06:41:03 +00:00
Chris Lattner 5a9a892e48 fix PR#
llvm-svn: 65906
2009-03-03 00:00:26 +00:00
Chris Lattner e29509a6e1 fix PR2639
llvm-svn: 65869
2009-03-02 20:58:48 +00:00
Douglas Gregor 5a80bd1504 Rework the way we find locally-scoped external declarations when we
need them to evaluate redeclarations or call a function that hasn't
already been declared. We now keep a DenseMap of these locally-scoped
declarations so that they are not visible but can be quickly found,
e.g., when we're looking for previous declarations or before we go
ahead and implicitly declare a function that's being called. Fixes
PR3672.

llvm-svn: 65792
2009-03-02 00:19:53 +00:00
Anders Carlsson 6c885805cd Fix invalid VLAs/VMs in Sema::ActOnVariableDeclarator, so that the variable will have the right type by the time the initializer is checked. This ensures that code like
int a[(int)(1.0 / 1.0) = { 1 } will work.

Eli, please review.
 

llvm-svn: 65725
2009-02-28 21:56:50 +00:00
Steve Naroff d123bd05ca Fix <rdar://problem/6451399> problems with labels and blocks.
- Move the 'LabelMap' from Sema to Scope. To avoid layering problems, the second element is now a 'StmtTy *', which makes the LabelMap a bit more verbose to deal with.
- Add 'ActiveScope' to Sema. Managed by ActOnStartOfFunctionDef(), ObjCActOnStartOfMethodDef(), ActOnBlockStmtExpr().
- Changed ActOnLabelStmt(), ActOnGotoStmt(), ActOnAddrLabel(), and ActOnFinishFunctionBody() to use the new ActiveScope.
- Added FIXME to workaround in ActOnFinishFunctionBody() (for dealing with C++ nested functions).  

llvm-svn: 65694
2009-02-28 16:48:43 +00:00
Eli Friedman cba899ff7b Check a few more kinds of declarations that make a scope.
llvm-svn: 65680
2009-02-28 06:22:14 +00:00
Eli Friedman f69d09bae5 Start of checking for gotos which jump to an illegal destination.
As far as I know, this catches all cases of jumping into the scope of a 
variable with a variably modified type (excluding statement 
expressions) in C.  This is missing some stuff we probably want to check
(other kinds of variably modified declarations, statement expressions, 
indirect gotos/addresses of labels in a scope, ObjC @try/@finally, cleanup 
attribute), the diagnostics aren't very good, and it's not particularly 
efficient, but it's a decent start.

This patch is a slightly modified version of the patch I attached to
PR3259, and it fixes that bug.  I was sort of planning on improving 
it, but I think it's okay as-is, especially since it looks like CodeGen 
doesn't have any use for this sort of data structure.  The only 
significant change I can think of from the version I attached to PR3259 
is that this version skips running the checking code when a function 
doesn't contain any labels.

This patch doesn't cover case statements, which also need similar 
checking; I'm not sure how we should deal with that. Extending the goto 
checking to also check case statements wouldn't be too hard; it's just a 
matter of keeping track of the scope of the closest switch and checking that
the scope of every case is the same as the scope of the switch.  That said, 
it would likely be a performance hit to run this check on every 
function (it's an extra pass over the entire function), so we probably want
some other solution.

llvm-svn: 65678
2009-02-28 05:41:13 +00:00
Eli Friedman a1c7b6c5f6 Fix obvious shortcoming in the implementations of Evaluate for
integer __real__ and __imag__.  Not sure how I missed this.

llvm-svn: 65677
2009-02-28 03:59:05 +00:00
Chris Lattner 7b0ec8a9df upgrade various 'implicit int' warnings from an ext-warn to warning when not
in C89 mode.  This makes it enabled by default instead of only enabled with
-pedantic.  Clang defaults to c99 mode, so people will see this more often
than with GCC, but they can always use -std=c89 if they really want c89.

llvm-svn: 65647
2009-02-27 18:53:28 +00:00