aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorJames A. Morrison <phython@gcc.gnu.org>2004-12-21 17:01:08 +0000
committerJames A. Morrison <phython@gcc.gnu.org>2004-12-21 17:01:08 +0000
commit0724c83eb13a580aa21184ac7e85cb1374ba22b1 (patch)
tree4f41c122c72dec3b860a1cabdb23536dbf18fbee /gcc/c-decl.c
parent1d47a31066a50e7ef6b4c9e8f039b656e5e91140 (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@92459 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 97420d16cc2..f881ea8e052 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -2964,6 +2964,8 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
decl = grokdeclarator (declarator, declspecs,
NORMAL, initialized, NULL);
+ if (!decl)
+ return 0;
deprecated_state = DEPRECATED_NORMAL;
@@ -4437,14 +4439,9 @@ 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);
- if (DECL_INITIAL (decl) != NULL_TREE)
- DECL_INITIAL (decl) = error_mark_node;
}
else if (current_scope != file_scope)
{
@@ -4458,14 +4455,19 @@ grokdeclarator (const struct c_declarator *declarator,
if (pedantic)
pedwarn ("invalid storage class for function %qs", name);
}
- if (storage_class == csc_static)
+ else if (storage_class == csc_static)
{
error ("invalid storage class for function %qs", name);
- if (DECL_INITIAL (decl) != NULL_TREE)
- DECL_INITIAL (decl) = error_mark_node;
+ if (funcdef_flag)
+ storage_class = declspecs->storage_class = csc_none;
+ else
+ return 0;
}
}
+ 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))