summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Implement the new C++0x rules for non-trivial things in unions so thatAlexis Hunt2011-05-161-3/+7
| | | | | | my defaulted constructor tests stop yelling at me about them. llvm-svn: 131432
* Revert 131347. It asserts if the specialization in within a class template:Francois Pichet2011-05-141-7/+3
| | | | | | | | | | | | template<class U> struct X1 { template<class T> void f(T*); template<> void f(int*) { } }; Won't be so simple. I need to think more about it. llvm-svn: 131362
* In Microsoft mode, allow template function explicit specialization at class ↵Francois Pichet2011-05-141-2/+6
| | | | | | | | | | | | | | scope. Necessary to parse MFC and MSVC standard lib code. Example: struct X { template<class T> void f(T) { } template<> void f(int) { } } llvm-svn: 131347
* Properly parse the 'default' and 'delete' keywords.Alexis Hunt2011-05-121-27/+10
| | | | | | | | | | | | | | | | | They are actually grammatically considered definitions and parsed accordingly. This fixes the outstanding bugs regarding defaulting functions after their declarations. We now really nicely diagnose the following construct (try it!) int foo() = delete, bar; Still todo: Defaulted functions other than default constructors Test cases (including for the above construct) llvm-svn: 131228
* Implement deletion of explicitly defaulted default constructors.Alexis Hunt2011-05-121-31/+7
| | | | | | | We still don't parse out-of-line defaults correctly, which is needed to get the full effect out of this patch. llvm-svn: 131223
* Fix typo in comment.Nick Lewycky2011-05-121-1/+1
| | | | llvm-svn: 131212
* Commit some missing changes to the previous patch.Alexis Hunt2011-05-111-3/+15
| | | | | | This means we get C++0x jump-across-intializer semantics correct. llvm-svn: 131204
* Implement implicit deletion of default constructors.Alexis Hunt2011-05-111-1/+4
| | | | | | | | Yes, I'm aware that the diagnostics are awful. Tests to follow. llvm-svn: 131203
* In Microsoft mode, allow pure specifier (=0) on inline functions declared at ↵Francois Pichet2011-05-111-0/+5
| | | | | | | | | | | | | class scope. This removes 2 errors when parsing MFC code with clang Example: class A { virtual void f() = 0 { } } llvm-svn: 131175
* Re-do R131114 without breaking code.Alexis Hunt2011-05-101-7/+10
| | | | | | | | | I've edited one diagnostic which would print "copy constructor" for copy constructors and "constructor" for any other constructor. If anyone is extremely enamored with this, it can be reinstated with a simple boolean flag rather than calling getSpecialMember, which is inappropriate. llvm-svn: 131143
* Reimplement Sema::MatchTemplateParametersToScopeSpecifier() based onDouglas Gregor2011-05-101-3/+4
| | | | | | | | | | | | | | | | | | the semantic context referenced by the nested-name-specifier rather than the syntactic form of the nested-name-specifier. The previous incarnation was based on my complete misunderstanding of C++ [temp.expl.spec]. The latest C++0x working draft clarifies the requirements here, and this rewrite is intended to follow that. Along the way, improve source location information in the diagnostics. For example, if we report that a specific type needs or doesn't need a 'template<>' header, we dig out that type in the nested-name-specifier and highlight its range. Fixes: PR5907, PR9421, PR8277, PR8708, PR9482, PR9668, PR9877, and <rdar://problem/9135379>. llvm-svn: 131138
* Revert 131114. This fixes PR9884.Rafael Espindola2011-05-101-10/+7
| | | | llvm-svn: 131126
* Further implement defaulting constructors.Alexis Hunt2011-05-101-29/+36
| | | | | | | | | | | | | Focus is on default constructors for the time being. Currently the exception specification and prototype are processed correctly. Codegen might work but in all likelihood doesn't. Note that due to an error, out-of-line defaulting of member functions is currently impossible. It will continue to that until I muster up the courage to admit that I secretly pray to epimetheus and that I need to rework the way default gets from Parse -> Sema. llvm-svn: 131115
* The last of the trivial constructor changes, make CXXSpecialMemberAlexis Hunt2011-05-101-7/+10
| | | | | | reflect our new, more accurate AST. llvm-svn: 131114
* Ignore const/volatile/restrict qualifiers on anonymous structs andDouglas Gregor2011-05-091-0/+18
| | | | | | unions. Fixes PR8326. llvm-svn: 131109
* Extend the tag-ambiguity hack I committed in r130810 for tagDouglas Gregor2011-05-091-4/+2
| | | | | | definitions to also include tag declarations. Fixes PR8151. llvm-svn: 131102
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-091-2/+2
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* Per Richard's suggestion, rename DefLoc to DefaultLoc where it appears.Alexis Hunt2011-05-061-16/+17
| | | | llvm-svn: 131018
* Modify some deleted function methods to better reflect reality:Alexis Hunt2011-05-061-9/+4
| | | | | | | | | | | | | | | | | | | | - New isDefined() function checks for deletedness - isThisDeclarationADefinition checks for deletedness - New doesThisDeclarationHaveABody() does what isThisDeclarationADefinition() used to do - The IsDeleted bit is not propagated across redeclarations - isDeleted() now checks the canoncial declaration - New isDeletedAsWritten() does what it says on the tin. - isUserProvided() now correct (thanks Richard!) This fixes the bug that we weren't catching void foo() = delete; void foo() {} as being a redefinition. llvm-svn: 131013
* Do defaulted constructors properly.Alexis Hunt2011-05-061-10/+53
| | | | | | | | Explictly defaultedness is correctly reflected on the AST, but there are no changes to how that affects the definition of functions or much else really. llvm-svn: 130974
* Revert r130912 in order to approach defaulted functions from the otherAlexis Hunt2011-05-061-2/+1
| | | | | | | direction and not introduce things in the wrong place three different times. llvm-svn: 130968
* Implement support for C++0x alias templates.Richard Smith2011-05-051-16/+25
| | | | llvm-svn: 130953
* Implement some framework for defaulted constructors.Alexis Hunt2011-05-051-1/+2
| | | | | | There's some unused stuff for now. llvm-svn: 130912
* When tag lookup finds something ambiguous, and we're defining a newDouglas Gregor2011-05-041-0/+13
| | | | | | | | | | | | | tag, filter out those ambiguous names that we found if they aren't within the declaration context where this newly-defined tag will be visible. This is basically a hack, because we really need to fix the lookup of tag declarations in this case to not find things it shouldn't. However, it's better than what we had before, and it fixes <rdar://problem/9168556>. llvm-svn: 130810
* When parsing a template friend declaration we dropped the templateChandler Carruth2011-05-031-1/+11
| | | | | | | | | | | | | | | | | | | | parameters on the floor in certain cases: class X { template <typename T> friend typename A<T>::Foo; }; This was parsed as a *non* template friend declaration some how, and received an ExtWarn. Fixing the parser to actually provide the template parameters to the freestanding declaration parse triggers the code which specifically looks for such constructs and hard errors on them. Along the way, this prevents us from trying to instantiate constructs like the above inside of a outer template. This is important as loosing the template parameters means we don't have a well formed declaration and template instantiation will be unable to rebuild the AST. That fixes a crash in the GCC test suite. llvm-svn: 130772
* Store a parameter index and function prototype depth in everyJohn McCall2011-05-011-6/+17
| | | | | | | | | | parameter node and use this to correctly mangle parameter references in function template signatures. A follow-up patch will improve the storage usage of these fields; here I've just done the lazy thing. llvm-svn: 130669
* Extend Sema::ClassifyName() to support C++, ironing out a few issuesDouglas Gregor2011-04-271-33/+41
| | | | | | | | | in the classification of template names and using declarations. We now properly typo-correct the leading identifiers in statements to types, templates, values, etc. As an added bonus, this reduces the number of lookups required for disambiguation. llvm-svn: 130288
* Improve diagnostics for typo correction via Sema::ClassifyName(), byDouglas Gregor2011-04-271-3/+19
| | | | | | | | looking at the context and the correction and using a custom diagnostic. Also, enable some Fix-It tests that were somewhat lamely disabled. llvm-svn: 130283
* Add ms_struct attribute on record typeeFariborz Jahanian2011-04-261-0/+2
| | | | | | (and ignore it for now) - wip. llvm-svn: 130224
* 'extern' variables in functions don't shadow externs in global scope. Fixes ↵Argyrios Kyrtzidis2011-04-251-14/+4
| | | | | | rdar://8883302, this time for C++ as well. llvm-svn: 130157
* When Sema::ClassifyName() finds an invalid ivar reference, return anDouglas Gregor2011-04-251-11/+3
| | | | | | | invalid expression rather than the far-more-generic "error". Fixes a mild regression in error recovery uncovered by the GCC testsuite. llvm-svn: 130128
* Implement a new identifier-classification scheme where SemaDouglas Gregor2011-04-241-0/+306
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | performs name lookup for an identifier and resolves it to a type/expression/template/etc. in the same step. This scheme is intended to improve both performance (by reducing the number of redundant name lookups for a given identifier token) and error recovery (by giving Sema a chance to correct type names before the parser has decided that the identifier isn't a type name). For example, this allows us to properly typo-correct type names at the beginning of a statement: t.c:6:3: error: use of undeclared identifier 'integer'; did you mean 'Integer'? integer *i = 0; ^~~~~~~ Integer t.c:1:13: note: 'Integer' declared here typedef int Integer; ^ Previously, we wouldn't give a Fix-It because the typo correction occurred after the parser had checked whether "integer" was a type name (via Sema::getTypeName(), which isn't allowed to typo-correct) and therefore decided to parse "integer * i = 0" as an expression. By typo-correcting earlier, we typo-correct to the type name Integer and parse this as a declaration. Moreover, in this context, we can also typo-correct identifiers to keywords, e.g., t.c:7:3: error: use of undeclared identifier 'vid'; did you mean 'void'? vid *p = i; ^~~ void and recover appropriately. Note that this is very much a work-in-progress. The new Sema::ClassifyName is only used for expression-or-declaration disambiguation in C at the statement level. The next steps will be to make this work for the same disambiguation in C++ (where functional-style casts make some trouble), then push it further into the parser to eliminate more redundant name lookups. Fixes <rdar://problem/7963833> for C and starts us down the path of <rdar://problem/8172000>. llvm-svn: 130082
* Correctly emit a diagnostic for multiple templated function definitions in ↵Francois Pichet2011-04-221-18/+18
| | | | | | -flate-template-parsing mode. llvm-svn: 130030
* Add -fdelayed-template-parsing option. Using this option all templated ↵Francois Pichet2011-04-221-1/+6
| | | | | | | | | function definitions are parsed at the end of the translation unit only if it is required by an actual instantiation. As such all the symbols of the TU are available during name lookup. Using this flag is necessary for compatibility with Microsoft template code. This also provides some parsing speed improvement. llvm-svn: 130022
* Do not return true from MergeFunctionDecl for a warn_static_non_static ↵Francois Pichet2011-04-221-6/+8
| | | | | | warning in Microsoft mode. llvm-svn: 130010
* I concur with DPG here. This does indeed apply in 0x mode. Added testChandler Carruth2011-04-221-2/+1
| | | | | | | | | cases that demonstrates exactly why this does indeed apply in 0x mode. If isPOD is currently broken in 0x mode, we should fix that directly rather than papering over it here. llvm-svn: 130007
* For consistency, change suffix from war_ to warn_ for some Microsoft ↵Francois Pichet2011-04-221-1/+1
| | | | | | warnings I introduced lately. llvm-svn: 129986
* Downgrade error "static declaration of 'foo' follows non-static declaration" ↵Francois Pichet2011-04-221-2/+4
| | | | | | to a warning in Microsoft mode. llvm-svn: 129985
* ADT/Triple: Switch to using .isOSDarwin() predicate.Daniel Dunbar2011-04-191-2/+1
| | | | llvm-svn: 129823
* Support for C++11 (non-template) alias declarations.Richard Smith2011-04-151-41/+69
| | | | llvm-svn: 129567
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+41
| | | | | | draft standard (N3291). llvm-svn: 129541
* Still not used to put the * next to the variable name.Francois Pichet2011-04-131-1/+1
| | | | llvm-svn: 129426
* In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal to ↵Francois Pichet2011-04-131-1/+32
| | | | | | | | | | | | | | | | | | the type of one of the base classes then downgrade the missing typename error to a warning. Up to now this is the only case I found where MSVC doesn't require "typename" at class scope. Really strange! This fixes 1 error when parsing the MSVC 2008 header files. Example: template<class T> class A { public: typedef int TYPE; }; template<class T> class B : public A<T> { public: A<T>::TYPE a; // no typename required because A<T> is a base class. }; llvm-svn: 129425
* PR8369: make __attribute((regparm(0))) work correctly. Original patch byEli Friedman2011-04-091-2/+3
| | | | | | pageexec@freemail.hu, tweaks by me. llvm-svn: 129206
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | This patch authored by Eric Niebler. Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr pointers as in/out parameters (Expr *&). This is especially true for the routines that apply implicit conversions to nodes in-place. This design is workable only as long as those conversions cannot fail. If they are allowed to fail, they need a way to report their failures. The typical way of doing this in clang is to use an ExprResult, which has an extra bit to signal a valid/invalid state. Returning ExprResult is de riguour elsewhere in the Sema interface. We suggest changing the Expr *& parameters in the Sema interface to ExprResult &. This increases interface consistency and maintainability. This interface change is important for work supporting MS-style C++ properties. For reasons explained here <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>, seemingly trivial operations like rvalue/lvalue conversions that formerly could not fail now can. (The reason is that given the semantics of the feature, getter/setter method lookup cannot happen until the point of use, at which point it may be found that the method does not exist, or it may have the wrong type, or overload resolution may fail, or it may be inaccessible.) llvm-svn: 129143
* Fix PR 9626 (duplicated self-init warnings under -Wuninitialized) with ↵Ted Kremenek2011-04-041-1/+10
| | | | | | | | | | | | | | numerous CFG and UninitializedValues analysis changes: 1) Change the CFG to include the DeclStmt for conditional variables, instead of using the condition itself as a faux DeclStmt. 2) Update ExprEngine (the static analyzer) to understand (1), so not to regress. 3) Update UninitializedValues.cpp to initialize all tracked variables to Uninitialized at the start of the function/method. 4) Only use the SelfReferenceChecker (SemaDecl.cpp) on global variables, leaving the dataflow analysis to handle other cases. The combination of (1) and (3) allows the dataflow-based -Wuninitialized to find self-init problems when the initializer contained control-flow. llvm-svn: 128858
* Accept __declspec(dllimport) for function defined at class scope in ↵Francois Pichet2011-03-291-1/+3
| | | | | | | | Microsoft mode. This fixes a bunch of errors when compiling MSVC header files with the -DDLL flag. llvm-svn: 128457
* Diagnose uninitialized uses of a variable within its own initializer.Chandler Carruth2011-03-271-1/+44
| | | | | | | | | | | This is basically the same idea as the warning on uninitialized uses of fields within an initializer list. As such, it is on by default and under -Wuninitialized. Original patch by Richard Trieu, with some massaging from me on the wording and grouping of the diagnostics. llvm-svn: 128376
* Don't warn about the 'extern' in 'extern "C"' on a tag decl. This isJohn McCall2011-03-261-2/+7
| | | | | | usually useless, but not always. llvm-svn: 128326
* Get rid of handling of the 'explicit' keyword from class-head. We still ↵Anders Carlsson2011-03-251-5/+3
| | | | | | parse it though, although that will change shortly. llvm-svn: 128277
OpenPOWER on IntegriCloud