From: Paolo Carlini Date: Thu, 18 Jan 2018 17:11:43 +0000 (+0000) Subject: re PR c++/81013 (ICE with invalid union in class hierarchy) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=50b27938f70819e2453bcd72a80a6a4c2b9e2fcb;p=gcc.git re PR c++/81013 (ICE with invalid union in class hierarchy) /cp 2018-01-18 Paolo Carlini PR c++/81013 * decl.c (xref_basetypes): Early return upon error about derived union. /testsuite 2018-01-18 Paolo Carlini PR c++/81013 * g++.dg/inherit/union3.C: New. From-SVN: r256856 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0cacefa674d..2de9dcb06d5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-01-18 Paolo Carlini + + PR c++/81013 + * decl.c (xref_basetypes): Early return upon error about derived + union. + 2018-01-18 Nathan Sidwell PR c++/83160 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 12022a2fdd8..32ac81fc271 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f9674a9ee90..3110c486400 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-18 Paolo Carlini + + PR c++/81013 + * g++.dg/inherit/union3.C: New. + 2018-01-18 Christophe Lyon * 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 index 00000000000..c13b39768db --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/union3.C @@ -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(); +}