[c++17] If a class inherits virtual functions from a base class, it is

not an aggregtae.

llvm-svn: 334763
This commit is contained in:
Richard Smith 2018-06-14 20:03:22 +00:00
parent 0c09acd32d
commit c00e44656d
2 changed files with 10 additions and 1 deletions

View File

@ -259,9 +259,13 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
// C++ [class.virtual]p1:
// A class that declares or inherits a virtual function is called a
// polymorphic class.
if (BaseClassDecl->isPolymorphic())
if (BaseClassDecl->isPolymorphic()) {
data().Polymorphic = true;
// An aggregate is a class with [...] no virtual functions.
data().Aggregate = false;
}
// C++0x [class]p7:
// A standard-layout class is a class that: [...]
// -- has no non-standard-layout base classes

View File

@ -111,6 +111,11 @@ struct NonAggr6 { // expected-note 3 {{candidate constructor}}
};
NonAggr6 na6 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr6'}}
struct NonAggr7 : NonAggr6 { // expected-note 3 {{candidate constructor}}
int n;
};
NonAggr7 na7 = {{}, 42}; // expected-error {{no matching constructor for initialization of 'NonAggr7'}}
struct DefaultedAggr {
int n;