diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-05 16:20:31 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-05 16:20:31 +0000 |
commit | 64bffa9a6f40e5a3d5556f994f09f7bf45eecd4c (patch) | |
tree | 1dadd5d78769ad7701edc4f614b9c34e6020da5d /lib/AST/DeclCXX.cpp | |
parent | f03d7c7af2ca8555c513ba7667acffb667445ecd (diff) |
Keep track of whether a C++ class is an aggregate. Don't allow initialization of non-aggregates with initializer lists.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58757 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclCXX.cpp')
-rw-r--r-- | lib/AST/DeclCXX.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index f49b207b0c..cf59d1af36 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -50,6 +50,11 @@ void CXXRecordDecl::Destroy(ASTContext &C) { void CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases) { + // C++ [dcl.init.aggr]p1: + // An aggregate is an array or a class (clause 9) with [...] + // no base classes [...]. + Aggregate = false; + if (this->Bases) delete [] this->Bases; @@ -78,6 +83,11 @@ CXXRecordDecl::addConstructor(ASTContext &Context, // Note that we have a user-declared constructor. UserDeclaredConstructor = true; + // C++ [dcl.init.aggr]p1: + // An aggregate is an array or a class (clause 9) with no + // user-declared constructors (12.1) [...]. + Aggregate = false; + // Note when we have a user-declared copy constructor, which will // suppress the implicit declaration of a copy constructor. if (ConDecl->isCopyConstructor(Context)) @@ -154,9 +164,8 @@ CXXConstructorDecl::Create(ASTContext &C, CXXRecordDecl *RD, bool CXXConstructorDecl::isDefaultConstructor() const { // C++ [class.ctor]p5: - // - // A default constructor for a class X is a constructor of class - // X that can be called without an argument. + // A default constructor for a class X is a constructor of class + // X that can be called without an argument. return (getNumParams() == 0) || (getNumParams() > 0 && getParamDecl(0)->getDefaultArg() != 0); } @@ -165,10 +174,10 @@ bool CXXConstructorDecl::isCopyConstructor(ASTContext &Context, unsigned &TypeQuals) const { // C++ [class.copy]p2: - // A non-template constructor for class X is a copy constructor - // if its first parameter is of type X&, const X&, volatile X& or - // const volatile X&, and either there are no other parameters - // or else all other parameters have default arguments (8.3.6). + // A non-template constructor for class X is a copy constructor + // if its first parameter is of type X&, const X&, volatile X& or + // const volatile X&, and either there are no other parameters + // or else all other parameters have default arguments (8.3.6). if ((getNumParams() < 1) || (getNumParams() > 1 && getParamDecl(1)->getDefaultArg() == 0)) return false; |