summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR18044: Reject declarations of enumtype::X early to avoid an assertion inRichard Smith2013-11-251-1/+1
| | | | | | downstream code. llvm-svn: 195687
* Provide better diagnostic wording for initializers on staticHans Wennborg2013-11-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | data member definitions when the variable has an initializer in its declaration. For the following code: struct S { static const int x = 42; }; const int S::x = 42; This patch changes the diagnostic from: a.cc:4:14: error: redefinition of 'x' const int S::x = 42; ^ a.cc:2:20: note: previous definition is here static const int x = 42; ^ to: a.cc:4:18: error: static data member 'x' already has an initializer const int S::x = 42; ^ a.cc:2:24: note: previous initialization is here static const int x = 42; ^ Differential Revision: http://llvm-reviews.chandlerc.com/D2235 llvm-svn: 195306
* Refine 'deprecated' checking for Objective-C classes/methods.Ted Kremenek2013-11-201-0/+17
| | | | | | | | | - If a deprecated class refers to another deprecated class, do not warn. - @implementations of a deprecated class can refer to other deprecated things. Fixes <rdar://problem/15407366> and <rdar://problem/15466783>. llvm-svn: 195259
* When wrapping lazily generated builtins in an extern "C" context,Enea Zaffanella2013-11-201-0/+1
| | | | | | flag the LinkageSpecDecl as being implicitly generated too. llvm-svn: 195255
* ObjectiveC 'objc_bridging'. Assorment of improvements Fariborz Jahanian2013-11-191-27/+0
| | | | | | per Doug/Jordan comments. // rdar://15454846. llvm-svn: 195066
* ObjectiveC ARC. Adopt objc_bridge attributeFariborz Jahanian2013-11-191-0/+27
| | | | | | | on struct/union/class instead of typedef of such types. // rdar://15454846 llvm-svn: 195061
* If a replaceable global operator new/delete is marked inline, don't warn ifRichard Smith2013-11-161-9/+14
| | | | | | | it's also __attribute__((used)), since that undoes the problematic part of 'inline'. llvm-svn: 194916
* Downgrade the Error on an 'inline' operator new or delete to an ExtWarn. SomeRichard Smith2013-11-161-1/+1
| | | | | | | projects are relying on such (questionable) practices, so we should give them a way to opt out of this diagnostic. llvm-svn: 194905
* When we hit a #include directive that maps to a module import, emit a tokenRichard Smith2013-11-151-0/+6
| | | | | | | | | | | | representing the module import rather than making the module immediately visible. This serves two goals: * It avoids making declarations in the module visible prematurely, if we walk past the #include during a tentative parse, for instance, and * It gives a diagnostic (although, admittedly, not a very nice one) if a header with a corresponding module is included anywhere other than at the top level. llvm-svn: 194782
* PR17533 and duplicates: don't compute the return type of an overloaded operatorRichard Smith2013-11-151-1/+5
| | | | | | | until after we've referenced the operator; otherwise, we might pick up a not-yet-deduced type. llvm-svn: 194775
* Revert r194663 and r194647.Ted Kremenek2013-11-141-12/+0
| | | | | | Per feedback from Jordan Rose I realized this wasn't the right way to go. llvm-svn: 194664
* Refine -Wunused-variable to only suppress warning for __bridge_transfer, not ↵Ted Kremenek2013-11-141-14/+4
| | | | | | | | | all bridge casts. Also refine test case to capture the intention of this suppression. Essentially some developers use __bridge_transfer as if it were a safe CFRelease. llvm-svn: 194663
* Added warning on structures/unions that are empty or contain onlySerge Pavlov2013-11-141-13/+29
| | | | | | | | | | bit fields of zero size. Warnings are generated in C++ mode and if only such type is defined inside extern "C" block. The patch fixed PR5065. Differential Revision: http://llvm-reviews.chandlerc.com/D2151 llvm-svn: 194653
* Suppress -Wunused-variable when initializer uses bridge casts for memory ↵Ted Kremenek2013-11-141-0/+22
| | | | | | | | management. Fixes <rdar://problem/15432770>. llvm-svn: 194647
* REFACTOR: Have PushLambdaScope return the LambdaScopeInfo that it creates.Faisal Vali2013-11-121-2/+2
| | | | | | | | No Functionality change. This refactoring avoids having to call getCurLambda right after PushLambdaScope, to obtain the LambdaScopeInfo that was created during the call to PushLambdaScope. llvm-svn: 194438
* This patch implements capturing of variables within generic lambdas.Faisal Vali2013-11-071-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both Richard and I felt that the current wording in the working paper needed some tweaking - Please see http://llvm-reviews.chandlerc.com/D2035 for additional context and references to core-reflector messages that discuss wording tweaks. What is implemented is what we had intended to specify in Bristol; but, recently felt that the specification might benefit from some tweaking and fleshing. As a rough attempt to explain the semantics: If a nested lambda with a default-capture names a variable within its body, and if the enclosing full expression that contains the name of that variable is instantiation-dependent - then an enclosing lambda that is capture-ready (i.e. within a non-dependent context) must capture that variable, if all intervening nested lambdas can potentially capture that variable if they need to, and all intervening parent lambdas of the capture-ready lambda can and do capture the variable. Of note, 'this' capturing is also currently underspecified in the working paper for generic lambdas. What is implemented here is if the set of candidate functions in a nested generic lambda includes both static and non-static member functions (regardless of viability checking - i.e. num and type of parameters/arguments) - and if all intervening nested-inner lambdas between the capture-ready lambda and the function-call containing nested lambda can capture 'this' and if all enclosing lambdas of the capture-ready lambda can capture 'this', then 'this' is speculatively captured by that capture-ready lambda. Hopefully a paper for the C++ committee (that Richard and I had started some preliminary work on) is forthcoming. This essentially makes generic lambdas feature complete, except for known bugs. The more prominent ones (and the ones I am currently aware of) being: - generic lambdas and init-captures are broken - but a patch that fixes this is already in the works ... - nested variadic expansions such as: auto K = [](auto ... OuterArgs) { vp([=](auto ... Is) { decltype(OuterArgs) OA = OuterArgs; return 0; }(5)...); return 0; }; auto M = K('a', ' ', 1, " -- ", 3.14); currently cause crashes. I think I know how to fix this (since I had done so in my initial implementation) - but it will probably take some work and back & forth with Doug and Richard. A warm thanks to all who provided feedback - and especially to Doug Gregor and Richard Smith for their pivotal guidance: their insight and prestidigitation in such matters is boundless! Now let's hope this commit doesn't upset the buildbot gods ;) Thanks! llvm-svn: 194188
* Do not allow functions or kernels called 'main' in OpenCL.Joey Gouly2013-11-051-0/+7
| | | | llvm-svn: 194068
* Sema: Disallow derived classes with virtual bases from having flexible array ↵David Majnemer2013-11-021-0/+9
| | | | | | | | | | | | | | | members Flexible array members only work out if they are the last field of a record, however virtual bases would give us many situations where the flexible array member would overlap with the virtual base fields. It is unlikely in the extreme that this behavior was intended by the user so raise a diagnostic instead of accepting. This is will not reject conforming code because flexible array members are an extension in C++ mode. llvm-svn: 193920
* Sema: Cleanup and simplify anonymous union diagnosticsDavid Majnemer2013-11-021-34/+23
| | | | | | | | | | | | | | | | The determination of which diagnostics would be issued for certain anonymous unions started to get a little ridiculous. Clean this up by inverting the condition-tree's logic from dialect -> issue to issue -> diagnostic. As part of this cleanup, move ext_c99_flexible_array_member from DiagnosticParseKinds.td to DiagnosticSemaKinds.td because it's driven by Sema, not Parse. Also, the liberty was taken to edit ext_c99_flexible_array_member to match other, similar, diagnostics. llvm-svn: 193919
* Sema: Flexible array members were introduced in C99, diagnose their use in C++David Majnemer2013-11-021-0/+6
| | | | | | | The declaration of a flexible array member was correctly diagnosed as an extension in C89 mode but not in C++. llvm-svn: 193918
* Sema: Properly indent statements in Sema::ActOnLastBitfieldDavid Majnemer2013-11-021-6/+6
| | | | llvm-svn: 193917
* Sema: trim trailing whitespace in Sema::ActOnLastBitfieldDavid Majnemer2013-11-021-4/+4
| | | | llvm-svn: 193916
* Wraps lazily generated builtins in an extern "C" contextWarren Hunt2013-11-011-4/+14
| | | | | | | | | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2082 Adds a lang_c LinkageSpecDecl to lazily generated builtins. This enforces correct behavior for builtins in a variety of cases without special treatment elsewhere within the compiler (special treatment is removed by the patch). It also allows for C++ overloads of builtin functions, which Microsoft uses in their headers e.g. _InterlockedExchangeAdd is an extern C builtin for the long type but an inline wrapper for int type. llvm-svn: 193896
* Store a TypeArgument on an attribute as a TypeSourceInfo*, rather than as aRichard Smith2013-10-311-3/+0
| | | | | | QualType with a SourceLocation stashed alongside. llvm-svn: 193803
* ObjectiveC: under -Wunused-property-ivar warn if property'sFariborz Jahanian2013-10-251-0/+1
| | | | | | | backing warning is not used in one of its accessor methods. // rdar://14989999 llvm-svn: 193439
* Consider used attributes in hidden decls.Rafael Espindola2013-10-251-0/+10
| | | | | | Without this patch we would warn and fail to output the function in the test. llvm-svn: 193388
* A decl never becomes unused. Make that explicit in the API.Rafael Espindola2013-10-231-2/+4
| | | | llvm-svn: 193248
* Refactor out the circular reference to LambdaExpr in CXXRecordDecl.Faisal Vali2013-10-231-22/+31
| | | | | | | | | | | | | | | | | A prior commit of this patch was reverted because it was within the blamelist's purview of a failing test. The failure of that test has been addressed here: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131021/091546.html. Therefore I am recommitting this patch (all tests pass on windows, except for the usual modules & index suspects that never pass on my box). Some background: Both Doug and Richard had asked me in Chicago to remove the circular reference in CXXRecordDecl to LambdaExpr by factoring out and storing the needed information from LambdaExpr directly into CXXRecordDecl. In addition, I have added an IsGenericLambda flag - this makes life a little easier when we implement capturing, and are Sema-analyzing the body of a lambda (and the calloperator hasn't been wired to the closure class yet). Any inner lambdas can have potential captures that could require walking up the scope chain and checking if any generic lambdas are capture-ready. This 'bit' makes some of that checking easier. No change in functionality. This patch was approved by Doug with minor modifications (comments were cleaned up, and all data members were converted from bool/enum to unsigned, as requested): http://llvm-reviews.chandlerc.com/D1856 Thanks! llvm-svn: 193246
* Revert r193223 and r193216.Rafael Espindola2013-10-231-31/+22
| | | | | | | | | | They were causing CodeGenCXX/mangle-exprs.cpp to fail. Revert "Remove the circular reference to LambdaExpr in CXXRecordDecl." Revert "Again: Teach TreeTransform and family how to transform generic lambdas nested within templates and themselves." llvm-svn: 193226
* Remove the circular reference to LambdaExpr in CXXRecordDecl.Faisal Vali2013-10-231-22/+31
| | | | | | | | | | | | | | | Both Doug and Richard had asked me to remove the circular reference in CXXRecordDecl to LambdaExpr by factoring out and storing the needed information from LambdaExpr directly into CXXRecordDecl. No change in functionality. In addition, I have added an IsGenericLambda flag - this makes life a little easier when we implement capturing, and are Sema-analyzing the body of a lambda (and the calloperator hasn't been wired to the closure class yet). Any inner lambdas can have potential captures that could require walking up the scope chain and checking if any generic lambdas are capture-ready. This 'bit' makes some of that checking easier. This patch was approved by Doug with minor modifications (comments were cleaned up, and all data members were converted from bool/enum to unsigned, as requested): http://llvm-reviews.chandlerc.com/D1856 Thanks! llvm-svn: 193223
* Retain previous language linkage of friend function declarationsAlp Toker2013-10-221-3/+16
| | | | | | | | | | | | | | | | | | With this extension, friend function declarations will retain the language linkage specified for previous declarations instead of emitting an error diagnostic. The feature is known to be compatible with GCC and MSVC and permits a language to be specified indirectly where it cannot otherwise be written directly in class scope. Work is ongoing to improve linkage spec diagnostics. Fixes PR17337. Reviewed by Richard Smith. llvm-svn: 193206
* Consider hidden decls for isUsed checks.Rafael Espindola2013-10-221-2/+2
| | | | | | | | | | | | | | | | | This fixes pr17624. A FIXME from Richard Smith: It seems to me that the root cause is that a per-Decl 'used' flag doesn't really make much sense in the way we use it now. I think we should either track whether that particular declaration is used (with isUsed scanning the entire redecl chain), or we should only have one flag for the entire redeclaration chain (perhaps by always looking at the flag on either the most recent decl or the canonical decl). Modeling it as "is this declaration or any previous declaration used" is weird, and requires contortions like the loop at the end of Sema::MarkFunctionReferenced. llvm-svn: 193202
* Treat aliases as definitions.Rafael Espindola2013-10-221-7/+54
| | | | | | | | | | | | | | This fixes pr17639. Before this patch clang would consider void foo(void) __attribute((alias("__foo"))); a declaration. It now correctly handles it as a definition. Initial patch by Alp Toker. I added support for variables. llvm-svn: 193200
* Use early return. No functionality change.Rafael Espindola2013-10-221-10/+12
| | | | llvm-svn: 193166
* Fix comment typoAlp Toker2013-10-221-1/+1
| | | | llvm-svn: 193154
* Sema: Explain our deviation from the standard by referencing the, now open, ↵David Majnemer2013-10-211-0/+2
| | | | | | LWG issue. llvm-svn: 193062
* Sema: Diagnose global replacement functions declared as inlineDavid Majnemer2013-10-201-0/+7
| | | | | | | | | | | This fixes PR17591. N.B. This actually goes beyond what the standard mandates by requiring the restriction to hold for declarations instead of definitions. This is believed to be a defect in the standard and an LWG issue has been submitted. llvm-svn: 193044
* Simplify some implementations of get*Decl.Rafael Espindola2013-10-191-1/+1
| | | | | | | | | | * NamedDecl and CXXMethodDecl were missing getMostRecentDecl. * The const version can just forward to the non const. * getMostRecentDecl can use cast instead of cast_or_null. This then removes some casts from the callers. llvm-svn: 193039
* Add isFirstDecl to DecBase too and use it instead of getPreviousDecl() == 0.Rafael Espindola2013-10-191-4/+4
| | | | | | Redeclarable already had a isFirstDecl, but it was missing from DeclBase. llvm-svn: 193027
* [-fms-extensions] Permit 'override' in C++98 and 'sealed' as a synonym for ↵David Majnemer2013-10-181-2/+4
| | | | | | | | | | | | | | 'final' Summary: Some MS headers use these features. Reviewers: rnk, rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1948 llvm-svn: 192936
* Rename some functions for consistency.Rafael Espindola2013-10-171-11/+11
| | | | | | Every other function in Redeclarable.h was using Decl instead of Declaration. llvm-svn: 192900
* Sema: Simplify the check if a method returns an instance of the class.Benjamin Kramer2013-10-161-1/+3
| | | | | | | Just checking if the parent of the method is the same as the return type should be sufficient. Also fixes PR17587. llvm-svn: 192802
* Adds Microsoft compatiable C++ record layout code to clang.Warren Hunt2013-10-111-2/+1
| | | | llvm-svn: 192494
* -Wmicrosoft: Don't warn on non-inline pure virtual method definitionsReid Kleckner2013-10-081-1/+1
| | | | | | | | | | | | | | | MSVC and clang with -fms-extensions allow pure virtual methods to be defined inline after the "= 0" tokens. Clang warns on these because it is not standard, but incorrectly warns on out-of-line definitions, which are standard. With this change, clang will only warn on inline definitions of pure virtual methods. Fixes some self-host warnings on out-of-line definitions of pure virtual destructors. llvm-svn: 192244
* Remove transient code I did not mean to check in.Ted Kremenek2013-10-081-12/+0
| | | | llvm-svn: 192211
* Convert anachronistic use of 'void *' to 'DeclContext *' in Scope that was a ↵Ted Kremenek2013-10-081-8/+17
| | | | | | holdover from the long-dead Action interface. llvm-svn: 192203
* [ms-cxxabi] Fix the calling convention for operator new in recordsReid Kleckner2013-10-081-4/+2
| | | | | | | | | | | | | | | | | | Summary: Operator new, new[], delete, and delete[] are all implicitly static when declared inside a record. CXXMethodDecl already knows this, but we need to account for that before we pick the calling convention for the function type. Fixes PR17371. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1761 llvm-svn: 192150
* Sema: Only merge typedef attributes if the previous decl is a typedefJustin Bogner2013-10-081-5/+5
| | | | | | | | | | | | In r186373, we started merging attributes on typedefs, but this causes us to try to merge attributes even if the previous declaration was not a typedef. Only merge the attributes if the previous decl was also a typedef. Fixes rdar://problem/15044218 llvm-svn: 192146
* Remove an unnecessary overload from ASTLambda.h Faisal Vali2013-09-291-1/+1
| | | | | | | As Richard pointed out to me, dyn_cast is very cheap - there is no real benefit from adding cluttery overloads to only avoid that cast. No functionality change. llvm-svn: 191646
* Per latest drafting, switch to implementing init-captures as if by declaringRichard Smith2013-09-281-2/+5
| | | | | | and capturing a variable declaration, and complete the implementation of them. llvm-svn: 191605
OpenPOWER on IntegriCloud