Author: rsmith
Date: Thu Jun 14 13:03:22 2018
New Revision: 334763

URL: http://llvm.org/viewvc/llvm-project?rev=334763&view=rev
Log:
[c++17] If a class inherits virtual functions from a base class, it is
not an aggregtae.

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

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=334763&r1=334762&r2=334763&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Jun 14 13:03:22 2018
@@ -259,9 +259,13 @@ CXXRecordDecl::setBases(CXXBaseSpecifier
     // 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

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp?rev=334763&r1=334762&r2=334763&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp Thu Jun 14 
13:03:22 2018
@@ -111,6 +111,11 @@ struct NonAggr6 { // expected-note 3 {{c
 };
 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;
 


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to