From dc2af9e31ccc511234f54e020afe88f52839793d Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 27 Nov 2018 21:04:41 +0000 Subject: [PATCH] PR c++/88181 * class.c (fixup_attribute_variants): Also propagate TYPE_PACKED to variants. * g++.dg/debug/pr88181.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266527 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 8e157f6c25c1..41e66c082974 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 0b50f6715788..be3b4bbbe19e 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 0e211c98e547..d35a3f87cd1b 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 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); +} -- 2.47.2