re PR c/18596 (ICE in make_decl_rtl)

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.

From-SVN: r91504
This commit is contained in:
James A. Morrison 2004-11-30 00:32:34 +00:00
parent 1590d64e4f
commit 1ac0ac8b90
4 changed files with 30 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2004-11-30 James A. Morrison <phython@gcc.gnu.org>
PR middle-end/18596
* c-decl.c (grokdeclarator): Reset DECL_INTIAL to error_mark_node
on errors.
2004-11-30 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* expr.c (expand_expr_real_1, case NOP_EXPR): Properly handle

View File

@ -4428,8 +4428,15 @@ grokdeclarator (const struct c_declarator *declarator,
}
else if (TREE_CODE (type) == FUNCTION_TYPE)
{
decl = build_decl (FUNCTION_DECL, declarator->u.id, type);
decl = build_decl_attribute_variant (decl, decl_attr);
if (storage_class == csc_register || threadp)
error ("invalid storage class for function %qs", name);
{
error ("invalid storage class for function %qs", name);
if (DECL_INITIAL (decl) != NULL_TREE)
DECL_INITIAL (decl) = error_mark_node;
}
else if (current_scope != file_scope)
{
/* Function declaration not at file scope. Storage
@ -4443,12 +4450,13 @@ grokdeclarator (const struct c_declarator *declarator,
pedwarn ("invalid storage class for function %qs", name);
}
if (storage_class == csc_static)
error ("invalid storage class for function %qs", name);
{
error ("invalid storage class for function %qs", name);
if (DECL_INITIAL (decl) != NULL_TREE)
DECL_INITIAL (decl) = error_mark_node;
}
}
decl = build_decl (FUNCTION_DECL, declarator->u.id, type);
decl = build_decl_attribute_variant (decl, decl_attr);
DECL_LANG_SPECIFIC (decl) = GGC_CNEW (struct lang_decl);
if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))

View File

@ -1,3 +1,7 @@
2004-11-30 James A. Morrison <phython@gcc.gnu.org>
* gcc.dg/pr18596-1.c: New test.
2004-11-30 Ben Elliston <bje@au.ibm.com>
* g++.old-deja/g++.other/decl5.C: Remove remaining XFAILs.

View File

@ -0,0 +1,7 @@
/* { dg-do compile } */
int f(int i)
{
static int g(); /* { dg-warning "invalid storage class" } */
static int g() { return i; } /* { dg-warning "invalid storage class" } */
return g();
}