summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Parse the location of the 'namespace' token to ActOnNamespaceAliasDef. No ↵Anders Carlsson2009-03-281-5/+5
| | | | | | functionality change. llvm-svn: 67961
* Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for aChris Lattner2009-03-281-92/+91
| | | | | | | | | | | | | | | | | | | | 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
* As Eli pointed out, it is possible that a namespace lookup is ambiguous!Anders Carlsson2009-03-281-2/+0
| | | | llvm-svn: 67932
* Check that the alias points to a valid namespace.Anders Carlsson2009-03-281-0/+15
| | | | llvm-svn: 67925
* Check that the namespace alias doesn't conflict with a previous declaration ↵Anders Carlsson2009-03-281-1/+13
| | | | | | in this scope. llvm-svn: 67921
* Add an ActOnNamespaceAliasDef action and have the parser call it.Anders Carlsson2009-03-281-0/+9
| | | | llvm-svn: 67915
* Revert Sebastian's rvalue patch (r67870) since it caused test failures inAnders Carlsson2009-03-281-38/+22
| | | | | | | | SemaCXX//overload-member-call.cpp SemaCXX//overloaded-operator.cpp SemaTemplate//instantiate-method.cpp llvm-svn: 67912
* Better overload resolution for rvalue references.Sebastian Redl2009-03-271-22/+38
| | | | llvm-svn: 67870
* Move Sema::SetMemberAccessSpecifier to SemaAccess.cppAnders Carlsson2009-03-271-25/+0
| | | | llvm-svn: 67820
* Improve recovery when a constructor fails to type-check. Test case from AndersDouglas Gregor2009-03-271-6/+8
| | | | llvm-svn: 67818
* Revamp our representation of C++ nested-name-specifiers. We now have aDouglas Gregor2009-03-261-3/+10
| | | | | | | | | | | uniqued representation that should both save some memory and make it far easier to properly build canonical types for types involving dependent nested-name-specifiers, e.g., "typename T::Nested::type". This approach will greatly simplify the representation of CXXScopeSpec. That'll be next. llvm-svn: 67799
* AddAnders Carlsson2009-03-261-17/+2
| | | | | | | | | const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, AccessSpecifier AS); so we can easily add access specifiers to diagnostics. llvm-svn: 67795
* Factor the member access specifier setting code into its own function. No ↵Anders Carlsson2009-03-261-0/+40
| | | | | | intended functionality change. llvm-svn: 67725
* Improve handling of base initializers. We now parse initializers in out of ↵Anders Carlsson2009-03-251-0/+12
| | | | | | | | | | | | | | | | | | | | | | line decls, such as: class C { C() { } int a; }; C::C() : a(10) { } We also diagnose when initializers are used on declarations that aren't constructors: t.cpp:1:10: error: only constructors take base initializers void f() : a(10) { } ^ Doug and/or Sebastian: I'd appreciate a review, especially the nested-name-spec test results (from the looks of it we now match gcc in that test.) llvm-svn: 67672
* Parse deleted function definitions and hook them up to Doug's machinery.Sebastian Redl2009-03-241-0/+16
| | | | llvm-svn: 67653
* Fix the bug that Eli noticed where we wouldn't look at function decls ↵Anders Carlsson2009-03-241-21/+45
| | | | | | outside the class declaration. llvm-svn: 67627
* Template instantiation for constructorsDouglas Gregor2009-03-241-0/+9
| | | | llvm-svn: 67623
* Handle pointers to arrays of abstract types.Anders Carlsson2009-03-241-0/+9
| | | | llvm-svn: 67598
* More work on diagnosing abstract classes. We can now handle cases likeAnders Carlsson2009-03-241-1/+48
| | | | | | | | | | | | class C { void g(C c); virtual void f() = 0; }; In this case, C is not known to be abstract when doing semantic analysis on g. This is done by recursively traversing the abstract class and checking the types of member functions. llvm-svn: 67594
* More improvements to abstract type checking. Handle arrays correctly, and ↵Anders Carlsson2009-03-231-0/+3
| | | | | | make sure to check parameter types before they decay. llvm-svn: 67550
* It's an error to try to allocate an abstract object using new.Anders Carlsson2009-03-231-2/+2
| | | | llvm-svn: 67542
* Disallow catching exceptions by rvalue reference.Sebastian Redl2009-03-221-3/+7
| | | | llvm-svn: 67492
* Fix build from r67476 and address the easy part of Doug's comments on rvalue ↵Sebastian Redl2009-03-221-5/+4
| | | | | | refs. llvm-svn: 67480
* Disallow abstract types where appropriate.Anders Carlsson2009-03-221-1/+45
| | | | llvm-svn: 67476
* Keep track of whether a class is abstract or not. This is currently only ↵Anders Carlsson2009-03-221-1/+81
| | | | | | used for the __is_abstract type trait. llvm-svn: 67461
* Introduce a representation for types that we referred to via aDouglas Gregor2009-03-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qualified name, e.g., foo::x so that we retain the nested-name-specifier as written in the source code and can reproduce that qualified name when printing the types back (e.g., in diagnostics). This is PR3493, which won't be complete until finished the other tasks mentioned near the end of this commit. The parser's representation of nested-name-specifiers, CXXScopeSpec, is now a bit fatter, because it needs to contain the scopes that precede each '::' and keep track of whether the global scoping operator '::' was at the beginning. For example, we need to keep track of the leading '::', 'foo', and 'bar' in ::foo::bar::x The Action's CXXScopeTy * is no longer a DeclContext *. It's now the opaque version of the new NestedNameSpecifier, which contains a single component of a nested-name-specifier (either a DeclContext * or a Type *, bitmangled). The new sugar type QualifiedNameType composes a sequence of NestedNameSpecifiers with a representation of the type we're actually referring to. At present, we only build QualifiedNameType nodes within Sema::getTypeName. This will be extended to other type-constructing actions (e.g., ActOnClassTemplateId). Also on the way: QualifiedDeclRefExprs will also store a sequence of NestedNameSpecifiers, so that we can print out the property nested-name-specifier. I expect to also use this for handling dependent names like Fibonacci<I - 1>::value. llvm-svn: 67265
* The scope representation can now be either a DeclContext pointer or aDouglas Gregor2009-03-181-1/+1
| | | | | | | | | | Type pointer. This allows our nested-name-specifiers to retain more information about the actual spelling (e.g., which typedef did the user name, or what exact template arguments were used in the template-id?). It will also allow us to have dependent nested-name-specifiers that don't map to any DeclContext. llvm-svn: 67140
* Almost complete implementation of rvalue references. One bug, and a few ↵Sebastian Redl2009-03-161-8/+23
| | | | | | unclear areas. Maybe Doug can shed some light on some of the fixmes. llvm-svn: 67059
* Handle static_asserts when instantiating structs.Anders Carlsson2009-03-151-3/+3
| | | | llvm-svn: 67031
* Convert a bunch of actions to smart pointers, and also bring ↵Sebastian Redl2009-03-151-11/+12
| | | | | | PrintParserCallbacks a bit more in line with reality. llvm-svn: 67029
* Make sure to release the expressions.Anders Carlsson2009-03-151-0/+2
| | | | llvm-svn: 67027
* Handle dependent types/exprs in static_assert expressions.Anders Carlsson2009-03-141-11/+14
| | | | llvm-svn: 66997
* More static_assert work. Check that the assert expr is valid and show an ↵Anders Carlsson2009-03-141-0/+27
| | | | | | error if it's false. Create the declaration and add it to the current context. llvm-svn: 66995
* Refactor the way we handle operator overloading and templateDouglas Gregor2009-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | instantiation for binary operators. This change moves most of the operator-overloading code from the parser action ActOnBinOp to a new, parser-independent semantic checking routine CreateOverloadedBinOp. Of particular importance is the fact that CreateOverloadedBinOp does *not* perform any name lookup based on the current parsing context (it doesn't take a Scope*), since it has to be usable during template instantiation, when there is no scope information. Rather, it takes a pre-computed set of functions that are visible from the context or via argument-dependent lookup, and adds to that set any member operators and built-in operator candidates. The set of functions is computed in the parser action ActOnBinOp based on the current context (both operator name lookup and argument-dependent lookup). Within a template, the set computed by ActOnBinOp is saved within the type-dependent AST node and is augmented with the results of argument-dependent name lookup at instantiation time (see TemplateExprInstantiator::VisitCXXOperatorCallExpr). Sadly, we can't fully test this yet. I'll follow up with template instantiation for sizeof so that the real fun can begin. llvm-svn: 66923
* Move most of the checking from ActOnCXXMemberDeclarator to other, more ↵Douglas Gregor2009-03-111-66/+2
| | | | | | general routines. This is a step toward separating the checking logic from Declarators, which in turn is required for template instantiation. llvm-svn: 66734
* Make sure that we set the access specifier for an instantiated FieldDecl, ↵Douglas Gregor2009-03-111-13/+4
| | | | | | and that the aggregate and POD flags for an instantiated class template are updated based on instantiation of a FieldDecl llvm-svn: 66701
* Eliminate CXXClassMemberWrapperDouglas Gregor2009-03-111-4/+1
| | | | llvm-svn: 66698
* Eliminate CXXClassVarDecl. It doesn't add anythingDouglas Gregor2009-03-111-2/+2
| | | | llvm-svn: 66696
* Implement basic template instantiation for fields. Reshuffle checkingDouglas Gregor2009-03-111-1/+2
| | | | | | | for FieldDecls so that the parser and the template instantiation make use of the same semantic checking module. llvm-svn: 66685
* Limit the template instantiation depth to some user-configurable valueDouglas Gregor2009-03-101-1/+1
| | | | | | | | | | | | | | | | (default: 99). Beyond this limit, produce an error and consider the current template instantiation a failure. The stack we're building to track the instantiations will, eventually, be used to produce instantiation backtraces from diagnostics within template instantiation. However, we're not quite there yet. This adds a new Clang driver option -ftemplate-depth=NNN, which should eventually be generated from the GCC command-line operation -ftemplate-depth-NNN (note the '-' rather than the '='!). I did not make the driver changes to do this mapping. llvm-svn: 66513
* Implement template instantiation for ClassTemplateSpecializationTypes,Douglas Gregor2009-03-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | such as replacing 'T' in vector<T>. There are a few aspects to this: - Extend TemplateArgument to allow arbitrary expressions (an Expr*), and switch ClassTemplateSpecializationType to store TemplateArguments rather than it's own type-or-expression representation. - ClassTemplateSpecializationType can now store dependent types. In that case, the canonical type is another ClassTemplateSpecializationType (with default template arguments expanded) rather than a declaration (we don't build Decls for dependent types). - Split ActOnClassTemplateId into ActOnClassTemplateId (called from the parser) and CheckClassTemplateId (called from ActOnClassTemplateId and InstantiateType). They're smart enough to handle dependent types, now. llvm-svn: 66509
* Rename DiagnoseIncompleteType to RequireCompleteType, and update the ↵Douglas Gregor2009-03-091-2/+2
| | | | | | documentation to reflect the fact that we can instantiate templates here llvm-svn: 66421
* more minor simplifications.Chris Lattner2009-03-051-7/+6
| | | | llvm-svn: 66214
* refactor C++ bitfield checking a bit (haha)Chris Lattner2009-03-051-55/+31
| | | | llvm-svn: 66213
* fix PR3607 and a fixme, by checking bitfield constraintsChris Lattner2009-03-051-4/+8
| | | | | | more consistently. llvm-svn: 66210
* Implement the basics of implicit instantiation of class templates, inDouglas Gregor2009-03-031-44/+91
| | | | | | | | | | | | | | | | | | | | response to attempts to diagnose an "incomplete" type. This will force us to use DiagnoseIncompleteType more regularly (rather than looking at isIncompleteType), but that's also a good thing. Implicit instantiation is still very simplistic, and will create a new definition for the class template specialization (as it should) but it only actually instantiates the base classes and attaches those. Actually instantiating class members will follow. Also, instantiate the types of non-type template parameters before checking them, allowing, e.g., template<typename T, T Value> struct Constant; to work properly. llvm-svn: 65924
* Create a new TypeNodes.def file that enumerates all of the types,Douglas Gregor2009-02-261-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | giving them rough classifications (normal types, never-canonical types, always-dependent types, abstract type representations) and making it far easier to make sure that we've hit all of the cases when decoding types. Switched some switch() statements on the type class over to using this mechanism, and filtering out those things we don't care about. For example, CodeGen should never see always-dependent or non-canonical types, while debug info generation should never see always-dependent types. More switch() statements on the type class need to be moved over to using this approach, so that we'll get warnings when we add a new type then fail to account for it somewhere in the compiler. As part of this, some types have been renamed: TypeOfExpr -> TypeOfExprType FunctionTypeProto -> FunctionProtoType FunctionTypeNoProto -> FunctionNoProtoType There shouldn't be any functionality change... llvm-svn: 65591
* Downgrade complaints about calling unavailable functions to a warningDouglas Gregor2009-02-181-2/+20
| | | | | | | | | | | | | | | | | | (as GCC does), except when we've performed overload resolution and found an unavailable function: in this case, we actually error. Merge the checking of unavailable functions with the checking for deprecated functions. This unifies a bit of code, and makes sure that we're checking for unavailable functions in the right places. Also, this check can cause an error. We may, eventually, want an option to make "unavailable" warnings into errors. Implement much of the logic needed for C++0x deleted functions, which are effectively the same as "unavailable" functions (but always cause an error when referenced). However, we don't have the syntax to specify deleted functions yet :) llvm-svn: 64955
* remove "; candidates are/is:" from various ambiguity diagnostics.Chris Lattner2009-02-171-2/+2
| | | | | | 2 out of 2 people on irc prefer them gone :) llvm-svn: 64749
* Adopt a more principled approach to invalid declarations:Douglas Gregor2009-02-161-4/+7
| | | | | | | | | | | | | | | | | | | | | | | - If a declaration is an invalid redeclaration of an existing name, complain about the invalid redeclaration then avoid adding it to the AST (we can still parse the definition or initializer, if any). - If the declaration is invalid but there is no prior declaration with that name, introduce the invalid declaration into the AST (for later error recovery). - If the declaration is an invalid redeclaration of a builtin that starts with __builtin_, we produce an error and drop the redeclaration. If it is an invalid redeclaration of a library builtin (e.g., malloc, printf), warn (don't error!) and drop the redeclaration. If a user attempts to define a builtin, produce an error and (if it's a library builtin like malloc) suggest -ffreestanding. This addresses <rdar://problem/6097585> and PR2892. However, PR3588 is still going to cause some problems when builtins are redeclared without a prototype. llvm-svn: 64639
OpenPOWER on IntegriCloud