summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Handle simple friend-class decls in class templates better by ensuring thatJohn McCall2010-03-251-61/+79
| | | | | | | we look for shadow friend decls in the appropriate scope before injecting a new declaration. llvm-svn: 99552
* Improve diagnostics when ivar added to classFariborz Jahanian2010-03-241-1/+1
| | | | | | extension (radar 6812436). llvm-svn: 99408
* Silently drop dependent friend function template specializations,Douglas Gregor2010-03-241-4/+11
| | | | | | | | since we have absolutely no way to match them when they are declared nor do we have a way to represent these parsed-but-not-checked friend declarations. llvm-svn: 99407
* Correct that last fixit: if the user wroteJohn McCall2010-03-241-2/+17
| | | | | | | | | template <> friend void foo(int); we need to change it to friend void foo<>(int); or else the user won't get the template specialization they obviously want. llvm-svn: 99390
* Support friend function specializations.John McCall2010-03-241-0/+10
| | | | llvm-svn: 99389
* When recovering from a qualified typedef name, don't clear out theDouglas Gregor2010-03-231-1/+2
| | | | | | | DeclContext because we don't want a NULL DeclContext. Instead, use the current context. llvm-svn: 99281
* Only perform CFG-based warnings on 'static inline' functions thatTed Kremenek2010-03-231-4/+3
| | | | | | | are called (transitively) by regular functions/blocks within a translation untion. llvm-svn: 99233
* -Wshadow should only warn about parameter declarations when we'reJohn McCall2010-03-221-12/+22
| | | | | | | | | entering a function or block definition, not on every single declaration. Unfortunately we don't have previous-lookup results around when it's time to make this decision, so we have to redo the lookup. The alternative is to use delayed diagnostics. llvm-svn: 99172
* Fix PR6618.Rafael Espindola2010-03-211-0/+4
| | | | | | | If a struct has an invalid field, mark it as invalid. Also avoid producing errors about incomplete types that are invalid. llvm-svn: 99150
* Refactor CFG-based warnings in Sema to be run by a worked object called ↵Ted Kremenek2010-03-201-14/+22
| | | | | | | | | | | | | | | AnalysisBasedWarnings. This object controls when the warnings are executed, allowing the client code in Sema to selectively disable warnings as needed. Centralizing the logic for analysis-based warnings allows us to optimize when and how they are run. Along the way, remove the redundant logic for the 'check fall-through' warning for blocks; now the same logic is used for both blocks and functions. llvm-svn: 99085
* Implement -Wshadow for parameter declarations as well.John McCall2010-03-201-18/+36
| | | | llvm-svn: 99037
* Redeclaration lookups for parameter names should be flagged as redeclaration ↵John McCall2010-03-181-1/+5
| | | | | | | | lookups so they don't trigger diagnostics like (say) access control. llvm-svn: 98806
* ActOnTagDefinitionError is supposed to 'unwind' ActOnTagStartDefinition, notJohn McCall2010-03-171-3/+3
| | | | | | | | ActOnStartCXXMemberDeclaration. We haven't started the field collector on this class yet, so don't stop it. Fixes a crash in the VS buildbot and a memory error on all the others. llvm-svn: 98760
* Remove warning about shadowing a built-in; built-ins aren't actuallyDouglas Gregor2010-03-171-9/+1
| | | | | | | considered to be a part of the translation unit unless they're named in a way that brings them into existence. llvm-svn: 98729
* Clean up after ourselves when there's an error parsing the base clause.John McCall2010-03-171-0/+12
| | | | | | Fixes the crash-on-invalid in PR6629. llvm-svn: 98698
* Implement -Wshadow. Based on a patch by Mike M.!John McCall2010-03-161-0/+62
| | | | llvm-svn: 98684
* Perform access control for the implicit calls to base and member destructorsJohn McCall2010-03-161-1/+2
| | | | | | that occur in constructors (on the unwind path). llvm-svn: 98681
* Remember declaration scope qualifiers in the AST. Imposes no memory overheadJohn McCall2010-03-151-0/+18
| | | | | | | | | | | on unqualified declarations. Patch by Enea Zaffanella! Minimal adjustments: allocate the ExtInfo nodes with the ASTContext and delete them during Destroy(). I audited a bunch of Destroy methods at the same time, to ensure that the correct teardown was being done. llvm-svn: 98540
* Use llvm::SmallVector instead of std::vector.Ted Kremenek2010-03-121-2/+3
| | | | llvm-svn: 98397
* Maintain type source information for functions through templateJohn McCall2010-03-111-0/+1
| | | | | | | | | | | instantiation. Based on a patch by Enea Zaffanella! I found a way to reduce some of the redundancy between TreeTransform's "standard" FunctionProtoType transformation and TemplateInstantiator's override, and I killed off the old SubstFunctionType by adding type source info for the last cases where we were creating FunctionDecls without TSI (at least that get passed through template instantiation). llvm-svn: 98252
* Create a new InjectedClassNameType to represent bare-word references to the John McCall2010-03-101-18/+1
| | | | | | | | | | | | | injected class name of a class template or class template partial specialization. This is a non-canonical type; the canonical type is still a template specialization type. This becomes the TypeForDecl of the pattern declaration, which cleans up some amount of code (and complicates some other parts, but whatever). Fixes PR6326 and probably a few others, primarily by re-establishing a few invariants about TypeLoc sizes. llvm-svn: 98134
* In C++98/03, an uninitialized variable that has POD class type will beDouglas Gregor2010-03-081-15/+29
| | | | | | | | | uninitialized. This seems not to be the case in C++0x, where we still call the (trivial) default constructor for a POD class (!). Previously, we had implemented only the C++0x rules; now we implement both. Fixes PR6536. llvm-svn: 97928
* Fix for PR6294: we should only delay recording nested dynamic classes if theyEli Friedman2010-03-071-1/+1
| | | | | | | are lexically nested. Othewise, we never end up recording semantically nested classes. llvm-svn: 97900
* Diagnose the declaration of enum templates. Also, be a bit moreDouglas Gregor2010-03-021-3/+4
| | | | | | careful about value-dependent enumerators. Fixes PR5786. llvm-svn: 97570
* Keep an explicit stack of function and block scopes, each element ofDouglas Gregor2010-03-011-26/+32
| | | | | | | | | | | | | | | | | | | | which has the label map, switch statement stack, etc. Previously, we had a single set of maps in Sema (for the function) along with a stack of block scopes. However, this lead to funky behavior with nested functions, e.g., in the member functions of local classes. The explicit-stack approach is far cleaner, and we retain a 1-element cache so that we're not malloc/free'ing every time we enter a function. Fixes PR6382. Also, tweaked the unused-variable warning suppression logic to look at errors within a given Scope rather than within a given function. The prior code wasn't looking at the right number-of-errors count when dealing with blocks, since the block's count would be deallocated before we got to ActOnPopScope. This approach works with nested blocks/functions, and gives tighter error recovery. llvm-svn: 97518
* Fix the lookup of names used in a friend declaration to not attempt toChandler Carruth2010-03-011-2/+3
| | | | | | | re-declare them. This fixes PR6317. Also add the beginnings of an interesting test case for p1 of [class.friend] which also covers PR6317. llvm-svn: 97499
* fix PR5933: don't warn about unused variables if a function has other errors ↵Chris Lattner2010-03-011-1/+2
| | | | | | in it. llvm-svn: 97498
* Implement jump checking for initialized c++ variables, implementingChris Lattner2010-03-011-4/+11
| | | | | | | | | | | | | | | | | | a fixme and PR6451. Only perform jump checking if the containing function has no errors, and add the infrastructure needed to do this. On the testcase in the PR, we produce: t.cc:6:3: error: illegal goto into protected scope goto later; ^ t.cc:7:5: note: jump bypasses variable initialization X x; ^ llvm-svn: 97497
* Fix a really trivial crasher and begin fleshing out one of the namespace testChandler Carruth2010-02-251-4/+7
| | | | | | cases. llvm-svn: 97134
* More Sema check for ivars in class continuation.Fariborz Jahanian2010-02-231-15/+2
| | | | llvm-svn: 97002
* Early support for declaring ivars in class extensions. wip.Fariborz Jahanian2010-02-221-0/+13
| | | | llvm-svn: 96819
* Add 'previous declaration is here' note for param redefinition Chris Lattner2010-02-221-3/+2
| | | | | | | | | | | | | errors, e.g.: t.c:1:21: error: redefinition of parameter 'x' int test(int x, int x); ^ t.c:1:14: note: previous declaration is here int test(int x, int x); ^ llvm-svn: 96769
* Eliminate the default arguments to ASTContext::getFunctionType(),Douglas Gregor2010-02-211-3/+9
| | | | | | | | fixing up a few callers that thought they were propagating NoReturn information but were in fact saying something about exception specifications. llvm-svn: 96766
* Make Decl::isOutOfLine() virtual, and use that to determine when definitionsChandler Carruth2010-02-211-8/+9
| | | | | | | are for out of line declarations more easily. This simplifies the logic and handles the case of out-of-line class definitions correctly. Fixes PR6107. llvm-svn: 96729
* Don't warn about functions redeclared without the dllimport attribute whenTed Kremenek2010-02-211-1/+5
| | | | | | -fms-extensions is enabled. Fixes <rdar://problem/7669559>. llvm-svn: 96721
* Patch removes IVars list from ObjCInterfaceDecl andFariborz Jahanian2010-02-191-1/+0
| | | | | | instead relies on their DeclContext for iteration, etc. llvm-svn: 96638
* Allow redefinitions of extern inline functions in GNU89 mode, just as GCCCharles Davis2010-02-181-2/+18
| | | | | | does. Fixes PR5253. llvm-svn: 96553
* When diagnosing enumerator values outside of the range of 'int', beDouglas Gregor2010-02-171-1/+1
| | | | | | | sure that we get the "too large" vs. "too small" part of the diagnostic correct. llvm-svn: 96524
* Do not add functions marked with the unused attribute to the list of unused ↵Tanya Lattner2010-02-171-1/+1
| | | | | | functions to warn about. Update test case. llvm-svn: 96452
* Complain if block-literal expression's parameter name isFariborz Jahanian2010-02-121-0/+1
| | | | | | missing (in c/objc mode). Fixes radar 7528255. llvm-svn: 96017
* Implementing unused function warning.Tanya Lattner2010-02-121-0/+9
| | | | llvm-svn: 95940
* Remove use of 'std::string' from Attr objects, using instead a byteTed Kremenek2010-02-111-7/+7
| | | | | | | | | array allocated using the allocator in ASTContext. This addresses these strings getting leaked when using a BumpPtrAllocator (in ASTContext). Fixes: <rdar://problem/7636765> llvm-svn: 95853
* Eliminate a bunch of unnecessary ASTContexts from members functions ofDouglas Gregor2010-02-111-10/+9
| | | | | | Decl subclasses. No functionality change. llvm-svn: 95841
* Eliminate the ASTContext parameter from RecordDecl::getDefinition()Douglas Gregor2010-02-111-1/+1
| | | | | | | and CXXRecordDecl::getDefinition(); it's totally unnecessary. No functionality change. llvm-svn: 95836
* Migrate the mish-mash of declaration checks inDouglas Gregor2010-02-091-173/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Sema::ActOnUninitializedDecl over to InitializationSequence (with default initialization), eliminating redundancy. More importantly, we now check that a const definition in C++ has an initilizer, which was an #if 0'd code for many, many months. A few other tweaks were needed to get everything working again: - Fix all of the places in the testsuite where we defined const objects without initializers (now that we diagnose this issue) - Teach instantiation of static data members to find the previous declaration, so that we build proper redeclaration chains. Previously, we had the redeclaration chain but built it too late to be useful, because... - Teach instantiation of static data member definitions not to try to check an initializer if a previous declaration already had an initializer. This makes sure that we don't complain about static const data members with in-class initializers and out-of-line definitions. - Move all of the incomplete-type checking logic out of Sema::FinalizeDeclaratorGroup; it makes more sense in ActOnUnitializedDecl. There may still be a few places where we can improve these diagnostics. I'll address that as a separate commit. llvm-svn: 95657
* Silence GCC warning and stay in 80 cols.Benjamin Kramer2010-02-061-4/+5
| | | | llvm-svn: 95494
* Implement a warning diagnostic for weak vtables. Fixes PR6116.Anders Carlsson2010-02-061-2/+9
| | | | llvm-svn: 95472
* Standardize the parsing of function type attributes in a way thatJohn McCall2010-02-051-13/+16
| | | | | | | | | | | | follows (as conservatively as possible) gcc's current behavior: attributes written on return types that don't apply there are applied to the function instead, etc. Only parse CC attributes as type attributes, not as decl attributes; don't accepet noreturn as a decl attribute on ValueDecls, either (it still needs to apply to other decls, like blocks). Consistently consume CC/noreturn information throughout codegen; enforce this by removing their default values in CodeGenTypes::getFunctionInfo(). llvm-svn: 95436
* A dependent initializer with zero arguments should return a NULLDouglas Gregor2010-02-051-1/+2
| | | | | | | initializer (for no initialization) rather than a ParenListExpr with zero arguments in it. llvm-svn: 95382
* A function declarator with a non-identifier name in an anonymous classDouglas Gregor2010-02-051-1/+2
| | | | | | is a constructor for that class, right? Fixes PR6238. llvm-svn: 95367
OpenPOWER on IntegriCloud