C++ PATCH for c++/80073 (C++17 ICE with virtual base)

Submitted by Jason Merrill on March 17, 2017, 6:41 p.m.

Details

Message ID CADzB+2kVJQ-nkOzSbLZQ2o_HM5osXD6RLFxLmjXqPOCHV-deAg@mail.gmail.com
State New
Headers show

Commit Message

Jason Merrill March 17, 2017, 6:41 p.m.
The code for setting CLASSTYPE_NON_AGGREGATE failed to consider
indirect virtual bases.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 18b4a698996d151d87e5db2084859c83facd798f
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 17 13:14:42 2017 -0400

            PR c++/80073 - C++17 ICE with virtual base.
    
            * decl.c (xref_basetypes): Also check for indirect vbases.

Patch hide | download patch | download mbox

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 61ecf81..bf24e8b 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13812,6 +13812,9 @@  xref_basetypes (tree ref, tree base_list)
 
   if (max_vbases)
     {
+      /* An aggregate can't have virtual base classes.  */
+      CLASSTYPE_NON_AGGREGATE (ref) = true;
+
       vec_alloc (CLASSTYPE_VBASECLASSES (ref), max_vbases);
 
       if (max_dvbases)
diff --git a/gcc/testsuite/g++.dg/init/vbase2.C b/gcc/testsuite/g++.dg/init/vbase2.C
new file mode 100644
index 0000000..1711ea9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/vbase2.C
@@ -0,0 +1,8 @@ 
+// PR c++/80073
+// { dg-do compile { target c++11 } }
+
+struct A {};
+
+struct B : virtual A {};
+
+struct C : B {} c {};