summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't assert when trying to diagnose why a class with a constructor template isRichard Smith2012-02-261-9/+25
| | | | | | non-trivial. llvm-svn: 151486
* Try to handle qualifiers more consistently for array InitListExprs. Fixes ↵Eli Friedman2012-02-231-3/+1
| | | | | | | | <rdar://problem/10907510>, and makes the ASTs a bit more self-consistent. (I've chosen to keep the qualifiers, but it isn't a strong preference; if anyone prefers removing them, please yell.) llvm-svn: 151229
* modern objc translator. Finish off first cut of theFariborz Jahanian2012-02-201-0/+4
| | | | | | | modern meta-data translation by commenting out private ivar declarations in user source. Also, added several tests. llvm-svn: 150985
* When we resolve the type of an 'auto' variable, clear out the linkageDouglas Gregor2012-02-201-1/+2
| | | | | | | of that variable; it will need to be recomputed with the resolved type. llvm-svn: 150984
* Remove a debugging line accidentally left in the last commit.David Chisnall2012-02-181-1/+0
| | | | llvm-svn: 150882
* Implement #pragma redefine_extname.David Chisnall2012-02-181-0/+32
| | | | | | This fixes PR5172 and allows clang to compile C++ programs on Solaris using the system headers. llvm-svn: 150881
* Avoid infinite mutual recursion in DiagnoseInvalidRedeclaration.Kaelyn Uhrain2012-02-161-2/+18
| | | | | | | | Don't try to typo-correct a method redeclaration to declarations not in the current record as it could lead to infinite recursion if CorrectTypo finds more than one correction candidate in a parent record. llvm-svn: 150735
* C++11 allows unions to have static data members. Remove the correspondingRichard Smith2012-02-161-7/+11
| | | | | | restriction and add some tests. llvm-svn: 150721
* Shift Microsoft enum extensions from -fms-extensions to -fms-compatibility, ↵Eli Friedman2012-02-161-3/+3
| | | | | | so -fms-extensions doesn't affect enum semantics in incompatible ways. <rdar://problem/10657186>. llvm-svn: 150663
* Warn about non-int main() results in GNU C mode instead of erroring.John McCall2012-02-141-12/+21
| | | | | | Based on a patch by Vasiliy Korchagin! llvm-svn: 150500
* Deal with a horrible C++11 special case. If a non-literal type has a constexprRichard Smith2012-02-131-8/+8
| | | | | | | | | | | constructor, and that constructor is used to initialize an object of static storage duration such that all members and bases are initialized by constant expressions, constant initialization is performed. In this case, the object can still have a non-trivial destructor, and if it does, we must emit a dynamic initializer which performs no initialization and instead simply registers that destructor. llvm-svn: 150419
* Update constexpr implementation to match CWG's chosen approach for core issuesRichard Smith2012-02-131-9/+13
| | | | | | | | | | | | | | | | | | | | 1358, 1360, 1452 and 1453. - Instantiations of constexpr functions are always constexpr. This removes the need for separate declaration/definition checking, which is now gone. - This makes it possible for a constexpr function to be virtual, if they are only dependently virtual. Virtual calls to such functions are not constant expressions. - Likewise, it's now possible for a literal type to have virtual base classes. A constexpr constructor for such a type cannot actually produce a constant expression, though, so add a special-case diagnostic for a constructor call to such a type rather than trying to evaluate it. - Classes with trivial default constructors (for which value initialization can produce a fully-initialized value) are considered literal types. - Classes with volatile members are not literal types. - constexpr constructors can be members of non-literal types. We do not yet use static initialization for global objects constructed in this way. llvm-svn: 150359
* Employ DirectList initialized entities to properly sort through some ↵Sebastian Redl2012-02-121-3/+6
| | | | | | initialization edge cases. llvm-svn: 150342
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-111-35/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of having a special-purpose function. - ActOnCXXDirectInitializer, which was mostly duplication of AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days ago), is dropped completely. - MultiInitializer, which was an ugly hack I added, is dropped again. - We now have the infrastructure in place to distinguish between int x = {1}; int x({1}); int x{1}; -- VarDecl now has getInitStyle(), which indicates which of the above was used. -- CXXConstructExpr now has a flag to indicate that it represents list- initialization, although this is not yet used. - InstantiateInitializer was renamed to SubstInitializer and simplified. - ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which always produces a ParenListExpr. Placed that so far failed to convert that back to a ParenExpr containing comma operators have been fixed. I'm pretty sure I could have made a crashing test case before this. The end result is a (I hope) considerably cleaner design of initializers. More importantly, the fact that I can now distinguish between the various initialization kinds means that I can get the tricky generalized initializer test cases Johannes Schaub supplied to work. (This is not yet done.) This commit passed self-host, with the resulting compiler passing the tests. I hope it doesn't break more complicated code. It's a pretty big change, but one that I feel is necessary. llvm-svn: 150318
* PR11684, core issue 1417:Richard Smith2012-02-101-18/+0
| | | | | | | | | | | | | | o Correct the handling of the restrictions on usage of cv-qualified and ref-qualified function types. o Fix a bug where such types were rejected in template type parameter default arguments, due to such arguments not being treated as a template type arg context. o Remove the ExtWarn for usage of such types as template arguments; that was a standard defect, not a GCC extension. o Improve the wording and unify the code for diagnosing cv-qualifiers with the code for diagnosing ref-qualifiers. llvm-svn: 150244
* Adding support for warning when a non-C compatible user-defined type is ↵Aaron Ballman2012-02-091-0/+11
| | | | | | | | returned from an extern "C" function. Fixes bug 6143 llvm-svn: 150128
* When completing a lambda expression, make sure to check and attach theDouglas Gregor2012-02-081-1/+2
| | | | | | body of the lambda to the function call operator. llvm-svn: 150087
* Fix a bug in semantic analysis involving anonymous structs and flexible arrays.Eli Friedman2012-02-071-2/+14
| | | | llvm-svn: 149966
* Fix a couple of nasty bugs involving negative enum constants. ↵Eli Friedman2012-02-071-19/+18
| | | | | | <rdar://problem/10760113>. llvm-svn: 149965
* Removed redundant location info from ElaboratedTypeLoc / DependentNameLoc / ↵Abramo Bagnara2012-02-061-1/+1
| | | | | | DependentTSTLoc. Uniformed names referencing elaborated keyword. No intended functionality changes. llvm-svn: 149889
* constexpr: Implement DR1358: An instantiation of a constexpr function whichRichard Smith2012-02-051-1/+1
| | | | | | | can't produce a constant expression is not ill-formed (so long as some instantiation of that function can produce a constant expression). llvm-svn: 149802
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-19/+23
| | | | | | | | | | | | | | | | | | value of class type, look for a unique conversion operator converting to integral or unscoped enumeration type and use that. Implements [expr.const]p5. Sema::VerifyIntegerConstantExpression now performs the conversion and returns the converted result. Some important callers of Expr::isIntegralConstantExpr have been switched over to using it (including all of those required for C++11 conformance); this switch brings a side-benefit of improved diagnostics and, in several cases, simpler code. However, some language extensions and attributes have not been moved across and will not perform implicit conversions on constant expressions of literal class type where an ICE is required. In passing, fix static_assert to perform a contextual conversion to bool on its argument. llvm-svn: 149776
* Disallow constexpr main.Richard Smith2012-02-041-2/+7
| | | | llvm-svn: 149770
* Don't warn about anonymous struct/union in C11.Hans Wennborg2012-02-031-5/+7
| | | | | | Also, in C, call this a C11 extension rather than a GNU extension. llvm-svn: 149695
* Add some code to accurately perform odr-used marking for variables per the ↵Eli Friedman2012-02-021-0/+2
| | | | | | C++11 rules. llvm-svn: 149641
* objc: don't crash if primary class is missing and continuation classFariborz Jahanian2012-02-021-0/+2
| | | | | | is declaring ivars. // rdar://10752081 llvm-svn: 149573
* Fix crash on invalid in microsoft anonymous struct extension.Nico Weber2012-02-011-3/+4
| | | | | | Fixes PR11847. Patch from Jason Haslam! llvm-svn: 149460
* Make the callback object to Sema::CorrectTypo mandatory.Kaelyn Uhrain2012-01-311-6/+6
| | | | llvm-svn: 149451
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-3/+5
| | | | llvm-svn: 149127
* Avoid redundant NNS qualification in constructor/destructor names.Abramo Bagnara2012-01-271-2/+8
| | | | llvm-svn: 149124
* Replace a hack to handle NSLog/NSLogv in sema by declaring them as Library ↵Jean-Daniel Dupas2012-01-241-12/+9
| | | | | | Builtins. llvm-svn: 148873
* Small code cleanup/simplification in Sema::ClassifyName.Kaelyn Uhrain2012-01-241-7/+7
| | | | llvm-svn: 148850
* Minor fixups for auto deduction of initializer lists.Sebastian Redl2012-01-231-1/+2
| | | | | | | | Fix some review comments. Add a test for deduction when std::initializer_list isn't available yet. Fix redundant error messages. This fixes and outstanding FIXME too. llvm-svn: 148735
* In Microsoft Mode, disable the C++11 strict integral conversion rules for ↵Francois Pichet2012-01-211-1/+2
| | | | | | enumerator that were introduced with r148439. Otherwise MSVC headers won't compile in C++ 11 mode. llvm-svn: 148642
* Instantiate dependent attributes when instantiating templates.DeLesley Hutchins2012-01-201-0/+3
| | | | llvm-svn: 148592
* constexpr: converted constant expression handling for enumerator values, caseRichard Smith2012-01-181-18/+28
| | | | | | | | | | values and non-type template arguments of integral and enumeration types. This change causes some legal C++98 code to no longer compile in C++11 mode, by enforcing the C++11 rule that narrowing integral conversions are not permitted in the final implicit conversion sequence for the above cases. llvm-svn: 148439
* Convert SemaDecl.cpp to pass callback objects to CorrectTypo.Kaelyn Uhrain2012-01-181-47/+82
| | | | | | | | | | | | Includes tests highlighting the cases where accuracy has improved (there is one call that does no filtering beyond selecting the set of allowed keywords, and one call that only triggers for ObjC code for which a test by someone who knows ObjC would be welcome). Also fixes a small typo in one of the suggestion messages, and drops a malformed "expected-note" for a suggestion that did not occur even when the malformed note was committed as r145930. llvm-svn: 148420
* Auto deduction support for std::initializer_list, including for-range ↵Sebastian Redl2012-01-171-3/+1
| | | | | | | | support. This means you can now write: for (int i : {1, 4, 512, 23, 251}) {} llvm-svn: 148353
* objc: fixes a bug where struct used inside anFariborz Jahanian2012-01-171-1/+2
| | | | | | | | objc class was not being exported to parent decl context resulting in bogus mismatch warning later on. // rdar://10655530 llvm-svn: 148320
* Remove unnecessary default cases in switches over enums.David Blaikie2012-01-171-1/+0
| | | | | | This allows -Wswitch-enum to find switches that need updating when these enums are modified. llvm-svn: 148281
* De-virtualize getPreviousDecl() and getMostRecentDecl() when we knowDouglas Gregor2012-01-141-6/+6
| | | | | | | | | | | | we have a redeclarable type, and only use the new virtual versions (getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have that type information. This keeps us from penalizing users with strict type information (and is the moral equivalent of a "final" method). Plus, settle on the names getPreviousDecl() and getMostRecentDecl() throughout. llvm-svn: 148187
* Progress towards making isUsed() reflect whether a declaration is odr-used; ↵Eli Friedman2012-01-131-2/+2
| | | | | | | | don't set isUsed for local variables which are referenced in unevaluated contexts. Make other code use isReferenced() (which basically indicates that a declaration isn't dead) where appropriate. I was forced to change test/SemaCXX/linkage.cpp because we aren't actually modeling extern "C" in the AST the way that testcase expects; we were not printing a warning only because we skipped the relevant check. Someone who actually understands the semantics here should fix that. llvm-svn: 148158
* Don't crash while trying to diagnose a function declared at block scope with anRichard Smith2012-01-131-1/+2
| | | | | | incomplete return type. llvm-svn: 148088
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-2/+33
| | | | | | | | | | | | | | | | | | | | | | | - If the declarator is at the start of a line, and the previous line contained another declarator and ended with a comma, then that comma was probably a typo for a semicolon: int n = 0, m = 1, l = 2, // k = 5; myImportantFunctionCall(); // oops! - If removing the parentheses would correctly initialize the object, then produce a note suggesting that fix. - Otherwise, if there is a simple initializer we can suggest which performs value-initialization, then provide a note suggesting a correction to that initializer. Sema::Declarator now tracks the location of the comma prior to the declarator in the declaration, if there is one, to facilitate providing the note. The code to determine an appropriate initializer from the -Wuninitialized warning has been factored out to allow use in both that and -Wvexing-parse. llvm-svn: 148072
* objective-c: fixes a regression in looking up namesFariborz Jahanian2012-01-121-2/+5
| | | | | | | in class extensions and categories by recent refactoring of objc class ASTs. // rdar://1066654 llvm-svn: 147982
* Improve the diagnostic when trying to redefine a typedef with aDouglas Gregor2012-01-111-1/+12
| | | | | | variably-modified type. llvm-svn: 147973
* C11 allows typedefs to be redefined. Implement this in C11 mode, andDouglas Gregor2012-01-111-4/+2
| | | | | | | downgrade the default-error warning to an ExtWarn in C90/99. <rdar://problem/10668057> llvm-svn: 147925
* Update C++11 scoped enumeration support to match the final proposal:Richard Smith2012-01-101-1/+13
| | | | | | | | - reject definitions of enums within friend declarations - require 'enum', not 'enum class', for non-declaring references to scoped enumerations llvm-svn: 147824
OpenPOWER on IntegriCloud