From d15a79696738d4f81b17774af7f7d7a80f429d5c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 27 Nov 2018 22:04:41 +0100 Subject: [PATCH] re PR c++/88181 (ICE: verify_type failed (error: type variant differs by TYPE_PACKED)) PR c++/88181 * class.c (fixup_attribute_variants): Also propagate TYPE_PACKED to variants. * g++.dg/debug/pr88181.C: New test. From-SVN: r266527 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/class.c | 2 ++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/debug/pr88181.C | 29 ++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 gcc/testsuite/g++.dg/debug/pr88181.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8e157f6c25c..41e66c08297 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-11-27 Jakub Jelinek + + PR c++/88181 + * class.c (fixup_attribute_variants): Also propagate TYPE_PACKED + to variants. + 2018-11-26 Marek Polacek PR c++/88120 - ICE when calling save_expr in a template. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0b50f671578..be3b4bbbe19 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1951,6 +1951,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); @@ -1968,6 +1969,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 0e211c98e54..d35a3f87cd1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-11-27 Jakub Jelinek + PR c++/88181 + * g++.dg/debug/pr88181.C: New test. + PR middle-end/87157 * gcc.dg/vect/costmodel/ppc/costmodel-vect-33.c (main1): Add noipa attribute. diff --git a/gcc/testsuite/g++.dg/debug/pr88181.C b/gcc/testsuite/g++.dg/debug/pr88181.C new file mode 100644 index 00000000000..fc6f8136b61 --- /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); +} -- 2.30.2