re PR c++/14476 (ICE after error about enum not being defined when using it as a bit field)

PR c++/14476
	* decl.c (xref_tag): Do not create dummy ENUMERAL_TYPEs.

	PR c++/14476
	* g++.dg/lookup/enum1.C: New test.

From-SVN: r79312
This commit is contained in:
Mark Mitchell 2004-03-11 08:40:08 +00:00 committed by Mark Mitchell
parent fc31c7cacf
commit 30fc3df7fc
3 changed files with 11 additions and 19 deletions

View File

@ -9392,25 +9392,7 @@ xref_tag (enum tag_types tag_code, tree name,
if (code == ENUMERAL_TYPE)
{
error ("use of enum `%#D' without previous declaration", name);
t = make_node (ENUMERAL_TYPE);
/* Give the type a default layout like unsigned int
to avoid crashing if it does not get defined. */
TYPE_MODE (t) = TYPE_MODE (unsigned_type_node);
TYPE_ALIGN (t) = TYPE_ALIGN (unsigned_type_node);
TYPE_USER_ALIGN (t) = 0;
TREE_UNSIGNED (t) = 1;
TYPE_PRECISION (t) = TYPE_PRECISION (unsigned_type_node);
TYPE_MIN_VALUE (t) = TYPE_MIN_VALUE (unsigned_type_node);
TYPE_MAX_VALUE (t) = TYPE_MAX_VALUE (unsigned_type_node);
/* Enable us to recognize when a type is created in class context.
To do nested classes correctly, this should probably be cleared
out when we leave this classes scope. Currently this in only
done in `start_enum'. */
pushtag (name, t, globalize);
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
else
{

View File

@ -1,3 +1,8 @@
2004-03-11 Mark Mitchell <mark@codesourcery.com>
PR c++/14476
* g++.dg/lookup/enum1.C: New test.
2004-03-10 Mark Mitchell <mark@codesourcery.com>
PR c++/14510

View File

@ -0,0 +1,5 @@
// PR c++/14476
struct tree_common {
enum tree_code code : 8; // { dg-error "" }
};