Commit 2f074b08 by Jason Merrill Committed by Jason Merrill

re PR c++/51248 (ICE with pointer to enum)

	PR c++/51248
	* decl.c (copy_type_enum): Also update variants.
	(finish_enum): Allow variants of complete enums.

From-SVN: r182345
parent 3c72114c
2011-12-14 Jason Merrill <jason@redhat.com>
PR c++/51248
* decl.c (copy_type_enum): Also update variants.
(finish_enum): Allow variants of complete enums.
2011-12-14 Dodji Seketeli <dodji@redhat.com> 2011-12-14 Dodji Seketeli <dodji@redhat.com>
PR c++/51475 PR c++/51475
......
...@@ -11908,15 +11908,19 @@ xref_basetypes (tree ref, tree base_list) ...@@ -11908,15 +11908,19 @@ xref_basetypes (tree ref, tree base_list)
static void static void
copy_type_enum (tree dst, tree src) copy_type_enum (tree dst, tree src)
{ {
TYPE_MIN_VALUE (dst) = TYPE_MIN_VALUE (src); tree t;
TYPE_MAX_VALUE (dst) = TYPE_MAX_VALUE (src); for (t = dst; t; t = TYPE_NEXT_VARIANT (t))
TYPE_SIZE (dst) = TYPE_SIZE (src); {
TYPE_SIZE_UNIT (dst) = TYPE_SIZE_UNIT (src); TYPE_MIN_VALUE (t) = TYPE_MIN_VALUE (src);
SET_TYPE_MODE (dst, TYPE_MODE (src)); TYPE_MAX_VALUE (t) = TYPE_MAX_VALUE (src);
TYPE_PRECISION (dst) = TYPE_PRECISION (src); TYPE_SIZE (t) = TYPE_SIZE (src);
TYPE_ALIGN (dst) = TYPE_ALIGN (src); TYPE_SIZE_UNIT (t) = TYPE_SIZE_UNIT (src);
TYPE_USER_ALIGN (dst) = TYPE_USER_ALIGN (src); SET_TYPE_MODE (dst, TYPE_MODE (src));
TYPE_UNSIGNED (dst) = TYPE_UNSIGNED (src); TYPE_PRECISION (t) = TYPE_PRECISION (src);
TYPE_ALIGN (t) = TYPE_ALIGN (src);
TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (src);
TYPE_UNSIGNED (t) = TYPE_UNSIGNED (src);
}
} }
/* Begin compiling the definition of an enumeration type. /* Begin compiling the definition of an enumeration type.
...@@ -12285,9 +12289,12 @@ finish_enum (tree enumtype) ...@@ -12285,9 +12289,12 @@ finish_enum (tree enumtype)
return; return;
} }
/* Here there should not be any variants of this type. */ /* If this is a forward declaration, there should not be any variants,
though we can get a variant in the middle of an enum-specifier with
wacky code like 'enum E { e = sizeof(const E*) };' */
gcc_assert (enumtype == TYPE_MAIN_VARIANT (enumtype) gcc_assert (enumtype == TYPE_MAIN_VARIANT (enumtype)
&& !TYPE_NEXT_VARIANT (enumtype)); && (TYPE_VALUES (enumtype)
|| !TYPE_NEXT_VARIANT (enumtype)));
} }
/* Build and install a CONST_DECL for an enumeration constant of the /* Build and install a CONST_DECL for an enumeration constant of the
......
2011-12-14 Jason Merrill <jason@redhat.com>
PR c++/51248
* g++.dg/other/enum2.C: New.
2011-12-14 Dodji Seketeli <dodji@redhat.com> 2011-12-14 Dodji Seketeli <dodji@redhat.com>
PR c++/51475 PR c++/51475
......
// PR c++/51248
enum E { e = sizeof(const E*) };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment