With the testcase in 12322, we get an ICE after errors because of nested functions. Reduced testcase: int f(int i) { static int g(); static int g() { return i; } return g(); } : Search converges between 2004-07-27-trunk (#496) and 2004-07-28-trunk (#497).
Confirmed: 18596.c: In function 'f': 18596.c:3: error: invalid storage class for function 'g' 18596.c:4: error: invalid storage class for function 'g'
Created attachment 7612 [details] Robustify c-decl.c This patch fixes the problem with the testcase. Unfortunatly, it causes two more error messages, i.e. nested.c:4: error: redefinition of ‘g’ nested.c:3: error: previous definition of ‘g’ was here I'm going to regtest this patch then submit it.
(In reply to comment #2) > Created an attachment (id=7612) > Robustify c-decl.c > > This patch fixes the problem with the testcase. Unfortunatly, it causes two > more > error messages, i.e. Maybe the easy way to fix it is not to set the DECL_INITIAL to error_mark_node if it not set yet. Does that fix the extra error message?
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-11/msg02350.html>.
Subject: Bug 18596 CVSROOT: /cvs/gcc Module name: gcc Changes by: phython@gcc.gnu.org 2004-11-30 00:32:34 Modified files: gcc : c-decl.c ChangeLog gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: pr18596-1.c Log message: 2004-11-26 James A. Morrison <phython@gcc.gnu.org> PR middle-end/18596 * c-decl.c (grokdeclarator): Reset DECL_INTIAL to error_mark_node on errors. testsuite: * gcc.dg/pr18596-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.611&r2=1.612 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6634&r2=2.6635 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4687&r2=1.4688 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr18596-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed the the previous commit.
I'm reopening this bug, because with LAST_UPDATED "Tue Nov 30 11:22:00 UTC 2004" (with a local patch to work around the mklibgcc.in breakage at that time, later fixed) I get the same error this PR is supposed to have fixed: /gcc/testsuite/gcc.dg/pr18596-1.c: In function 'f': /gcc/testsuite/gcc.dg/pr18596-1.c:4: error: invalid storage class for function 'g' /gcc/testsuite/gcc.dg/pr18596-1.c:5: error: ISO C forbids nested functions /gcc/testsuite/gcc.dg/pr18596-1.c:5: error: invalid storage class for function 'g' /gcc/testsuite/gcc.dg/pr18596-1.c: In function 'g': /gcc/testsuite/gcc.dg/pr18596-1.c:5: internal compiler error: in make_decl_rtl, at varasm.c:867 Note also that the test-case needs a dg-options "" to avoid the automatically added -ansi. (How was the test-case tested?)
... on mmix-knuth-mmixware, I forgot to say.
Note even without -pedantic we get an ICE still.
I probably should be shot for this one. I'm looking into it.
Created attachment 7645 [details] 3rd round of a patch I'm going to go through a couple rounds of testing this time.
This patch still causes a regression: FAIL: gcc.dg/funcdef-storage-1.c (test for excess errors)
Strange that it didn't fail on sparc or sparc64 linux.
Sorry, did you mean static.nested3.patch ?
Andrew's patch for 17807 stops funcdef-storage.c from ICEing, but it causes an extra error in that testcase because it thinks foo should be a nested function.
Maybe unsetting the DECL's context will fix the ICE, I don't know for sure.
Created attachment 7673 [details] Round 4 patch
Created attachment 7674 [details] Test case 1
Created attachment 7675 [details] test case two
Created attachment 7676 [details] test case 3
The round 4 patch causes lots of regressions.
Removing patch keyword as the non of the current patches work.
Ehm, maybe this is a stupid question - but why are we generating a DECL_RTL to begin with, given that we have errors?
The problem occurs in no-unit-at-a-time mode, so the nested functions are expanded, and that is where the problems start.
Created attachment 7767 [details] round 5 or so This patch passes regression testing if the function definition in funcdef-storage-1.c is removed.
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-12/msg01411.html>.
Subject: Bug 18596 CVSROOT: /cvs/gcc Module name: gcc Changes by: phython@gcc.gnu.org 2004-12-21 17:01:08 Modified files: gcc : ChangeLog c-decl.c c-parse.in c-typeck.c gcc/testsuite : ChangeLog gcc/testsuite/gcc.dg: funcdef-storage-1.c pr18596-1.c Added files: gcc/testsuite/gcc.dg: pr18596-2.c pr18596-3.c Log message: 2004-12-19 James A. Morrison <phython@gcc.gnu.org> PR c/18596 * c-parse.in (initdcl): Don't process a declaration if start_decl fails. (notype_initdcl): Don't process a declaration if start_decl fails. * c-decl.c (start_decl): Fail if grokdeclarator fails. (grokdeclarator): Fail if a function definition has an invalid storage class. * c-typeck.c (start_init): Treat error_mark_node the same as 0. testsuite: PR c/18596 * gcc.dg/funcdef-storage-1.c (foo): Remove. * gcc.dg/pr18596-1.c: Use dg-error. (dg-options): Use -fno-unit-at-a-time. * gcc.dg/pr18596-2.c: New test. * gcc.dg/pr18596-3.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6910&r2=2.6911 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.617&r2=1.618 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-parse.in.diff?cvsroot=gcc&r1=1.255&r2=1.256 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.404&r2=1.405 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4788&r2=1.4789 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr18596-2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr18596-3.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/funcdef-storage-1.c.diff?cvsroot=gcc&r1=1.2&r2=1.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr18596-1.c.diff?cvsroot=gcc&r1=1.1&r2=1.2
Lets see if I did it right this time.