summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* First pass at friend semantics.John McCall2009-08-061-28/+24
| | | | llvm-svn: 78274
* Refactor methods on DeclSpec to take a diagnostic& parameter, and reflect thisJohn McCall2009-08-031-5/+7
| | | | | | | | elsewhere. Very slightly decouples DeclSpec users from knowing the exact diagnostics to report, and makes it easier to provide different diagnostics in some places. llvm-svn: 77990
* Rename Action::TagKind to Action::TagUseKind, which removes both a misnomerJohn McCall2009-07-311-14/+14
| | | | | | and a name collision. llvm-svn: 77658
* Implement support for out-of-line definitions of the class members of classDouglas Gregor2009-07-221-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | templates, e.g., template<typename T> struct Outer { struct Inner; }; template<typename T> struct Outer<T>::Inner { // ... }; Implementing this feature required some extensions to ActOnTag, which now takes a set of template parameter lists, and is the precursor to removing the ActOnClassTemplate function from the parser Action interface. The reason for this approach is simple: the parser cannot tell the difference between a class template definition and the definition of a member of a class template; both have template parameter lists, and semantic analysis determines what that template parameter list means. There is still some cleanup to do with ActOnTag and ActOnClassTemplate. This commit provides the basic functionality we need, however. llvm-svn: 76820
* Fix the parsing of default arguments for inline member function Eli Friedman2009-07-221-29/+34
| | | | | | | | definitions. I'm not very familiar with this code, so please review. llvm-svn: 76796
* Issue a more descriptive diagnostics when mis-declaringFariborz Jahanian2009-07-201-2/+4
| | | | | | a destructor. llvm-svn: 76436
* Pass the right brace SourceLocation from the Parser to the TagDecls.Argyrios Kyrtzidis2009-07-141-1/+1
| | | | llvm-svn: 75591
* Patch to implement template types in ctor-initializer list.Fariborz Jahanian2009-07-011-5/+16
| | | | | | Also has fix for bugzilla-4469. llvm-svn: 74631
* Patch to support optional nested-name-specifier in in ctor-initializerFariborz Jahanian2009-06-301-3/+5
| | | | | | list. llvm-svn: 74571
* Make it possible for using decls to point to operators. Fixes PR4441.Anders Carlsson2009-06-271-8/+24
| | | | llvm-svn: 74362
* Fix PR4448.Anders Carlsson2009-06-261-2/+0
| | | | llvm-svn: 74257
* Parse the C++0x decltype specifier.Anders Carlsson2009-06-241-0/+47
| | | | llvm-svn: 74086
* Parsing and AST support for using declarations, from John Thompson!Douglas Gregor2009-06-201-6/+69
| | | | llvm-svn: 73812
* Keep track of when declarations are "used" according to C andDouglas Gregor2009-06-191-1/+1
| | | | | | | | | | | | C++. This logic is required to trigger implicit instantiation of function templates and member functions of class templates, which will be implemented separately. This commit includes support for -Wunused-parameter, printing warnings for named parameters that are not used within a function/Objective-C method/block. Fixes <rdar://problem/6505209>. llvm-svn: 73797
* Diagnose the use of attributes on namespace aliases, from Anis AhmadDouglas Gregor2009-06-171-3/+11
| | | | llvm-svn: 73626
* improve localizability by not passing english phrases into Chris Lattner2009-06-141-4/+5
| | | | | | diagnostics in some cases. llvm-svn: 73314
* Add more parser support for Microsoft extensions.Eli Friedman2009-06-081-3/+2
| | | | llvm-svn: 73101
* Add real parsing for __declspec. It doesn't make much of a difference Eli Friedman2009-06-081-1/+2
| | | | | | at the moment because we ignore the result. llvm-svn: 73056
* Reject incomplete types in exception specs.Sebastian Redl2009-05-291-3/+9
| | | | llvm-svn: 72580
* If a declarator group declares a type, make sure to add that declaration Eli Friedman2009-05-291-1/+1
| | | | | | to the DeclGroup. llvm-svn: 72559
* When we parse a tag specifier, keep track of whether that tagDouglas Gregor2009-05-281-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | specifier resulted in the creation of a new TagDecl node, which happens either when the tag specifier was a definition or when the tag specifier was the first declaration of that tag type. This information has several uses, the first of which is implemented in this commit: 1) In C++, one is not allowed to define tag types within a type specifier (e.g., static_cast<struct S { int x; } *>(0) is ill-formed) or within the result or parameter types of a function. We now diagnose this. 2) We can extend DeclGroups to contain information about any tags that are declared/defined within the declaration specifiers of a variable, e.g., struct Point { int x, y, z; } p; This will help improve AST printing and template instantiation, among other things. 3) For C99, we can keep track of whether a tag type is defined within the type of a parameter, to properly cope with cases like, e.g., int bar(struct T2 { int x; } y) { struct T2 z; } We can also do similar things wherever there is a type specifier, e.g., to keep track of where the definition of S occurs in this legal C99 code: (struct S { int x, y; } *)0 llvm-svn: 72555
* Reimplement much of the way that we track nested classes in theDouglas Gregor2009-05-271-22/+69
| | | | | | | | | | | | | parser. Rather than placing all of the delayed member function declarations and inline definitions into a single bucket corresponding to the top-level class, we instead mirror the nesting structure of the nested classes and place the delayed member functions into their appropriate place. Then, when we actually parse the delayed member function declarations, set up the scope stack the same way as it was when we originally saw the declaration, so that we can find, e.g., template parameters that are in scope. llvm-svn: 72502
* Improve name lookup for and template instantiation of declarationDouglas Gregor2009-05-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | | references. There are several smallish fixes here: - Make sure we look through template parameter scope when determining whether we're parsing a nested class (or nested class *template*). This makes sure that we delay parsing the bodies of inline member functions until after we're out of the outermost class (template) scope. - Since the bodies of member functions are always parsed "out-of-line", even when they were declared in-line, teach unqualified name lookup to look into the (semantic) parents. - Use the new InstantiateDeclRef to handle the instantiation of a reference to a declaration (in DeclRefExpr), which drastically simplifies template instantiation for DeclRefExprs. - When we're instantiating a ParmVarDecl, it must be in the current instantiation scope, so only look there. Also, remove the #if 0's and FIXME's from the dynarray example, which now compiles and executes thanks to Anders and Eli. llvm-svn: 72481
* Merge the ASTVector and ASTOwningVector templates, since they offeredDouglas Gregor2009-05-211-1/+0
| | | | | | | | redundant functionality. The result (ASTOwningVector) lives in clang/Parse/Ownership.h and is used by both the parser and semantic analysis. No intended functionality change. llvm-svn: 72214
* Use v.data() instead of &v[0] when SmallVector v might be empty.Jay Foad2009-05-211-4/+5
| | | | llvm-svn: 72210
* Implement explicit instantiations of member classes of class templates, e.g.,Douglas Gregor2009-05-141-6/+26
| | | | | | | | | | | | | | | | | | | | | | | | | template<typename T> struct X { struct Inner; }; template struct X<int>::Inner; This change is larger than it looks because it also fixes some a problem with nested-name-specifiers and tags. We weren't requiring the DeclContext associated with the scope specifier of a tag to be complete. Therefore, when looking for something like "struct X<int>::Inner", we weren't instantiating X<int>. This, naturally, uncovered a problem with member pointers, where we were requiring the left-hand side of a member pointer access expression (e.g., x->*) to be a complete type. However, this is wrong: the semantics of this expression does not require a complete type (EDG agrees). Stuart vouched for me. Blame him. llvm-svn: 71756
* Implement parsing for explicit instantiations of class templates, e.g.,Douglas Gregor2009-05-121-8/+66
| | | | | | | | | template class X<int>; This also cleans up the propagation of template information through declaration parsing, which is used to improve some diagnostics. llvm-svn: 71608
* Fix test case by always setting the type spec type, even for friend decls.Anders Carlsson2009-05-111-5/+4
| | | | llvm-svn: 71486
* Add an ActOnFriendDecl and call it for friend class decls.Anders Carlsson2009-05-111-3/+11
| | | | llvm-svn: 71482
* For friend class decls, always use TK_Reference so we'll try to look up ↵Anders Carlsson2009-05-111-1/+1
| | | | | | existing class decls first. llvm-svn: 71481
* Have the parser communicate the exception specification to the action.Sebastian Redl2009-04-291-3/+8
| | | | llvm-svn: 70389
* Implement function-try-blocks. However, there's a very subtle bug that I ↵Sebastian Redl2009-04-261-1/+3
| | | | | | can't track down. llvm-svn: 70155
* Diagnose invalid uses of tagged types with a missing tag. For example, in:Chris Lattner2009-04-121-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | struct xyz { int y; }; enum abc { ZZZ }; static xyz b; abc c; we used to produce: t2.c:4:8: error: unknown type name 'xyz' static xyz b; ^ t2.c:5:1: error: unknown type name 'abc' abc c; ^ we now produce: t2.c:4:8: error: use of tagged type 'xyz' without 'struct' tag static xyz b; ^ struct t2.c:5:1: error: use of tagged type 'abc' without 'enum' tag abc c; ^ enum GCC produces the normal: t2.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘b’ t2.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’ rdar://6783347 llvm-svn: 68914
* Parse deleted member functions. Parsing member declarations goes through a ↵Sebastian Redl2009-04-121-5/+17
| | | | | | | | | different code path that I forgot previously. Implement the rvalue reference overload dance for returning local objects. Returning a local object first tries to find a move constructor now. The error message when no move constructor is defined (or is not applicable) and the copy constructor is deleted is quite ugly, though. llvm-svn: 68902
* fix a FIXME, providing accurate source range info for DeclStmt's. The endChris Lattner2009-04-021-13/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of the range is now the ';' location. For something like this: $ cat t2.c #define bool int void f(int x, int y) { bool b = !x && y; } We used to produce: $ clang-cc t2.c -ast-dump typedef char *__builtin_va_list; void f(int x, int y) (CompoundStmt 0x2201f10 <t2.c:3:22, line:5:1> (DeclStmt 0x2201ef0 <line:2:14> <---- 0x2201a20 "int b = (BinaryOperator 0x2201ed0 <line:4:10, col:16> 'int' '&&' (UnaryOperator 0x2201e90 <col:10, col:11> 'int' prefix '!' (DeclRefExpr 0x2201c90 <col:11> 'int' ParmVar='x' 0x2201a50)) (DeclRefExpr 0x2201eb0 <col:16> 'int' ParmVar='y' 0x2201e10))") Now we produce: $ clang-cc t2.c -ast-dump typedef char *__builtin_va_list; void f(int x, int y) (CompoundStmt 0x2201f10 <t2.c:3:22, line:5:1> (DeclStmt 0x2201ef0 <line:2:14, line:4:17> <------ 0x2201a20 "int b = (BinaryOperator 0x2201ed0 <col:10, col:16> 'int' '&&' (UnaryOperator 0x2201e90 <col:10, col:11> 'int' prefix '!' (DeclRefExpr 0x2201c90 <col:11> 'int' ParmVar='x' 0x2201a50)) (DeclRefExpr 0x2201eb0 <col:16> 'int' ParmVar='y' 0x2201e10))") llvm-svn: 68288
* Make parsing a semantic analysis a little more robust following SemaDouglas Gregor2009-04-011-11/+13
| | | | | | | | | | | | | | | | failures that involve malformed types, e.g., "typename X::foo" where "foo" isn't a type, or "std::vector<void>" that doens't instantiate properly. Similarly, be a bit smarter in our handling of ambiguities that occur in Sema::getTypeName, to eliminate duplicate error messages about ambiguous name lookup. This eliminates two XFAILs in test/SemaCXX, one of which was crying out to us, trying to tell us that we were producing repeated error messages. llvm-svn: 68251
* Parsing and AST representation for dependent template names that occurDouglas Gregor2009-03-311-2/+2
| | | | | | | | | | | within nested-name-specifiers, e.g., for the "apply" in typename MetaFun::template apply<T1, T2>::type At present, we can't instantiate these nested-name-specifiers, so our testing is sketchy. llvm-svn: 68081
* Improve the representation of template names in the AST. ThisDouglas Gregor2009-03-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | representation handles the various ways in which one can name a template, including unqualified references ("vector"), qualified references ("std::vector"), and dependent template names ("MetaFun::template apply"). One immediate effect of this change is that the representation of nested-name-specifiers in type names for class template specializations (e.g., std::vector<int>) is more accurate. Rather than representing std::vector<int> as std::(vector<int>) we represent it as (std::vector)<int> which more closely follows the C++ grammar. Additionally, templates are no longer represented as declarations (DeclPtrTy) in Parse-Sema interactions. Instead, I've introduced a new OpaquePtr type (TemplateTy) that holds the representation of a TemplateName. This will simplify the handling of dependent template-names, once we get there. llvm-svn: 68074
* Push DeclGroup much farther throughout the compiler. Now the variousChris Lattner2009-03-291-30/+36
| | | | | | | | | | | | | | | | | | | | | | | | | productions (except the already broken ObjC cases like @class X,Y;) in the parser that can produce more than one Decl return a DeclGroup instead of a Decl, etc. This allows elimination of the Decl::NextDeclarator field, and exposes various clients that should look at all decls in a group, but which were only looking at one (such as the dumper, printer, etc). These have been fixed. Still TODO: 1) there are some FIXME's in the code about potentially using DeclGroup for better location info. 2) ParseObjCAtDirectives should return a DeclGroup due to @class etc. 3) I'm not sure what is going on with StmtIterator.cpp, or if it can be radically simplified now. 4) I put a truly horrible hack in ParseTemplate.cpp. I plan to bring up #3/4 on the mailing list, but don't plan to tackle #1/2 in the short term. llvm-svn: 68002
* reduce indentation with an early exit.Chris Lattner2009-03-291-25/+23
| | | | llvm-svn: 67997
* Parse the location of the 'namespace' token to ActOnNamespaceAliasDef. No ↵Anders Carlsson2009-03-281-6/+7
| | | | | | functionality change. llvm-svn: 67961
* Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for aChris Lattner2009-03-281-38/+36
| | | | | | | | | | | | | | | | | | | | pointer. Its purpose in life is to be a glorified void*, but which does not implicitly convert to void* or other OpaquePtr's with a different UID. Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>. Change the entire parser/sema interface to use DeclPtrTy instead of DeclTy*. This makes the C++ compiler enforce that these aren't convertible to other opaque types. We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc, but I don't plan to do that in the short term. The one outstanding known problem with this patch is that we lose the bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to bitmangle the success bit into the low bit of DeclPtrTy. I will rectify this with a subsequent patch. llvm-svn: 67952
* Add an ActOnNamespaceAliasDef action and have the parser call it.Anders Carlsson2009-03-281-1/+2
| | | | llvm-svn: 67915
* Parse namespace aliases.Anders Carlsson2009-03-281-4/+35
| | | | llvm-svn: 67908
* Handle parsing of templates in member declarations. Pass the AccessSpecifier ↵Anders Carlsson2009-03-261-2/+7
| | | | | | | | all the way down to ActOnClassTemplate. Doug, Sebastian: Plz review! :) llvm-svn: 67723
* Pass access specifiers through to member classes and member enums.Douglas Gregor2009-03-251-3/+4
| | | | llvm-svn: 67710
* In Parser::ParseClassSpecifier, don't conflate a NULL declaration withDouglas Gregor2009-03-251-10/+12
| | | | | | | | failure to perform a declaration. Instead, explicitly note semantic failures that occur during template parsing with a DeclResult. Fixes PR3872. llvm-svn: 67659
* Handle static_asserts when instantiating structs.Anders Carlsson2009-03-151-3/+2
| | | | llvm-svn: 67031
* Pass more sane arguments to ActOnStaticAssertDeclarationAnders Carlsson2009-03-131-9/+4
| | | | llvm-svn: 66983
* Add parser support for static_assert.Anders Carlsson2009-03-111-1/+54
| | | | llvm-svn: 66661
OpenPOWER on IntegriCloud