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
This commit is contained in:
Jakub Jelinek 2018-11-27 22:04:41 +01:00 committed by Jakub Jelinek
parent fc74d562de
commit d15a796967
4 changed files with 40 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2018-11-27 Jakub Jelinek <jakub@redhat.com>
PR c++/88181
* class.c (fixup_attribute_variants): Also propagate TYPE_PACKED
to variants.
2018-11-26 Marek Polacek <polacek@redhat.com>
PR c++/88120 - ICE when calling save_expr in a template.

View file

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

View file

@ -1,5 +1,8 @@
2018-11-27 Jakub Jelinek <jakub@redhat.com>
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.

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