Bug 14476

Summary: [3.3 Regression] ICE after error about enum not being defined when using it as a bit field
Product: gcc Reporter: Andrew Pinski <pinskia>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: minor CC: gcc-bugs
Priority: P2 Keywords: error-recovery, ice-on-invalid-code
Version: 4.0.0   
Target Milestone: 3.3.4   
Host: Target:
Build: Known to work: 2.95.3 3.4.0 4.0.0
Known to fail: 3.0.4 3.2.3 3.3.3 Last reconfirmed: 2004-03-08 14:57:55

Description Andrew Pinski 2004-03-08 04:45:40 UTC
struct tree_common
{
  enum tree_code code : 8;
};

This used to work correctly in 2.95.3
Comment 1 Andrew Pinski 2004-03-08 04:48:58 UTC
Forgot to say this is the ICE I get on the mainline:
test5.c:3: error: use of enum `tree_code' without previous declaration
test5.c:3: error: field `code' has incomplete type
test5.c:2: internal compiler error: tree check: expected class 't', have 'x' (error_mark) in 
layout_class_type, at cp/class.c:4626
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 2 Gabriel Dos Reis 2004-03-08 04:57:45 UTC
Subject: Re:  [3.3/3.4/3.5 Regression] ICE after error about enum not being defined when using it as a bit field

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Forgot to say this is the ICE I get on the mainline:
| test5.c:3: error: use of enum `tree_code' without previous declaration
| test5.c:3: error: field `code' has incomplete type
| test5.c:2: internal compiler error: tree check: expected class 't', have 'x' (error_mark) in 
| layout_class_type, at cp/class.c:4626

This is ICE caused by the compiler trying to be overly helpful in
thinking that by recording "code" as member he would be able to 
"process more".  It could just ignore "code" after issuing the error.

-- Gaby
Comment 3 Wolfgang Bangerth 2004-03-08 14:57:54 UTC
Confirmed. We started ICEing in in or before 3.2.3, but it worked in 
2.95. 
 
W. 
Comment 5 GCC Commits 2004-03-11 08:40:12 UTC
Subject: Bug 14476

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-03-11 08:40:08

Modified files:
	gcc/cp         : decl.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/lookup: enum1.C 

Log message:
	PR c++/14476
	* decl.c (xref_tag): Do not create dummy ENUMERAL_TYPEs.
	
	PR c++/14476
	* g++.dg/lookup/enum1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1194&r2=1.1195
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3594&r2=1.3595
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/enum1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 6 Mark Mitchell 2004-03-11 08:44:00 UTC
Fixed in GCC 3.4 and GCC 3.5.
Comment 7 GCC Commits 2004-03-13 03:16:01 UTC
Subject: Bug 14476

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	gdr@gcc.gnu.org	2004-03-13 03:15:58

Modified files:
	gcc/cp         : ChangeLog decl.c 
Added files:
	gcc/testsuite/g++.dg/lookup: enum2.C 

Log message:
	Backport:
	2004-03-11  Mark Mitchell  <mark@codesourcery.com>
	PR c++/14476
	* decl.c (xref_tag): Do not create dummy ENUMERAL_TYPEs.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.262&r2=1.3076.2.263
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.78&r2=1.965.2.79
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/enum2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

Comment 8 Gabriel Dos Reis 2004-03-13 03:16:51 UTC
Applied patch to GCC-3.3.4 too.

-- Gaby