summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Sema: Do not merge new decls with invalid, old declsDavid Majnemer2013-07-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Sema::MergeFunctionDecl attempts merging two decls even if the old decl is invalid. This can lead to interesting circumstances where we successfully merge the decls but the result makes no sense. Take the following for example: template <typename T> int main(void); int main(void); Sema will not consider these to be overloads of the same name because main can't be overloaded, which means that this must be a redeclaration. In this case the templated decl is compatible with the non-templated decl allowing the Sema::CheckFunctionDeclaration machinery to move on and do bizarre things like setting the previous decl of a non-templated decl to a templated decl! The way I see it, we should just bail from MergeFunctionDecl if the old decl is invalid. This fixes PR16531. llvm-svn: 185779
* Sema: Fix a crash when main is redeclared as a function-template.David Majnemer2013-07-061-8/+8
| | | | | | | | | | This boils down to us sending invalid function decls to CheckFunctionDeclaration becauswe we did not consider that CheckMain could cause the decl to be invalid. Instead, interogate the new decl's main-validity and *then* send it over to get CheckFunctionDeclaration'd if it was still valid after calling CheckMain. llvm-svn: 185745
* Use SmallVectorImpl& for function arguments instead of SmallVector.Craig Topper2013-07-051-5/+5
| | | | llvm-svn: 185715
* Add a space between closing template '>' to unbreak build.Craig Topper2013-07-041-1/+1
| | | | llvm-svn: 185611
* Use SmallVectorImpl instead of SmallVector for iterators and references to ↵Craig Topper2013-07-041-1/+1
| | | | | | avoid specifying the vector size unnecessarily. llvm-svn: 185610
* Allow typo correction to try removing nested name specifiers.Kaelyn Uhrain2013-07-021-11/+21
| | | | | | | | | | | | | | | | | The removal is tried by retrying the failed lookup of a correction candidate with either the MemberContext or SS (CXXScopeSpecifier) or both set to NULL if they weren't already. If the candidate identifier is then looked up successfully, make a note in the candidate that the SourceRange should include any existing nested name specifier even if the candidate isn't adding a different one (i.e. the candidate has a NULL NestedNameSpecifier). Also tweak the diagnostic messages to differentiate between a suggestion that just replaces the identifer but leaves the existing nested name specifier intact and one that replaces the entire qualified identifier, in cases where the suggested replacement is unqualified. llvm-svn: 185487
* Fix to PR15826 - clang hits assert in clang::ASTContext::getASTRecordLayout.Serge Pavlov2013-07-021-1/+2
| | | | llvm-svn: 185446
* Reinstate r185229, reverted in r185256, with a tweak: further ignore theRichard Smith2013-06-301-55/+186
| | | | | | | | | | | | | | | | | | | | | | | standard's rule that an extern "C" declaration conflicts with any entity in the global scope with the same name. Now we only care if the global scope entity is a variable declaration (and so might have the same mangled name as the extern "C" declaration). This has been reported as a standard defect. Original commit message: PR7927, PR16247: Reimplement handling of matching extern "C" declarations across scopes. When we declare an extern "C" name that is not a redeclaration of an entity in the same scope, check whether it redeclares some extern "C" entity from another scope, and if not, check whether it conflicts with a (non-extern-"C") entity in the translation unit. When we declare a name in the translation unit that is not a redeclaration, check whether it conflicts with any extern "C" entities (possibly from other scopes). llvm-svn: 185281
* Revert r185229 as it breaks compilation of <windows.h>Timur Iskhodzhanov2013-06-291-181/+55
| | | | llvm-svn: 185256
* PR7927, PR16247: Reimplement handling of matching extern "C" declarationsRichard Smith2013-06-281-55/+181
| | | | | | | | | | | | | | | across scopes. When we declare an extern "C" name that is not a redeclaration of an entity in the same scope, check whether it redeclares some extern "C" entity from another scope, and if not, check whether it conflicts with a (non-extern-"C") entity in the translation unit. When we declare a name in the translation unit that is not a redeclaration, check whether it conflicts with any extern "C" entities (possibly from other scopes). llvm-svn: 185229
* Under -fms-extensions, only inject a friend tag name when we didn't see a ↵Douglas Gregor2013-06-271-3/+7
| | | | | | | | | | | | | | tag with that name in an enclosing scope. r177473 made us correctly consider only those declarations in the enclosing namespace scope when looking for a friend declaration. Under ms-extensions mode, where we do some level of friend injection, this meant that we were introducing a new tag type into a different scope than what Microsoft actually does. Address this by only doing the friend injection when we didn't see any tag with that name in any outer scope. Fixes <rdar://problem/14250378>. llvm-svn: 185100
* Don't check for triviality on fields of templated records. We can't know theNick Lewycky2013-06-251-2/+2
| | | | | | answer until after instantiation. Fixes PR16061! llvm-svn: 184890
* Fix null pointer dereference if we redeclare an unprototyped function. Patch byRichard Smith2013-06-251-9/+11
| | | | | | WenHan Gu! llvm-svn: 184875
* Improve diagnostic for redeclaring static member function. Fixes PR16382.Eli Friedman2013-06-191-1/+1
| | | | llvm-svn: 184378
* Fix pr16354.Rafael Espindola2013-06-191-1/+21
| | | | | | | | | | | We now reject things like struct ABC { static double a; }; register double ABC::a = 1.0; llvm-svn: 184300
* DR14, DR101, and part of DR1: fix handling of extern "C" declarations inRichard Smith2013-06-181-34/+40
| | | | | | | namespaces, by treating them just like we treat extern "C" declarations in function scope. llvm-svn: 184223
* Clean up empty struct/union recognition.Serge Pavlov2013-06-171-13/+15
| | | | | | | | | Make use of getTypeSizeInChars to detect structs/unions of zero size. It allows more accurate detection of types of zero size. It however has a side effect - sequence of used types may change, that is why the test 'override-layout' was modified. llvm-svn: 184088
* C++11: don't warn about the deprecated 'register' keyword if it's combined withRichard Smith2013-06-171-2/+12
| | | | | | an asm label. llvm-svn: 184069
* Unify return type checking for functions and ObjC methods. Move all theEli Friedman2013-06-141-17/+0
| | | | | | | | random checks for ObjC object return types to SemaType.cpp. Fixes issue with ObjC method type checking reported on cfe-dev. llvm-svn: 184006
* Allow clang to build __clear_cache on ARM.Rafael Espindola2013-06-131-1/+2
| | | | | | | | | __clear_cache is special. It needs no signature, but is a real function in compiler_rt or libgcc. Patch by Andrew Turner. llvm-svn: 183926
* Remove some unicode that sneaked in.David Majnemer2013-06-111-1/+1
| | | | llvm-svn: 183725
* Implement DR85: Redeclaration of member is forbiddenDavid Majnemer2013-06-111-0/+10
| | | | | | | Disallow the existence of a declaration of a member class that isn't a forward declaration before it's definition. llvm-svn: 183722
* Use FPT::getArgTypes() instead of manually building ArrayRefsReid Kleckner2013-06-101-10/+3
| | | | | | | | Made significantly easier with git-clang-format. Differential Revision: http://llvm-reviews.chandlerc.com/D947 llvm-svn: 183694
* Revert "[Sema] Make FunctionType's TSI use unadjusted argument types"Reid Kleckner2013-06-081-36/+31
| | | | | | | | | This reverts commit r183614. It broke test/Sema/block-printf-attribute-1.c on non-Windows platforms, and the fix is not trivial. llvm-svn: 183616
* [Sema] Make FunctionType's TSI use unadjusted argument typesReid Kleckner2013-06-081-31/+36
| | | | | | | | | | | | | | | | This helps preserve the type-as-written in the AST, which we need for MSVC mangling. In particular, we need to preserve the types of array parameters in function pointer types. The essence of this change is: - QualType ArgTy = Param->getType(); + QualType ArgTy = Param->getTypeSourceInfo()->getType(); ... followed by the adjustment in ActOnFunctionDeclarator(). Differential Revision: http://llvm-reviews.chandlerc.com/D883 llvm-svn: 183614
* Recognition of empty structures and unions is moved to semantic stageSerge Pavlov2013-06-081-0/+35
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D586 llvm-svn: 183609
* Microsoft has a language extension which allows union members to beAaron Ballman2013-05-301-3/+7
| | | | | | | references. What's more, they use this language extension in their ATL header files (which come as part of MFC and the Win32 SDK). This patch implements support for the Microsoft extension, and addresses PR13737. llvm-svn: 182936
* Disallow extern decls of type void in C++ modeDavid Majnemer2013-05-291-5/+9
| | | | | | | C++ and C differ with respect to the handling of extern void declarations. Enforce the C++ behavior in C++ mode. llvm-svn: 182814
* [ms-cxxabi] Look up operator delete() at every virtual dtor declaration.Peter Collingbourne2013-05-201-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the C++ standard requires that this lookup take place only at the definition point of a virtual destructor (C++11 [class.dtor]p12), the Microsoft ABI may require the compiler to emit a deleting destructor for any virtual destructor declared in the TU, including ones without a body, requiring an operator delete() lookup for every virtual destructor declaration. The result of the lookup should be the same no matter which declaration is used (except in weird corner cases). This change will cause us to reject some valid TUs in Microsoft ABI mode, e.g.: struct A { void operator delete(void *); }; struct B { void operator delete(void *); }; struct C : A, B { virtual ~C(); }; As Richard points out, every virtual function declared in a TU (including this virtual destructor) is odr-used, so it must be defined in any program which declares it, or the program is ill formed, no diagnostic required. Because we know that any definition of this destructor will cause the lookup to fail, the compiler can choose to issue a diagnostic here. Differential Revision: http://llvm-reviews.chandlerc.com/D822 llvm-svn: 182270
* Implement __declspec(selectany) under -fms-extensionsReid Kleckner2013-05-201-0/+9
| | | | | | | | | | | | | | | | selectany only applies to externally visible global variables. It has the effect of making the data weak_odr. The MSDN docs suggest that unused definitions can only be dropped at linktime, so Clang uses weak instead of linkonce. MSVC optimizes away references to constant selectany data, so it must assume that there is only one definition, hence weak_odr. Reviewers: espindola Differential Revision: http://llvm-reviews.chandlerc.com/D814 llvm-svn: 182266
* Check a pointer is not null before attempting to use it. This prevents aRichard Trieu2013-05-161-2/+4
| | | | | | crash on an explicit specialization of a member function in a class scope. llvm-svn: 181971
* Cleanup handling of UniqueExternalLinkage.Rafael Espindola2013-05-131-11/+11
| | | | | | | | | | | | | This patch renames getLinkage to getLinkageInternal. Only code that needs to handle UniqueExternalLinkage specially should call this. Linkage, as defined in the c++ standard, is provided by getFormalLinkage. It maps UniqueExternalLinkage to ExternalLinkage. Most places in the compiler actually want isExternallyVisible, which handles UniqueExternalLinkage as internal. llvm-svn: 181677
* Avoid patching storage class for block scope thread_local variables.Enea Zaffanella2013-05-101-16/+17
| | | | llvm-svn: 181627
* C++1y auto return type: when a function contains no 'return' statements at all,Richard Smith2013-05-101-13/+18
| | | | | | | substitute 'void' into the return type rather than replacing it with 'void', so that we maintain the 'auto' type sugar. llvm-svn: 181584
* Try to recognise hidden tag type names in potential declarations, in ObjC ↵Argyrios Kyrtzidis2013-05-071-12/+10
| | | | | | | | code as well. rdar://13829073 llvm-svn: 181345
* Replace 'MultiExprArg()' with 'None'Dmitri Gribenko2013-05-051-3/+3
| | | | llvm-svn: 181166
* Make all 'is in extern "C"' tests use the lexical context.Rafael Espindola2013-05-051-5/+3
| | | | | | | I was not able to find a case (other than the fix in r181163) where this makes a difference, but it is a more obviously correct API to have. llvm-svn: 181165
* Use lexical contexts when checking for conflicting language linkages.Rafael Espindola2013-05-051-2/+2
| | | | | | | This fixes pr14958. I will audit other calls to isExternCContext to see if there are any similar bugs left. llvm-svn: 181163
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-3/+1
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* In VarDecl nodes, store the thread storage class specifier as written.Enea Zaffanella2013-05-041-3/+1
| | | | llvm-svn: 181113
* Implement most of N3638 (return type deduction for normal functions).Richard Smith2013-05-041-7/+49
| | | | | | | Missing (somewhat ironically) is support for the new deduction rules in lambda functions, plus PCH support for return type patching. llvm-svn: 181108
* Say 'decltype(auto)' not 'auto' as appropriate in mismatched-deduction ↵Richard Smith2013-05-041-0/+1
| | | | | | diagnostic. llvm-svn: 181103
* PR15906: The body of a lambda is not an evaluated subexpression; don't visit ↵Richard Smith2013-05-031-1/+1
| | | | | | it when visiting such subexpressions. llvm-svn: 181046
* ArrayRef'ize InitializationSequence constructor and ↵Dmitri Gribenko2013-05-031-10/+8
| | | | | | | | InitializationSequence::Diagnose() Patch by Robert Wilhelm. llvm-svn: 181022
* Add const qualifier to Sema::getTypeName's parameter `II`Dmitri Gribenko2013-05-031-1/+1
| | | | | | Patch by Ismail Pazarbasi. llvm-svn: 181011
* Use attribute argument information to determine when to parse attribute ↵Douglas Gregor2013-05-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | arguments as expressions. This change partly addresses a heinous problem we have with the parsing of attribute arguments that are a lone identifier. Previously, we would end up parsing the 'align' attribute of this as an expression "(Align)": template<unsigned Size, unsigned Align> class my_aligned_storage { __attribute__((align((Align)))) char storage[Size]; }; while this would parse as a "parameter name" 'Align': template<unsigned Size, unsigned Align> class my_aligned_storage { __attribute__((align(Align))) char storage[Size]; }; The code that handles the alignment attribute would completely ignore the parameter name, so the while the first of these would do what's expected, the second would silently be equivalent to template<unsigned Size, unsigned Align> class my_aligned_storage { __attribute__((align)) char storage[Size]; }; i.e., use the maximal alignment rather than the specified alignment. Address this by sniffing the "Args" provided in the TableGen description of attributes. If the first argument is "obviously" something that should be treated as an expression (rather than an identifier to be matched later), parse it as an expression. Fixes <rdar://problem/13700933>. llvm-svn: 180973
* Revert r180970; it's causing breakage.Douglas Gregor2013-05-021-2/+2
| | | | llvm-svn: 180972
* Use attribute argument information to determine when to parse attribute ↵Douglas Gregor2013-05-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | arguments as expressions. This change partly addresses a heinous problem we have with the parsing of attribute arguments that are a lone identifier. Previously, we would end up parsing the 'align' attribute of this as an expression "(Align)": template<unsigned Size, unsigned Align> class my_aligned_storage { __attribute__((align((Align)))) char storage[Size]; }; while this would parse as a "parameter name" 'Align': template<unsigned Size, unsigned Align> class my_aligned_storage { __attribute__((align(Align))) char storage[Size]; }; The code that handles the alignment attribute would completely ignore the parameter name, so the while the first of these would do what's expected, the second would silently be equivalent to template<unsigned Size, unsigned Align> class my_aligned_storage { __attribute__((align)) char storage[Size]; }; i.e., use the maximal alignment rather than the specified alignment. Address this by sniffing the "Args" provided in the TableGen description of attributes. If the first argument is "obviously" something that should be treated as an expression (rather than an identifier to be matched later), parse it as an expression. Fixes <rdar://problem/13700933>. llvm-svn: 180970
* When deducing an 'auto' type, don't modify the type-as-written.Richard Smith2013-04-301-7/+7
| | | | llvm-svn: 180808
* Don't treat a non-deduced 'auto' type as being type-dependent. Instead, thereRichard Smith2013-04-301-54/+68
| | | | | | | | are now two distinct canonical 'AutoType's: one is the undeduced 'auto' placeholder type, and the other is a deduced-but-dependent type. All deduced-to-a-non-dependent-type cases are still non-canonical. llvm-svn: 180789
OpenPOWER on IntegriCloud