backport: re PR c++/88181 (ICE: verify_type failed (error: type variant differs by TYPE_PACKED))

Backported from mainline
	2018-11-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/88181
	* class.c (fixup_attribute_variants): Also propagate TYPE_PACKED
	to variants.

	* g++.dg/debug/pr88181.C: New test.

From-SVN: r275071
This commit is contained in:
Jakub Jelinek 2019-08-30 13:14:56 +02:00 committed by Jakub Jelinek
parent 5ba94a17e7
commit 17981e7baa
4 changed files with 45 additions and 0 deletions

View File

@ -1,3 +1,12 @@
2019-08-30 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2018-11-27 Jakub Jelinek <jakub@redhat.com>
PR c++/88181
* class.c (fixup_attribute_variants): Also propagate TYPE_PACKED
to variants.
2019-04-10 Matthias Klose <doko@ubuntu.com>
Backport from the gcc-8 branch

View File

@ -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);
}

View File

@ -1,6 +1,11 @@
2019-08-30 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2018-11-27 Jakub Jelinek <jakub@redhat.com>
PR c++/88181
* g++.dg/debug/pr88181.C: New test.
2018-11-20 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/87895

View File

@ -0,0 +1,29 @@
// PR c++/88181
// { dg-do compile }
// { dg-options "-fpack-struct -g -std=c++11" }
template <typename T> struct A { typedef T B; };
template <typename...> class C;
template <typename e> struct D { constexpr D (e) {} };
template <int, typename...> struct E;
template <int N, typename T, typename... U>
struct E<N, T, U...> : E<1, U...>, D<T> {
constexpr E (T x, U... y) : E<1, U...>(y...), D<T>(x) {}
};
template <int N, typename T> struct E<N, T> : D<T> {
constexpr E (T x) : D<T>(x) {}
};
template <typename T, typename U> struct C<T, U> : E<0, T, U> {
constexpr C (T x, U y) : E<0, T, U>(x, y) {}
void operator= (typename A<const C>::B);
};
struct F {};
struct G {};
int
main ()
{
F f;
G g;
constexpr C<F, G> c(f, g);
}