re PR c++/81013 (ICE with invalid union in class hierarchy)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 18 Jan 2018 17:11:43 +0000 (17:11 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 18 Jan 2018 17:11:43 +0000 (17:11 +0000)
/cp
2018-01-18  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/81013
* decl.c (xref_basetypes): Early return upon error about derived
union.

/testsuite
2018-01-18  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/81013
* g++.dg/inherit/union3.C: New.

From-SVN: r256856

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/inherit/union3.C [new file with mode: 0644]

index 0cacefa674d158b8933b6caa0686a2eedc10d509..2de9dcb06d5949a063a4413e3f3d87bd70c0731f 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-18  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/81013
+       * decl.c (xref_basetypes): Early return upon error about derived
+       union.
+
 2018-01-18  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/83160
index 12022a2fdd8b51fe236303bb029ec7255c2e21ac..32ac81fc27164c5f19882cfa54a58dddb5e10a96 100644 (file)
@@ -13801,7 +13801,10 @@ xref_basetypes (tree ref, tree base_list)
       CLASSTYPE_NON_LAYOUT_POD_P (ref) = true;
 
       if (TREE_CODE (ref) == UNION_TYPE)
-       error ("derived union %qT invalid", ref);
+       {
+         error ("derived union %qT invalid", ref);
+         return;
+       }
     }
 
   if (max_bases > 1)
index f9674a9ee90d550bc847f11ecb8173a6ffb3c441..3110c486400b7464beeeac3c9f9b192267c99981 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-18  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/81013
+       * g++.dg/inherit/union3.C: New.
+
 2018-01-18  Christophe Lyon <christophe.lyon@linaro.org>
 
        * gcc.dg/rtl/arm/stl-cond.c: Enable on arm*.
diff --git a/gcc/testsuite/g++.dg/inherit/union3.C b/gcc/testsuite/g++.dg/inherit/union3.C
new file mode 100644 (file)
index 0000000..c13b397
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/81013
+
+struct A
+{
+  virtual void foo() const;
+};
+
+union B : A  // { dg-error "derived union 'B' invalid" }
+{
+  void foo() const;
+};
+
+void bar(const B& b)
+{
+  b.foo();
+}