diff options
author | Geoffrey Keating <geoffk@apple.com> | 2004-08-30 22:19:24 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2004-08-30 22:19:24 +0000 |
commit | ff164b22d364c830b43d08e521a768b2a2957bbc (patch) | |
tree | 0a03574db9fe3cc658f3e39c3b39e37c3aa5c726 /gcc/c-decl.c | |
parent | e2cad04b2825ff91d12ebe595c91bbf3cf824fcc (diff) | |
download | gcc-ff164b22d364c830b43d08e521a768b2a2957bbc.zip gcc-ff164b22d364c830b43d08e521a768b2a2957bbc.tar.gz gcc-ff164b22d364c830b43d08e521a768b2a2957bbc.tar.bz2 |
re PR c/12738 (Missing function with 'static' block-scope declaration; unit-at-a-time; and IMA.)
2004-08-30 Geoffrey Keating <geoffk@apple.com>
PR 12738
PR 17205
Radar 3460526
Radar 3775729
* c-decl.c (grokdeclarator): Produce error for 'static' on local
function declaration.
Index: testsuite/ChangeLog
2004-08-30 Geoffrey Keating <geoffk@apple.com>
* gcc.dg/funcdef-storage-1.c: New.
* gcc.c-torture/compile/920625-2.c: Don't use 'static' to declare
an extern function in local scope.
* gcc.c-torture/execute/20010605-1.c: Don't use 'static inline' to
declare an 'auto inline' function in local scope.
* gcc.dg/20011130-1.c: Likewise.
* gcc.c-torture/execute/nest-stdar-1.c: Don't use 'static' to declare
an 'auto' function in local scope.
* gcc.dg/20021014-1.c: Likewise.
* gcc.dg/20030331-2.c: Likewise.
From-SVN: r86807
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 7ef352e..b2f7bbe 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -4664,26 +4664,29 @@ grokdeclarator (tree declarator, tree declspecs, } else if (TREE_CODE (type) == FUNCTION_TYPE) { - if (specbits & (1 << (int) RID_AUTO) - && (pedantic || current_scope == file_scope)) - pedwarn ("invalid storage class for function `%s'", name); - if (specbits & (1 << (int) RID_REGISTER)) - error ("invalid storage class for function `%s'", name); - if (specbits & (1 << (int) RID_THREAD)) + if (specbits & (1 << (int) RID_REGISTER) + || specbits & (1 << (int) RID_THREAD)) error ("invalid storage class for function `%s'", name); - /* Function declaration not at file scope. - Storage classes other than `extern' are not allowed - and `extern' makes no difference. */ - if (current_scope != file_scope - && (specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_INLINE))) - && pedantic) - pedwarn ("invalid storage class for function `%s'", name); + else if (current_scope != file_scope) + { + /* Function declaration not at file scope. Storage + classes other than `extern' are not allowed, C99 + 6.7.1p5, and `extern' makes no difference. However, + GCC allows 'auto', perhaps with 'inline', to support + nested functions. */ + if (specbits & (1 << (int) RID_AUTO)) + { + if (pedantic) + pedwarn ("invalid storage class for function `%s'", name); + } + if (specbits & (1 << (int) RID_STATIC)) + error ("invalid storage class for function `%s'", name); + } decl = build_decl (FUNCTION_DECL, declarator, type); decl = build_decl_attribute_variant (decl, decl_attr); - DECL_LANG_SPECIFIC (decl) - = GGC_CNEW (struct lang_decl); + DECL_LANG_SPECIFIC (decl) = GGC_CNEW (struct lang_decl); if (pedantic && type_quals && ! DECL_IN_SYSTEM_HEADER (decl)) pedwarn ("ISO C forbids qualified function types"); |