diff options
author | Joseph Myers <jsm@polyomino.org.uk> | 2004-09-13 22:00:33 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2004-09-13 22:00:33 +0100 |
commit | 61f4f1cc3d363590bec97bc8fb035064d617bd73 (patch) | |
tree | ba99baf31dd5640c618debd8f6de5121f2512a34 /gcc/c-decl.c | |
parent | b4cb0e432b123b1e152e9d35c0675495bde8fe72 (diff) | |
download | gcc-61f4f1cc3d363590bec97bc8fb035064d617bd73.zip gcc-61f4f1cc3d363590bec97bc8fb035064d617bd73.tar.gz gcc-61f4f1cc3d363590bec97bc8fb035064d617bd73.tar.bz2 |
c-decl.c (grokdeclarator): Correct comments about where storage class specifiers are rejected by grammar...
* c-decl.c (grokdeclarator): Correct comments about where storage
class specifiers are rejected by grammar and add corresponding
asserts. Diagnose typedefs and parameters declared inline.
Change warning for inline main to a pedwarn. Only diagnose inline
main if hosted.
(declspecs_add_scspec): Allow duplicate "inline".
testsuite:
* gcc.dg/declspec-7.c: Don't expect diagnostic for duplicate
"inline".
* gcc.dg/declspec-11.c: Update expected messages.
* gcc.dg/inline-6.c, gcc.dg/inline-7.c, gcc.dg/inline-8.c,
gcc.dg/inline-9.c, gcc.dg/inline-10.c, gcc.dg/inline-11.c,
gcc.dg/inline-12.c: New tests.
From-SVN: r87450
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 7d986cd..1d6c40d 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -4356,8 +4356,6 @@ grokdeclarator (const struct c_declarator *declarator, if (storage_class == csc_typedef) { tree decl; - /* Note that the grammar rejects storage classes - in typenames, fields or parameters */ if (pedantic && TREE_CODE (type) == FUNCTION_TYPE && type_quals) pedwarn ("ISO C forbids qualified function types"); @@ -4368,6 +4366,8 @@ grokdeclarator (const struct c_declarator *declarator, || declspecs->typedef_signed_p) C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1; decl_attributes (&decl, returned_attrs, 0); + if (declspecs->inline_p) + pedwarn ("%Jtypedef %qD declared %<inline%>", decl, decl); return decl; } @@ -4391,8 +4391,10 @@ grokdeclarator (const struct c_declarator *declarator, if (decl_context == TYPENAME) { - /* Note that the grammar rejects storage classes - in typenames, fields or parameters */ + /* Note that the grammar rejects storage classes in typenames + and fields. */ + gcc_assert (storage_class == csc_none && !threadp + && !declspecs->inline_p); if (pedantic && TREE_CODE (type) == FUNCTION_TYPE && type_quals) pedwarn ("ISO C forbids const or volatile function types"); @@ -4495,9 +4497,16 @@ grokdeclarator (const struct c_declarator *declarator, DECL_ARG_TYPE (decl) = promoted_type; DECL_ARG_TYPE_AS_WRITTEN (decl) = type_as_written; + if (declspecs->inline_p) + pedwarn ("%Jparameter %qD declared %<inline%>", decl, decl); } else if (decl_context == FIELD) { + /* Note that the grammar rejects storage classes in typenames + and fields. */ + gcc_assert (storage_class == csc_none && !threadp + && !declspecs->inline_p); + /* Structure field. It may not be a function. */ if (TREE_CODE (type) == FUNCTION_TYPE) @@ -4579,10 +4588,10 @@ grokdeclarator (const struct c_declarator *declarator, C_FUNCTION_IMPLICIT_INT (decl) = 1; /* Record presence of `inline', if it is reasonable. */ - if (MAIN_NAME_P (declarator->u.id)) + if (flag_hosted && MAIN_NAME_P (declarator->u.id)) { if (declspecs->inline_p) - warning ("cannot inline function %<main%>"); + pedwarn ("cannot inline function %<main%>"); } else if (declspecs->inline_p) { @@ -6858,10 +6867,11 @@ declspecs_add_scspec (struct c_declspecs *specs, tree scspec) switch (i) { case RID_INLINE: - /* GCC has hitherto given an error for duplicate inline, but - this should be revisited since C99 permits duplicate - inline. */ - dupe = specs->inline_p; + /* C99 permits duplicate inline. Although of doubtful utility, + it seems simplest to permit it in gnu89 mode as well, as + there is also little utility in maintaining this as a + difference between gnu89 and C99 inline. */ + dupe = false; specs->inline_p = true; break; case RID_THREAD: |