summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Allow dllimport/dllexport on inline functions and adjust the linkage.Hans Wennborg2014-05-151-14/+6
| | | | | | | | This is a step towards handling these attributes on classes (PR11170). Differential Revision: http://reviews.llvm.org/D3772 llvm-svn: 208925
* When we generate a redeclaration for anJohn McCall2014-05-141-1/+9
| | | | | | | elaborated-type-specifier, place it in the correct context. llvm-svn: 208799
* Create a redeclaration when an elaborated type specifierJohn McCall2014-05-141-3/+6
| | | | | | | | | resolves to an existing declaration if there are attributes present. This gives us something to apply the attributes to. llvm-svn: 208756
* PR19713: Don't warn on unused static inline functions, even if the 'inline' wasRichard Smith2014-05-111-2/+3
| | | | | | implied by 'constexpr'. llvm-svn: 208511
* Consolidate single void paramter checkingAlp Toker2014-05-111-6/+2
| | | | | | | | Also correct argument/parameter terminology. No change in functionality. llvm-svn: 208498
* Add support for partial jump scope checkingAlp Toker2014-05-091-2/+0
| | | | | | | | | | This lets us diagnose and perform more complete semantic analysis when faced with errors in the function body or declaration. By recovering here we provide more consistent diagnostics, particularly during interactive editing. llvm-svn: 208394
* If an instantiation of a template is required to be a complete type, checkRichard Smith2014-05-071-1/+6
| | | | | | | whether the definition of the template is visible rather than checking whether the instantiated definition happens to be in an imported module. llvm-svn: 208150
* Make module self-import an errorBen Langmuir2014-05-051-0/+7
| | | | | | | | Ideally, importing Foo.a from Foo.b would "do the right thing", but until it does, this patch makes it an error rather than allow it to silently be ignored. llvm-svn: 207948
* Minor cleanups, no behavior change.Nico Weber2014-05-031-11/+9
| | | | | | | | | | * Fixes a "return" that was indented at the same level as the continuation from the previous line * Wrap several lines to 80 columns * Remove an if check that was always true * Move a variable declaration slightly closer to its use llvm-svn: 207922
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-19/+19
| | | | llvm-svn: 207896
* Rewrite NRVO determination. Track NRVO candidates on the parser Scope and ↵Nick Lewycky2014-05-031-17/+8
| | | | | | | | apply the NRVO candidate flag to all possible NRVO candidates here, and remove the flags in computeNRVO or upon template instantiation. A variable now has NRVO applied if and only if every return statement in that scope returns that variable. This is nearly optimal. Performs NRVO roughly 7% more often in a bootstrap build of clang. Patch co-authored by Richard Smith. llvm-svn: 207890
* __thread: Move constant init check to CheckCompleteVariableDeclarationReid Kleckner2014-04-301-21/+20
| | | | | | | | | | We were emitting dynamic initializers for __thread variables if there was no explicit initializer, as in this test case: struct S { S(); }; __thread S s; llvm-svn: 207675
* -Wunused-parameter: Don't fire on defaulted or deleted functionsReid Kleckner2014-04-301-1/+3
| | | | | | | | Patch by Dinesh Dwivedi! Differential Revision: http://reviews.llvm.org/D3376 llvm-svn: 207672
* CodeGen: Fix linkage of reference temporariesDavid Majnemer2014-04-281-1/+2
| | | | | | | | | | | | | | | Summary: A reference temporary should inherit the linkage of the variable it initializes. Otherwise, we may hit cases where a reference temporary wouldn't have the same value in all translation units. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3515 llvm-svn: 207451
* PR19558: don't produce an "unused variable" warning for a variable template ↵Richard Smith2014-04-251-1/+2
| | | | | | partial specialization. llvm-svn: 207260
* Initial implementation of -modules-earch-all option, for searching for ↵John Thompson2014-04-231-6/+9
| | | | | | symbols in non-imported modules. llvm-svn: 206977
* Nitpicky refactoring -- use of nullptr and auto, made a bit more ↵Aaron Ballman2014-04-171-12/+12
| | | | | | const-correct. No functional changes intended. llvm-svn: 206491
* Refactor all the checking for missing 'template<>'s when a declaration has aRichard Smith2014-04-171-43/+24
| | | | | | template-id after its scope specifier into a single place. llvm-svn: 206442
* Don't emit an ExtWarn on declarations of variable template specializations;Richard Smith2014-04-171-6/+6
| | | | | | | we'll already have issued the relevant diagnostic when we saw the declaration of the primary template. llvm-svn: 206441
* [objc] -[NSObject init] is documented to not do anything, don't warn if ↵Argyrios Kyrtzidis2014-04-161-2/+14
| | | | | | | | subclasses do not call [super init] on their initializers. Part of rdar://16568441 llvm-svn: 206410
* Fix a comment to match the implementationAlp Toker2014-04-151-1/+1
| | | | llvm-svn: 206298
OpenPOWER on IntegriCloud