[cfe-commits] r142411 - in /cfe/trunk: lib/AST/DeclCXX.cpp test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp

Richard Smith richard-llvm at metafoo.co.uk
Tue Oct 18 13:08:55 PDT 2011


Author: rsmith
Date: Tue Oct 18 15:08:55 2011
New Revision: 142411

URL: http://llvm.org/viewvc/llvm-project?rev=142411&view=rev
Log:
Simplify RecordDeclCXX::setBases slightly. No functional change.

Add test that a variadic base list which expands to 0 bases doesn't make the
class a non-aggregate. This test passed before the change, too.

Modified:
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=142411&r1=142410&r2=142411&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Oct 18 15:08:55 2011
@@ -77,15 +77,20 @@
 CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
                         unsigned NumBases) {
   ASTContext &C = getASTContext();
-  
-  // C++ [dcl.init.aggr]p1:
-  //   An aggregate is an array or a class (clause 9) with [...]
-  //   no base classes [...].
-  data().Aggregate = false;
 
   if (!data().Bases.isOffset() && data().NumBases > 0)
     C.Deallocate(data().getBases());
 
+  if (NumBases) {
+    // C++ [dcl.init.aggr]p1:
+    //   An aggregate is [...] a class with [...] no base classes [...].
+    data().Aggregate = false;
+
+    // C++ [class]p4:
+    //   A POD-struct is an aggregate class...
+    data().PlainOldData = false;
+  }
+
   // The set of seen virtual base types.
   llvm::SmallPtrSet<CanQualType, 8> SeenVBaseTypes;
   
@@ -105,14 +110,6 @@
     CXXRecordDecl *BaseClassDecl
       = cast<CXXRecordDecl>(BaseType->getAs<RecordType>()->getDecl());
 
-    // C++ [dcl.init.aggr]p1:
-    //   An aggregate is [...] a class with [...] no base classes [...].
-    data().Aggregate = false;    
-    
-    // C++ [class]p4:
-    //   A POD-struct is an aggregate class...
-    data().PlainOldData = false;
-    
     // A class with a non-empty base class is not empty.
     // FIXME: Standard ref?
     if (!BaseClassDecl->isEmpty()) {

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp?rev=142411&r1=142410&r2=142411&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp Tue Oct 18 15:08:55 2011
@@ -53,6 +53,10 @@
 struct NonAggr5 : Aggr {
 };
 NonAggr5 na5 = { b }; // expected-error {{non-aggregate type 'NonAggr5'}}
+template<typename...BaseList>
+struct MaybeAggr5a : BaseList... {};
+MaybeAggr5a<> ma5a0 = {}; // ok
+MaybeAggr5a<Aggr> ma5a1 = {}; // expected-error {{non-aggregate type 'MaybeAggr5a<Aggr>'}}
 
 // and no virtual functions.
 struct NonAggr6 {





More information about the cfe-commits mailing list