From dd67723af339f94870149ee1934dd652f83ca738 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 18 Oct 2011 20:08:55 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142411 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclCXX.cpp | 23 ++++++++----------- .../dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp | 4 ++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index f3da67c4ff..576d0d5148 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -77,15 +77,20 @@ void 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 SeenVBaseTypes; @@ -105,14 +110,6 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases, CXXRecordDecl *BaseClassDecl = cast(BaseType->getAs()->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()) { diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp index b8c1e18a2e..13b02c014e 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp @@ -53,6 +53,10 @@ NonAggr4 na4 = { 42 }; // expected-error {{non-aggregate type 'NonAggr4'}} struct NonAggr5 : Aggr { }; NonAggr5 na5 = { b }; // expected-error {{non-aggregate type 'NonAggr5'}} +template +struct MaybeAggr5a : BaseList... {}; +MaybeAggr5a<> ma5a0 = {}; // ok +MaybeAggr5a ma5a1 = {}; // expected-error {{non-aggregate type 'MaybeAggr5a'}} // and no virtual functions. struct NonAggr6 { -- 2.40.0