]> granicus.if.org Git - clang/commitdiff
[c++17] If a class inherits virtual functions from a base class, it is
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 14 Jun 2018 20:03:22 +0000 (20:03 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 14 Jun 2018 20:03:22 +0000 (20:03 +0000)
not an aggregtae.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334763 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp

index b3607caef642452ecaca3df7ad3a90b9591106b7..076e6376d15783b4bd23d6bd054000b0d54c4461 100644 (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
index f4f73a5af8ce6ac0f3cac20d04366f88bac937b4..e9e9ce57fa7f1e85334f4342aa496c65565fd2b5 100644 (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;