summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* refactor C++ bitfield checking a bit (haha)Chris Lattner2009-03-051-3/+5
| | | | llvm-svn: 66213
* fix PR3607 and a fixme, by checking bitfield constraintsChris Lattner2009-03-051-10/+34
| | | | | | more consistently. llvm-svn: 66210
* When parsing a function body, add it to the crash stack, giving us somethingChris Lattner2009-03-051-0/+9
| | | | | | | | | | | | | like: Stack dump: 0. t.c:5:10: in compound statement ('{}') 1. t.c:3:12: in compound statement ('{}') 2. t.c:3:12: parsing function body 'foo' 3. clang t.c Abort llvm-svn: 66118
* Check that the return type for function definitions is complete.Eli Friedman2009-03-041-0/+8
| | | | llvm-svn: 66027
* Switch attributes to be allocated from the declcontext bump pointer just likeChris Lattner2009-03-041-10/+11
| | | | | | | decls. This reduces the number of calls to malloc on cocoa.h with pth and -disable-free from 15958 to 12444 times (down ~3500). llvm-svn: 66023
* add an a Attr::Destroy method and force clients to go through it. As part of Chris Lattner2009-03-041-6/+6
| | | | | | this, make DeclBase::Destroy destroy attributes instead of the DeclBase dtor. llvm-svn: 66020
* Implement the basics of implicit instantiation of class templates, inDouglas Gregor2009-03-031-5/+8
| | | | | | | | | | | | | | | | | | | | response to attempts to diagnose an "incomplete" type. This will force us to use DiagnoseIncompleteType more regularly (rather than looking at isIncompleteType), but that's also a good thing. Implicit instantiation is still very simplistic, and will create a new definition for the class template specialization (as it should) but it only actually instantiates the base classes and attaches those. Actually instantiating class members will follow. Also, instantiate the types of non-type template parameters before checking them, allowing, e.g., template<typename T, T Value> struct Constant; to work properly. llvm-svn: 65924
* Rework the way we find locally-scoped external declarations when weDouglas Gregor2009-03-021-68/+69
| | | | | | | | | | | 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
* Whoops, actually remove the VLA/VM check in FinalizeDeclaratorGroup.Anders Carlsson2009-02-281-36/+0
| | | | llvm-svn: 65737
* Fix invalid VLAs/VMs in Sema::ActOnVariableDeclarator, so that the variable ↵Anders Carlsson2009-02-281-0/+36
| | | | | | | | | | | 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
* Fix a crash in test/Parser/control-scope.c that testrunner didn'tChris Lattner2009-02-281-1/+1
| | | | | | | | notice because it was a negative test with a fix suggested by Jean-Daniel Dupas. Convert the test from a negative to a positive test to catch stuff like this. llvm-svn: 65708
* Fix <rdar://problem/6451399> problems with labels and blocks.Steve Naroff2009-02-281-6/+21
| | | | | | | | | - 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
* Check a few more kinds of declarations that make a scope.Eli Friedman2009-02-281-0/+3
| | | | llvm-svn: 65680
* Start of checking for gotos which jump to an illegal destination. Eli Friedman2009-02-281-2/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix minor memory leak. Add comment describing what we need to do for Eli Friedman2009-02-271-7/+16
| | | | | | strict constant initializer checking. llvm-svn: 65612
* Create a new TypeNodes.def file that enumerates all of the types,Douglas Gregor2009-02-261-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | giving them rough classifications (normal types, never-canonical types, always-dependent types, abstract type representations) and making it far easier to make sure that we've hit all of the cases when decoding types. Switched some switch() statements on the type class over to using this mechanism, and filtering out those things we don't care about. For example, CodeGen should never see always-dependent or non-canonical types, while debug info generation should never see always-dependent types. More switch() statements on the type class need to be moved over to using this approach, so that we'll get warnings when we add a new type then fail to account for it somewhere in the compiler. As part of this, some types have been renamed: TypeOfExpr -> TypeOfExprType FunctionTypeProto -> FunctionProtoType FunctionTypeNoProto -> FunctionNoProtoType There shouldn't be any functionality change... llvm-svn: 65591
* Zap the Sema constant initializer checking code that we aren't using Eli Friedman2009-02-261-527/+2
| | | | | | | | anymore. If we want to reuse bits and pieces to add strict checking for constant initializers, we can dig them out of SVN history; the existing code won't be useful as-is. llvm-svn: 65502
* Fix for PR3663/3669: use TryToFixInvalidVariablyModifiedType for Eli Friedman2009-02-261-33/+37
| | | | | | | variable declarations where applicable. Also, a few fixes to TryToFixInvalidVariablyModifiedType for issues that this exposed. llvm-svn: 65500
* C99 DR #316 implies that the function parameter types that are knownDouglas Gregor2009-02-251-1/+7
| | | | | | | | | | only from a function definition (that does not have a prototype) are only used to determine the compatible with other declarations of that same function. In particular, when referencing the function we pretend as if it does not have a prototype. Implement this behavior, which fixes PR3626. llvm-svn: 65460
* move some initialization checking code from SemaDecl.cppChris Lattner2009-02-241-141/+0
| | | | | | to SemaInit.cpp, no functionality change. llvm-svn: 65394
* first wave of fixes for @encode sema support. This is part of PR3648.Chris Lattner2009-02-241-2/+2
| | | | | | | The big difference here is that (like string literal) @encode has array type, not pointer type. llvm-svn: 65391
* some minor cleanups, handle ObjCEncodeExpr in a couple places.Chris Lattner2009-02-241-6/+6
| | | | llvm-svn: 65389
* When we're declaring an object or function with linkage, teach nameDouglas Gregor2009-02-241-22/+27
| | | | | | | lookup to skip over names without linkage. This finishes <rdar://problem/6127293>. llvm-svn: 65386
* Extend the implicit declaration and checking against out-of-scopeDouglas Gregor2009-02-241-103/+161
| | | | | | | | | | | | | external declarations to also support external variable declarations. Unified the code for these two cases into two new subroutines. Note that we fail to diagnose cases like the one Neil pointed out, where a visible non-external declaration hides an external declaration by the same name. That will require some reshuffling of name lookup. llvm-svn: 65385
* In C, when we see a function declaration within a local scope, exportDouglas Gregor2009-02-241-0/+52
| | | | | | | | | | that declaration to global scope so that it can be found from other scopes. This allows us to diagnose redeclaration errors for external declarations across scopes. We also warn when name lookup finds such an out-of-scope declaration. This is part of <rdar://problem/6127293>; we'll also need to do the same thing for variables. llvm-svn: 65373
* Improve merging of function declarations. Specifically:Douglas Gregor2009-02-241-25/+115
| | | | | | | | | | | | | | | | - When we are declaring a function in local scope, we can merge with a visible declaration from an outer scope if that declaration refers to an entity with linkage. This behavior now works in C++ and properly ignores entities without linkage. - Diagnose the use of "static" on a function declaration in local scope. - Diagnose the declaration of a static function after a non-static declaration of the same function. - Propagate the storage specifier to a function declaration from a prior declaration (PR3425) - Don't name-mangle "main" llvm-svn: 65360
* fix rdar://6611778, a redefinition of an interface was causing anChris Lattner2009-02-231-4/+11
| | | | | | | | assertion when the ivars and method list was reset into the existing interface. To fix this, mark decls as invalid when they are redefined, and don't insert ivars/methods into invalid decls. llvm-svn: 65340
* Throw the switch to exclusively use Evaluate (along with the small Eli Friedman2009-02-221-0/+6
| | | | | | | | | | | | | | | | helper isConstantInitializer) to check whether an initializer is constant. This passes tests, but it's possible that it'll cause regressions with real-world code. Future work: 1. The diagnostics obtained this way are lower quality at the moment; some work both here and in Evaluate is needed for accurate diagnostics. 2. We probably need some extra code when we're in -pedantic mode so we can strictly enforce the rules in C99 6.6p7. 3. Dead code cleanup (this should wait until after 2, because we might want to re-use some of the code). llvm-svn: 65265
* Warn on use of __weak attribute on localFariborz Jahanian2009-02-211-0/+5
| | | | | | variable (objc2 gc specific). llvm-svn: 65240
* Slight tweak to last commit: make sure to copy CVR qualifiers for fixed Eli Friedman2009-02-211-1/+3
| | | | | | pointer types. llvm-svn: 65210
* Re-fix r65140 correctly.Eli Friedman2009-02-211-10/+69
| | | | llvm-svn: 65208
* Fix <rdar://problem/6500554> missing objc error message.Steve Naroff2009-02-201-4/+9
| | | | llvm-svn: 65198
* add plumbing to get ASTContext& down to allocation/deallocation points in ↵Chris Lattner2009-02-201-2/+4
| | | | | | | | ObjCList, but don't start using it yet. Renamed some methods to be more consistent. llvm-svn: 65168
* move the @implementation ivar list to being an ObjCList, which preventsChris Lattner2009-02-201-8/+5
| | | | | | it from being leaked, among other things. llvm-svn: 65150
* Always try to fold array sizes, and warn if we could fold something that ↵Anders Carlsson2009-02-201-44/+3
| | | | | | isn't an ICE. This makes us compatible with GCC. llvm-svn: 65140
* Fix <rdar://problem/6586239> bitfield constraints not enforced (for ObjC)Steve Naroff2009-02-201-6/+3
| | | | llvm-svn: 65128
* Suppress constant initializer checking when the declaration isn't valid. Eli Friedman2009-02-201-2/+4
| | | | | | | | This prevents emitting diagnostics which are almost certainly useless. (Note that the test is checking that we emit only one diagnostic.) llvm-svn: 65101
* GetTypeForDeclarator can return null on error now, handle this.Chris Lattner2009-02-191-1/+4
| | | | llvm-svn: 65076
* Emit the correct diagnostics when we constant fold an array size to a ↵Anders Carlsson2009-02-191-3/+13
| | | | | | negative value. llvm-svn: 65023
* Couple of helpers for objc's gc attributes.Fariborz Jahanian2009-02-191-1/+1
| | | | | | No change in functionality. llvm-svn: 64989
* Return true on errors, return true on errors, return true on errorsDouglas Gregor2009-02-181-1/+1
| | | | llvm-svn: 64957
* Downgrade complaints about calling unavailable functions to a warningDouglas Gregor2009-02-181-6/+15
| | | | | | | | | | | | | | | | | | (as GCC does), except when we've performed overload resolution and found an unavailable function: in this case, we actually error. Merge the checking of unavailable functions with the checking for deprecated functions. This unifies a bit of code, and makes sure that we're checking for unavailable functions in the right places. Also, this check can cause an error. We may, eventually, want an option to make "unavailable" warnings into errors. Implement much of the logic needed for C++0x deleted functions, which are effectively the same as "unavailable" functions (but always cause an error when referenced). However, we don't have the syntax to specify deleted functions yet :) llvm-svn: 64955
* Make warn-weak-field.m test pass again.Fariborz Jahanian2009-02-181-0/+2
| | | | llvm-svn: 64927
* Allow "overloadable" functions in C to be declared as variadic withoutDouglas Gregor2009-02-181-1/+2
| | | | | | | | | | | | | | | any named parameters, e.g., this is accepted in C: void f(...) __attribute__((overloadable)); although this would be rejected: void f(...); To do this, moved the checking of the "ellipsis without any named arguments" condition from the parser into Sema (where it belongs anyway). llvm-svn: 64902
* Don't allow calls to functions marked "unavailable". There's more workDouglas Gregor2009-02-181-3/+19
| | | | | | | | | | to do in this area, since there are other places that reference FunctionDecls. Don't allow "overloadable" functions (in C) to be declared without a prototype. llvm-svn: 64897
* Remove one more redundant dyn_cast.Argyrios Kyrtzidis2009-02-171-3/+0
| | | | llvm-svn: 64808
* Remove some redundant Decl -> Decl castings.Argyrios Kyrtzidis2009-02-171-3/+2
| | | | llvm-svn: 64804
* All Decls have a DeclContext now, hooray! Fans of consistency rejoice.Argyrios Kyrtzidis2009-02-171-1/+1
| | | | | | Pass the DeclContext to ObjCIvarDecls as well. llvm-svn: 64801
* Remove the error about redefining library functions. It's causing tooDouglas Gregor2009-02-171-5/+3
| | | | | | much pain when compiling the Linux kernel (PR3592). llvm-svn: 64767
* Static variables and functions won't collide with standard libraryDouglas Gregor2009-02-171-1/+3
| | | | | | | functions, so if we're declaring a static we should implicitly declare a library function by the same name (e.g., malloc, strdup). Fixes PR3592. llvm-svn: 64736
OpenPOWER on IntegriCloud