From: Jakub Jelinek Date: Fri, 30 Aug 2019 11:14:56 +0000 (+0200) Subject: backport: re PR c++/88181 (ICE: verify_type failed (error: type variant differs by... X-Git-Tag: releases/gcc-7.5.0~290 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17981e7baab8a2c754599b1643dc0d6b8de9dbb9;p=thirdparty%2Fgcc.git backport: re PR c++/88181 (ICE: verify_type failed (error: type variant differs by TYPE_PACKED)) Backported from mainline 2018-11-27 Jakub Jelinek PR c++/88181 * class.c (fixup_attribute_variants): Also propagate TYPE_PACKED to variants. * g++.dg/debug/pr88181.C: New test. From-SVN: r275071 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f9d983655179..881df4a89a69 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2019-08-30 Jakub Jelinek + + Backported from mainline + 2018-11-27 Jakub Jelinek + + PR c++/88181 + * class.c (fixup_attribute_variants): Also propagate TYPE_PACKED + to variants. + 2019-04-10 Matthias Klose Backport from the gcc-8 branch diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 688cc0e58d33..dbfea0ab653e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2088,6 +2088,7 @@ fixup_attribute_variants (tree t) unsigned align = TYPE_ALIGN (t); bool user_align = TYPE_USER_ALIGN (t); bool may_alias = lookup_attribute ("may_alias", attrs); + bool packed = TYPE_PACKED (t); if (may_alias) fixup_may_alias (t); @@ -2105,6 +2106,7 @@ fixup_attribute_variants (tree t) else TYPE_USER_ALIGN (variants) = user_align; SET_TYPE_ALIGN (variants, valign); + TYPE_PACKED (variants) = packed; if (may_alias) fixup_may_alias (variants); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 30c2257164f7..c90a43cd1c62 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2019-08-30 Jakub Jelinek Backported from mainline + 2018-11-27 Jakub Jelinek + + PR c++/88181 + * g++.dg/debug/pr88181.C: New test. + 2018-11-20 Jakub Jelinek PR tree-optimization/87895 diff --git a/gcc/testsuite/g++.dg/debug/pr88181.C b/gcc/testsuite/g++.dg/debug/pr88181.C new file mode 100644 index 000000000000..fc6f8136b615 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr88181.C @@ -0,0 +1,29 @@ +// PR c++/88181 +// { dg-do compile } +// { dg-options "-fpack-struct -g -std=c++11" } + +template struct A { typedef T B; }; +template class C; +template struct D { constexpr D (e) {} }; +template struct E; +template +struct E : E<1, U...>, D { + constexpr E (T x, U... y) : E<1, U...>(y...), D(x) {} +}; +template struct E : D { + constexpr E (T x) : D(x) {} +}; +template struct C : E<0, T, U> { + constexpr C (T x, U y) : E<0, T, U>(x, y) {} + void operator= (typename A::B); +}; +struct F {}; +struct G {}; + +int +main () +{ + F f; + G g; + constexpr C c(f, g); +}