Bug 12560 - [3.4 Regression] Error recovery problem with enum
Summary: [3.4 Regression] Error recovery problem with enum
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.0
: P2 minor
Target Milestone: 4.0.0
Assignee: Zack Weinberg
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2003-10-09 22:33 UTC by Falk Hueffner
Modified: 2005-02-09 02:18 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3 4.0.0
Known to fail:
Last reconfirmed: 2003-12-23 10:42:07


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Falk Hueffner 2003-10-09 22:33:35 UTC
falk@juist:/tmp% cat min.c

foo()
enum { a = b };

falk@juist:/tmp% gcc --version
gcc (GCC) 3.5-tree-ssa 20031009 (merged 20031005)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

falk@juist:/tmp% gcc -c min.c
min.c: In function `foo':

min.c:2: error: `b' undeclared (first use in this function)
min.c:2: error: (Each undeclared identifier is reported only once
min.c:2: error: for each function it appears in.)
min.c:2: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Andrew Pinski 2003-10-09 23:11:08 UTC
It also happens on the mainline (20031009). Also it is a regression from 3.3.1.

undeclared_variable (id=0x40100f40) at /home/gates/pinskia/src/gnu/gcc/src/gcc/c-decl.c:1967
1967      scope->shadowed = tree_cons (id, IDENTIFIER_SYMBOL_VALUE (id),
(gdb) bt
#0  undeclared_variable (id=0x40100f40) at /home/gates/pinskia/src/gnu/gcc/src/gcc/c-
decl.c:1967
#1  0x080783dc in build_external_ref (id=0x40100f40, fun=0) at /home/gates/pinskia/src/gnu/
gcc/src/gcc/c-typeck.c:1603
#2  0x0804c613 in yyparse () at c-parse.y:596
#3  0x080525db in c_parse_file () at c-parse.y:3033
#4  0x080a3c6b in c_common_parse_file (set_yydebug=2) at /home/gates/pinskia/src/gnu/gcc/
src/gcc/c-opts.c:1226
#5  0x083029b4 in toplev_main (argc=2, argv=0xbffec754) at /home/gates/pinskia/src/gnu/gcc/
src/gcc/toplev.c:1792
#6  0x080c453e in main (argc=2, argv=0x2) at /home/gates/pinskia/src/gnu/gcc/src/gcc/
main.c:35
Comment 2 Andrew Pinski 2003-10-26 23:03:15 UTC
From Phil's regression hunter: Search converges between 2003-03-17-trunk (#247) and 2003-03
-18-trunk (#248).
Comment 3 Volker Reichelt 2003-12-08 23:28:38 UTC
The regression was introduced by Zack's patch

http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01594.html
http://gcc.gnu.org/ml/gcc-cvs/2003-03/msg00901.html

Zack, could you please have a look?
Comment 4 Zack Weinberg 2003-12-08 23:42:36 UTC
Will address this as part of the c-decl.c overhaul I'm doing now.
Comment 5 Andrew Pinski 2004-01-25 02:52:13 UTC
The problem is that this point current_function_decl is not NULL but 
current_function_scope is NULL.
Comment 6 Andrew Pinski 2004-01-25 23:14:27 UTC
I have also seen this when you leave out the closing crucly brace for a function.
Comment 7 Mark Mitchell 2004-03-09 10:29:28 UTC
As this is just an ICE after a valid error message, we can postpone this until
3.4.1.
Comment 8 Zack Weinberg 2004-03-16 20:57:47 UTC
Fixed by the c-decl.c rewrite:
http://gcc.gnu.org/ml/gcc-patches/2004-03/msg01280.html
Comment 9 Zack Weinberg 2004-03-23 23:52:58 UTC
fixed in 3.5
Comment 10 Falk Hueffner 2004-05-05 18:48:11 UTC
As Zack says, it's fixed.