summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Objective-C. Recover from missing interface decl.Fariborz Jahanian2014-08-211-1/+2
| | | | | | | and checking on availability of method declaration instead of crashing. // rdar://18059669 llvm-svn: 216191
* C++1y is now C++14!Aaron Ballman2014-08-191-6/+6
| | | | | | Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording. llvm-svn: 215982
* Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid ↵Craig Topper2014-08-171-1/+1
| | | | | | needing to mention the size. llvm-svn: 215869
* Improve -Wuninitialized to catch const classes being used in their own copyRichard Trieu2014-08-121-0/+9
| | | | | | constructors. llvm-svn: 215471
* Sema: Handle declspecs without declarators in records properly in C modeDavid Majnemer2014-08-111-16/+28
| | | | | | | | | | | | | | | | | | | | | We had two bugs: - We wouldn't properly warn when a struct/union/enum was mentioned inside of a record definition if no declarator was provided. We should have mentioned that this declaration declares nothing. - We didn't properly support Microsoft's extension where certain declspecs without declarators would act as anonymous structs/unions. * We completely ignored the case where such a declspec could be a union. * We didn't properly handle the case where a record was defined inside another record: struct X { int a; struct Y { int b; }; }; llvm-svn: 215347
* [modules] When considering merging a newly-declared typedef into an importedRichard Smith2014-08-101-1/+38
| | | | | | | | | one, perform the import if the types match even if the imported declaration is hidden. Otherwise, NamedDecl::declarationReplaces will drop one of the name lookup entries, making the typedef effectively inaccessible from one of the modules that declared it. llvm-svn: 215306
* Don't drop dllimport from qualified friend redeclarations (PR20512)Hans Wennborg2014-08-041-4/+8
| | | | | | | | | | This matches MSVC's logic, which seems to be that when the friend declaration is qualified, it cannot be a declaration of a new symbol and so the dll linkage doesn't change. Differential Revision: http://reviews.llvm.org/D4764 llvm-svn: 214774
* Factor out exception specification information fromRichard Smith2014-07-311-6/+4
| | | | | | | | FunctionProtoType::ExtProtoInfo. Most of the users of these fields don't care about the other ExtProtoInfo bits and just want to talk about the exception specification. llvm-svn: 214450
* Local extern redeclarations of dllimport variables stay dllimport even if ↵Hans Wennborg2014-07-311-2/+3
| | | | | | they don't specify the attribute llvm-svn: 214425
* Delay check for prototype on __fastcall functions until after MergeFunctionDecl.Nico Weber2014-07-311-0/+12
| | | | | | | In C, it is only known after merging decls if a function with 0 arguments has a prototype. Fixes PR20386, see that for more notes. llvm-svn: 214408
* Add stopgap option -fmodule-implementation-of <name>Ben Langmuir2014-07-231-0/+3
| | | | | | | | | | | | | | | | | | This flag specifies that we are building an implementation file of the module <name>, preventing importing <name> as a module. This does not consider this to be the 'current module' for the purposes of doing modular checks like decluse or non-modular-include warnings, unlike -fmodule-name. This is needed as a stopgap until: 1) we can resolve relative includes to a VFS-mapped module (or can safely import a header textually and as part of a module) and ideally 2) we can safely do incremental rebuilding when implementation files import submodules. llvm-svn: 213767
* -fms-extensions: Implement half of #pragma init_segReid Kleckner2014-07-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This pragma is very rare. We could *hypothetically* lower some uses of it down to @llvm.global_ctors, but given that GlobalOpt isn't able to optimize prioritized global ctors today, there's really no point. If we wanted to do this in the future, I would check if the section used in the pragma started with ".CRT$XC" and had up to two characters after it. Those two characters could form the 16-bit initialization priority that we support in @llvm.global_ctors. We would have to teach LLVM to lower prioritized global ctors on COFF as well. This should let us compile some silly uses of this pragma in WebKit / Blink. Reviewers: rsmith, majnemer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4549 llvm-svn: 213593
* PR20356: Fix all Sema warnings with mismatched ext_/warn_ versusRichard Smith2014-07-191-2/+2
| | | | | | | | ExtWarn/Warnings. Mostly the name of the warning was changed to match the semantics, but in the PR20356 cases, the warning was about valid code, so the diagnostic was changed from ExtWarn to Warning instead. llvm-svn: 213443
* Objective-C. deprecated attribute is not inherited on methodsFariborz Jahanian2014-07-171-0/+2
| | | | | | | overriden in interfaces and protocols (this is already the case for properties). rdar://16068470 llvm-svn: 213282
* Fix FriendDecl source location and range for class templates and function ↵Nikola Smiljanic2014-07-171-0/+1
| | | | | | declarations that don't start with 'friend' keyword. Add more unittests. llvm-svn: 213220
* Consolidate header inclusion diagnosticsAlp Toker2014-07-111-23/+21
| | | | | | | Make argument orders match, unify diagnostic IDs and reword the message to be a little less saccharine. llvm-svn: 212845
* Return a FixItHint instead of taking a diagnostic builderReid Kleckner2014-07-111-7/+6
| | | | | | Addressing review comments from r212784. llvm-svn: 212786
* MSVC compat: Allow lookup of friend types in enclosing namespacesReid Kleckner2014-07-101-6/+63
| | | | | | | | | | | | | | | | | | | | | | | The relevant portion of C++ standard says [namespace.memdef]p3: If the name in a friend declaration is neither qualified nor a template-id and the declaration is a function or an elaborated-type-specifier, the lookup to determine whether the entity has been previously declared shall not consider any scopes outside the innermost enclosing namespace. MSVC does not implement that rule for types. If there is a type in an enclosing namespace, they consider an unqualified tag declaration with the same name to be a redeclaration of the type from another namespace. Implementing compatibility is a simple matter of disabling our implementation of this rule for types, which was added in r177473. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D4443 llvm-svn: 212784
* Sema: Allow aliases to have incomplete typeDavid Majnemer2014-07-091-5/+7
| | | | | | | | | | | | gcc supports this behavior and it is pervasively used inside the Linux kernel. Note that both gcc and clang will reject code that attempts to do this in a C++ language mode. This fixes PR17998. llvm-svn: 212631
* MS compat: Allow lookup of types from dependent bases in functionsReid Kleckner2014-07-081-2/+11
| | | | | | | | | | | | | | | | | | | | | | If we want to resolve the remaining FIXMEs here, we probably want to extend the main lookup mechanism to perform lookup into dependent bases, but we would have to tread lightly. Adding more name lookup has major impact on compile time. If we did extend the main mechanism, we would add a flag to LookupResult that allows us to find names from dependent base classes where the base is a specialization of a known template. The final LookupResult would still return LookupResult::NotFoundInCurrentInstantiation, but it would have a collection of Decls. If we find a real lookup result, we would clear the flag and the existing lookup results and begin accumulating only real lookup results. We would structure the lookup as a secondary lookup between normal lookup and typo correction for normal compilation, but for MSVC compatibility mode, we would always enable this extra lookup into dependent bases. llvm-svn: 212566
* Allow more lookup of types in dependent base classesReid Kleckner2014-07-081-0/+66
| | | | | | | | | | | | | | | | | | | | MSVC appears to perform name lookup into dependent base classes when the dependent base class has a known primary template. This allows them to know whether some unqualified ids are types or not, which allows them to parse more class templates without typename keywords. We can do the same thing when type name lookup fails, and if we find a single type decl in one of our dependent base classes, recover as though the user wrote 'typename MyClass::TypeFromBase'. This allows us to parse some COM smart pointer classes in wrl/client.h from the Windows 8 SDK. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D4237 llvm-svn: 212561
* Don't accept qualified 'int' main return types in C++ or standard C modeAlp Toker2014-07-021-22/+27
| | | | | | | | | C++ [basic.start.main]p1: "It shall have a return type of type int" ISO C is also clear about this, so only accept 'int' with qualifiers in GNUMode C. llvm-svn: 212171
* Introduce a FunctionDecl::getReturnTypeSourceRange() utilityAlp Toker2014-07-021-33/+18
| | | | | | | | | | This source range is useful for all kinds of diagnostic QOI and refactoring work, so let's make it more discoverable. This commit also makes use of the new function to enhance various diagnostics relating to return types and resolves an old FIXME. llvm-svn: 212154
* Import MutableArrayRef into clang namespace.Craig Topper2014-06-281-1/+1
| | | | llvm-svn: 211988
* Fix treatment of types defined in function prototypeSerge Pavlov2014-06-251-14/+19
| | | | | | | | | | | | Types defined in function prototype are diagnosed earlier in C++ compilation. They are put into declaration context where the prototype is introduced. Later on, when FunctionDecl object is created, these types are moved into the function context. This patch fixes PR19018 and PR18963. Differential Revision: http://reviews.llvm.org/D4145 llvm-svn: 211718
* Allow static_assert inside an anonymous union; fixes PR20021 as well as ↵Aaron Ballman2014-06-241-0/+2
| | | | | | implements C++ Issue 1940. llvm-svn: 211606
* [c++1z] Implement N3994: a range-based for loop can declare a variable with ↵Richard Smith2014-06-191-0/+31
| | | | | | | | | | | | super-terse notation for (x : range) { ... } which is equivalent to for (auto &&x : range) { ... } llvm-svn: 211267
* DiagnoseUnknownTypename always emits a diagnostic and returns trueReid Kleckner2014-06-191-5/+3
| | | | | | | | Make it return void and delete the dead code in the parser that handled the case where it might return false. This has been dead since 2010 when John deleted Action.h. llvm-svn: 211248
* Sema: Static redeclaration after extern declarations is a Microsoft ExtensionDavid Majnemer2014-06-181-23/+45
| | | | | | | | | | | CL permits static redeclarations to follow extern declarations. The storage specifier on the latter declaration has no effect. This fixes PR20034. Differential Revision: http://reviews.llvm.org/D4149 llvm-svn: 211238
* Inherit dll attributes to static localsHans Wennborg2014-06-181-0/+12
| | | | | | | | This makes us handle static locals in exported/imported functions correctly. Differential Revision: http://reviews.llvm.org/D4136 llvm-svn: 211173
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-24/+12
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* Recover from missing 'typename' in sizeof(T::InnerType)Reid Kleckner2014-06-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: 'sizeof' is a UnaryExprOrTypeTrait, and it can contain either a type or an expression. This change threads a RecoveryTSI parameter through the layers between TransformUnaryExprOrTypeTrait the point at which we look up the type. If lookup finds a single type result after instantiation, we now build TypeSourceInfo for it just like a normal transformation would. This fixes the last error in the hello world ATL app that I've been working with, and it now links and runs with clang. Please try it and file bugs! Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4108 llvm-svn: 210855
* Allow definition of dllimport static fields in partial specializations (PR19956)Hans Wennborg2014-06-091-2/+4
| | | | | | This expands the logic from r210141 to cover partial specializations too. llvm-svn: 210484
* Delay lookup of simple default template arguments under -fms-compatibilityReid Kleckner2014-06-061-0/+44
| | | | | | | | | | | | | | | | | | MSVC delays parsing of default arguments until instantiation. If the default argument is never used, it is never parsed. We don't model this. Instead, if lookup of a type name fails in a template argument context, we form a DependentNameType, which will be looked up at instantiation time. This fixes errors about 'CControlWinTraits' in atlwin.h. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D3995 llvm-svn: 210382
* Add pointer types to global named registerRenato Golin2014-06-051-0/+4
| | | | | | | | | | This patch adds support for pointer types in global named registers variables. It'll be lowered as a pair of read/write_register and inttoptr/ptrtoint calls. Also adds some early checks on types on SemaDecl to avoid the assert. Tests changed accordingly. (PR19837) llvm-svn: 210274
* Downgrade "definition of dllimport static field" error to warning for class ↵Hans Wennborg2014-06-041-2/+11
| | | | | | | | | | | | | | | | | | | templates (PR19902) This allows us to compile the following kind of code, which occurs in MSVC headers: template <typename> struct S { __declspec(dllimport) static int x; }; template <typename T> int S<T>::x; The definition works similarly to a dllimport inline function definition and gets available_externally linkage. Differential Revision: http://reviews.llvm.org/D3998 llvm-svn: 210141
* Sema: Check dll attributes on static data membersNico Rieck2014-05-291-4/+20
| | | | | | | Redeclarations cannot add a dll attribute and static data members cannot be defined. llvm-svn: 209825
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-2/+2
| | | | llvm-svn: 209812
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-14/+14
| | | | | | takeAs to getAs. llvm-svn: 209800
* Objective-C. Deprecate use of function definitionsFariborz Jahanian2014-05-281-0/+5
| | | | | | | in Objective-C container declarations (but not in their definitions. // rdar://10414277 llvm-svn: 209751
* Rejecting the mutable specifier on a freestanding type declaration, instead ↵Aaron Ballman2014-05-261-2/+7
| | | | | | of supporting it as a "extension" (which serves no purpose). Un-XFAILing the test for mutable specifiers. llvm-svn: 209635
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-162/+167
| | | | llvm-svn: 209613
* IRGen: Add more tests for dll attributesNico Rieck2014-05-251-1/+2
| | | | llvm-svn: 209596
* Emit used/dllexport inline method definitions in nested classes (PR19743, ↵Hans Wennborg2014-05-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR11170) The previous code that was supposed to handle this didn't work since parsing of inline method definitions is delayed to the end of the outer class definition. Thus, when HandleTagDeclDefinition() got called for the inner class, the inline functions in that class had not been parsed yet. Richard suggested that the way to do this is by handling inline method definitions through a new ASTConsumer callback. I really wanted to call ASTContext::DeclMustBeEmitted() instead of checking for attributes, but doing that causes us to compute linkage, and then we fail with "error: unsupported: typedef changes linkage of anonymous type, but linkage was already computed" on tests like this: (from SemaCXX/undefined-internal.cpp) :-/ namespace test7 { typedef struct { void bar(); void foo() { bar(); } } A; } Differential Revision: http://reviews.llvm.org/D3809 llvm-svn: 209549
* Implemented support for "pragma clang optimize on/off", based on attribute ↵Dario Domizioli2014-05-231-0/+5
| | | | | | | | | | | | | | | | 'optnone'. This patch implements support for selectively disabling optimizations on a range of function definitions through a pragma. The implementation is that all function definitions in the range are decorated with attribute 'optnone'. #pragma clang optimize off // All function definitions in here are decorated with 'optnone'. #pragma clang optimize on // Compilation resumes as normal. llvm-svn: 209510
* Improved location for non-constant initializers diagnostics.Abramo Bagnara2014-05-221-8/+12
| | | | llvm-svn: 209466
* An inline function redeclaration does not drop the dllimport attributeHans Wennborg2014-05-221-2/+4
| | | | llvm-svn: 209449
* Reduce string duplicationAlp Toker2014-05-201-7/+2
| | | | | | | If we're so keen on saving a dynamic allocation to add the trailing space, we might as well do it in style. llvm-svn: 209247
* Allow dllimport on function definitions when they're template instantiationsHans Wennborg2014-05-191-1/+2
| | | | llvm-svn: 209157
* Non-allocatable Global Named RegisterRenato Golin2014-05-191-7/+8
| | | | | | | | | | | | | This patch implements global named registers in Clang, lowering to the just created intrinsics in LLVM (@llvm.read/write_register). A new type of LValue had to be created (Register), which just adds support to carry the metadata node containing the name of the register. Two new methods to emit loads and stores interoperate with another to emit the named metadata node. No guarantees are being made and only non-allocatable global variable named registers are being supported. Local named register support is unchanged. llvm-svn: 209149
OpenPOWER on IntegriCloud