summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Explictly track tentative definitions within Sema, then hand thoseDouglas Gregor2009-04-211-0/+17
| | | | | | | | | | | | | | | tentative definitions off to the ASTConsumer at the end of the translation unit. Eliminate CodeGen's internal tracking of tentative definitions, and instead hook into ASTConsumer::CompleteTentativeDefinition. Also, tweak the definition-deferal logic for C++, where there are no tentative definitions. Fixes <rdar://problem/6808352>, and will make it much easier for precompiled headers to cope with tentative definitions in the future. llvm-svn: 69681
* clean up anonymous bitfield diagnostics, PR4017Chris Lattner2009-04-201-9/+21
| | | | llvm-svn: 69608
* Print an error for uses of __thread on targets which don't support it.Eli Friedman2009-04-191-0/+2
| | | | llvm-svn: 69553
* Add more thorough/correct checking for invalid __thread specifiers.Eli Friedman2009-04-191-7/+29
| | | | llvm-svn: 69542
* add a new Sema::CurFunctionNeedsScopeChecking bool that is used to avoid Chris Lattner2009-04-191-9/+17
| | | | | | | calling into the jump checker when a function or method is known to contain no VLAs or @try blocks. llvm-svn: 69509
* move jump scope checking and related code out into its own file, SemaDecl.cpp isChris Lattner2009-04-191-267/+1
| | | | | | already too large. llvm-svn: 69505
* rewrite an O(N^2) algorithm to be O(n).Chris Lattner2009-04-191-19/+18
| | | | llvm-svn: 69500
* second half of indirect jump checking: make sure that any Chris Lattner2009-04-191-10/+32
| | | | | | address taken labels are in function scope llvm-svn: 69499
* First half of jump scope checking for indirect goto.Chris Lattner2009-04-191-7/+21
| | | | llvm-svn: 69498
* reimplement DeclStmt handling so that we correctly handle intermixed Chris Lattner2009-04-181-47/+30
| | | | | | VLA's and statement expressions. llvm-svn: 69491
* the scope checker does work with objc methods, add testcase.Chris Lattner2009-04-181-5/+0
| | | | llvm-svn: 69487
* I didn't understand how @catches were chained. Now that I get it, fixChris Lattner2009-04-181-11/+10
| | | | | | | the scope checker to not think @catches are nested in each other, eliminating some bogus notes. llvm-svn: 69486
* forgot to commit this before.Chris Lattner2009-04-181-1/+1
| | | | llvm-svn: 69480
* reject invalid jumps among pieces of @try blocks. This seems to workChris Lattner2009-04-181-3/+24
| | | | | | | reasonably well except for the problem that @catches are nested within each other in the AST, giving the ugly diagnostics in L8. llvm-svn: 69477
* unconditionally check for goto correctness. This is because switchChris Lattner2009-04-181-4/+2
| | | | | | | | | statements don't end up in the LabelMap so we don't have a quick way to filter them. We could add state to Sema (a "has vla" and "has jump" bit) to try to filter this out, but that would be sort of gross and I'm not convinced it is the best way. Thoughts welcome. llvm-svn: 69476
* fix two error paths out of ParseBlockLiteralExpression toChris Lattner2009-04-181-1/+1
| | | | | | | | call ActOnBlockError so that CurBlock gets popped. This fixes a crash on test/block-syntax-error.c when this new assertion is enabled. llvm-svn: 69464
* refactor some code, adding a new getLabelMap() accessor methodChris Lattner2009-04-181-3/+5
| | | | | | | so that clients can't poke the function-local one when they really want the current block label. No functionality change. llvm-svn: 69463
* Improve switch diagnostic to emit the "jump" message on theChris Lattner2009-04-181-17/+20
| | | | | | | | | | | | | | | specific bad case instead of on the switch. Putting it on the switch means you don't know what case is the problem. For example: scope-check.c:54:3: error: illegal switch case into protected scope case 2: ^ scope-check.c:53:9: note: jump bypasses initialization of variable length array int a[x]; ^ llvm-svn: 69462
* first step to getting switches giving "jump into vla scope" errors.Chris Lattner2009-04-181-2/+7
| | | | llvm-svn: 69461
* fix error recovery in the case of a jump to a label with no definitionChris Lattner2009-04-181-25/+27
| | | | | | | to create a well formed AST instead of a dangling pointer. This resolves several fixme's. llvm-svn: 69459
* rewrite the goto scope checking code to be more efficient, simpler,Chris Lattner2009-04-181-81/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | produce better diagnostics, and be more correct in ObjC cases (fixing rdar://6803963). An example is that we now diagnose: int test1(int x) { goto L; int a[x]; int b[x]; L: return sizeof a; } with: scope-check.c:15:3: error: illegal goto into protected scope goto L; ^ scope-check.c:17:7: note: scope created by variable length array int b[x]; ^ scope-check.c:16:7: note: scope created by variable length array int a[x]; ^ instead of just saying "invalid jump". An ObjC example is: void test1() { goto L; @try { L: ; } @finally { } } t.m:6:3: error: illegal goto into protected scope goto L; ^ t.m:7:3: note: scope created by @try block @try { ^ There are a whole ton of fixme's for stuff to do, but I believe that this is a monotonic improvement over what we had. llvm-svn: 69437
* don't evaluate ->child_end() every time through the loop, or *i frequently ↵Chris Lattner2009-04-181-27/+32
| | | | | | within it. llvm-svn: 69431
* split code out into a new CheckFunctionJumpScopes routine,Chris Lattner2009-04-181-32/+44
| | | | | | | add some comments, change type from void* -> Stmt*, use smallvector instead of vector. llvm-svn: 69430
* make scope checking be static functions instead of sema methods.Chris Lattner2009-04-181-24/+24
| | | | llvm-svn: 69429
* FunctionDecl::getBody() is getting an ASTContext argument for use inDouglas Gregor2009-04-181-1/+1
| | | | | | | | lazy PCH deserialization. Propagate that argument wherever it needs to be. No functionality change, except that I've tightened up a few PCH tests in preparation. llvm-svn: 69406
* tweak redefinition of a typedef a bit to fix a couple of problems:Chris Lattner2009-04-171-15/+12
| | | | | | | | | | | | | | | | | | | | | | | 1. We had logic in sema to decide whether or not to emit the error based on manually checking whether in a system header file. 2. we were allowing redefinitions of typedefs in class scope in C++ if in header file. 3. there was no way to force typedef redefinitions to be accepted by the C compiler, which annoys me when stripping linemarkers out of .i files. The fix is to split the C++ class typedef redefinition path from the C path, and change the C path to be a warning that normally maps to error. This causes it to properly be ignored in system headers, etc. and gives us a way to control it. Passing -Wtypedef-redefinition now turns the error into a warning. One behavior change is that we now diagnose cases where you redefine a typedef in your .c file that was defined in a header file. This seems like reasonable behavior, and the diagnostic now indicates that it can be controlled with -Wtypedef-redefinition. llvm-svn: 69391
* fix a crash on invalid by making ActOnDeclarator create decl withChris Lattner2009-04-171-0/+3
| | | | | | | a dummy *function* type when it is recovering and knows it needs a function. rdar://6802350 - clang crash on invalid input llvm-svn: 69374
* Add support for the __has_trivial_destructor type trait.Anders Carlsson2009-04-171-0/+4
| | | | llvm-svn: 69345
* If a class has a non-trivial constructor that doesn't take any arguments, we ↵Anders Carlsson2009-04-161-1/+5
| | | | | | | | | | | | | | | | | | will now make an implicit CXXTemporaryObjectExpr. So struct S { S(); }; void f() { S s; } 's' here will implicitly be declared as. S s = S(); llvm-svn: 69326
* use getDiagnosticLevel instead of getDiagnosticMapping, whichChris Lattner2009-04-161-2/+2
| | | | | | is about to become private. llvm-svn: 69262
* Add support for the __has_trivial_constructor type trait.Anders Carlsson2009-04-161-0/+1
| | | | llvm-svn: 69245
* Fixup http://llvm.org/viewvc/llvm-project?rev=69165&view=rev (based on ↵Steve Naroff2009-04-151-3/+10
| | | | | | feedback from Eli). llvm-svn: 69184
* Revert previous patch (will commit a fix soon).Steve Naroff2009-04-151-7/+6
| | | | llvm-svn: 69178
* Fix <rdar://problem/6789707> "warning: 'extern' variable has an initializer" ↵Steve Naroff2009-04-151-1/+1
| | | | | | not correct for __private_extern__. llvm-svn: 69167
* Fix <rdar://problem/6791490> [clang10 regression] [sema] invalid illegal ↵Steve Naroff2009-04-151-7/+6
| | | | | | | | | | | | jump diagnostic. caused by: <rdar://problem/6252084> [sema] jumps into Obj-C exception blocks should be disallowed. Sema::RecursiveCalcLabelScopes() and Sema::RecursiveCalcJumpScopes() need to pop the ScopeStack within the statement iteration loop (was outside the loop). Eli, please review (thanks). llvm-svn: 69165
* Fix <rdar://problem/6252084> [sema] jumps into Obj-C exception blocks should ↵Steve Naroff2009-04-141-12/+13
| | | | | | | | be disallowed. This builds on Eli's work from http://llvm.org/viewvc/llvm-project?view=rev&revision=65678. llvm-svn: 69073
* Use hasAttr instead of getAttr for conditionals.Mike Stump2009-04-141-1/+1
| | | | llvm-svn: 69021
* Audit __private_extern__ handling.Daniel Dunbar2009-04-141-16/+13
| | | | | | | | | | | | | | - Exposed quite a few Sema issues and a CodeGen crash. - See FIXMEs in test case, and in SemaDecl.cpp (PR3983). I'm skeptical that __private_extern__ should actually be a storage class value. I think that __private_extern__ basically amounts to extern A __attribute__((visibility("hidden"))) and would be better off handled (a) as that, or (b) with an extra bit in the VarDecl. llvm-svn: 69020
* Fixup CodeGen for __weak __block variables. Radar 6756266Mike Stump2009-04-141-1/+2
| | | | llvm-svn: 69010
* PR3461: reject initializer for incomplete type. Based on patch by TimEli Friedman2009-04-131-0/+7
| | | | | | Northover. llvm-svn: 68991
* Make the selection of type declarations in Sema::getTypeNameDouglas Gregor2009-04-131-2/+4
| | | | | | | deterministic when faced with an ambiguity. This eliminates the annoying test/SemaCXX/using-directive.cpp failure. llvm-svn: 68952
* fix another case that assumed that GetTypeForDeclarator would never return null.Chris Lattner2009-04-121-4/+5
| | | | llvm-svn: 68918
* fix code that incorrectly assumed that GetTypeForDeclarator cannotChris Lattner2009-04-121-2/+4
| | | | | | return null. llvm-svn: 68916
* Diagnose invalid uses of tagged types with a missing tag. For example, in:Chris Lattner2009-04-121-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | struct xyz { int y; }; enum abc { ZZZ }; static xyz b; abc c; we used to produce: t2.c:4:8: error: unknown type name 'xyz' static xyz b; ^ t2.c:5:1: error: unknown type name 'abc' abc c; ^ we now produce: t2.c:4:8: error: use of tagged type 'xyz' without 'struct' tag static xyz b; ^ struct t2.c:5:1: error: use of tagged type 'abc' without 'enum' tag abc c; ^ enum GCC produces the normal: t2.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘b’ t2.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’ rdar://6783347 llvm-svn: 68914
* fix a valgrind problem I noticed while developing another patch,Chris Lattner2009-04-121-1/+1
| | | | | | | if a decl is invalid, it isn't added to the Decls array, so we need to pass in Decls.size() to avoid reading uninit memory. llvm-svn: 68913
* a few cleanups to StatementCreatesScope: unnest the whole thing,Chris Lattner2009-04-121-12/+15
| | | | | | | exit at the first decl found that creates a scope, don't evaluate decl_end() every iteration. llvm-svn: 68908
* simplify code to use adjustParameterType, apply objc arg attributesChris Lattner2009-04-111-6/+7
| | | | | | to their arguments. llvm-svn: 68876
* diagnose attempts to return objc interfaces by-value from C functions.Chris Lattner2009-04-111-1/+9
| | | | llvm-svn: 68873
* Improve the 'cannot pass objc interface by value' diagnostic:Chris Lattner2009-04-111-2/+2
| | | | | | | | | | | | | | | | | | 1) improve localizability by not passing english strings in. 2) improve location for arguments. 3) print the objc type being passed. Before: method-bad-param.m:15:1: error: Objective-C type cannot be passed by value -(void) my_method:(foo) my_param ^ after: method-bad-param.m:15:25: error: Objective-C interface type 'foo' cannot be passed by value -(void) my_method:(foo) my_param ^ llvm-svn: 68872
* Compare the predefines buffer in the PCH file with the predefinesDouglas Gregor2009-04-101-16/+0
| | | | | | | | | | | | | | | buffer generated for the current translation unit. If they are different, complain and then ignore the PCH file. This effectively checks for all compilation options that somehow would affect preprocessor state (-D, -U, -include, the dreaded -imacros, etc.). When we do accept the PCH file, throw away the contents of the predefines buffer rather than parsing them, since all of the results of that parsing are already stored in the PCH file. This eliminates the ugliness with the redefinition of __builtin_va_list, among other things. llvm-svn: 68838
OpenPOWER on IntegriCloud