diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-01-27 20:32:49 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-01-27 20:32:49 +0100 |
commit | cbdd8ae08c2cec98ed063a0ef2c237e80539e597 (patch) | |
tree | 25b41720693a07d6c651306b4666907bbb307799 /gcc/c | |
parent | 8dc781e4546beab0893020670bc8154809a5513b (diff) | |
download | gcc-cbdd8ae08c2cec98ed063a0ef2c237e80539e597.zip gcc-cbdd8ae08c2cec98ed063a0ef2c237e80539e597.tar.gz gcc-cbdd8ae08c2cec98ed063a0ef2c237e80539e597.tar.bz2 |
re PR debug/66869 (-Wunused-function no longer warns for static declarations without definition)
PR debug/66869
* c-decl.c (c_write_global_declarations_1): Warn with
warn_unused_function if static prototype without definition
is not C_DECL_USED.
* gcc.dg/pr66869.c: New test.
From-SVN: r232899
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 19 |
2 files changed, 22 insertions, 4 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 7999d2a..5341f04 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2016-01-27 Jakub Jelinek <jakub@redhat.com> + + PR debug/66869 + * c-decl.c (c_write_global_declarations_1): Warn with + warn_unused_function if static prototype without definition + is not C_DECL_USED. + 2016-01-27 Marek Polacek <polacek@redhat.com> PR c/68062 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 1ec6042..502fa5c 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -10741,11 +10741,22 @@ c_write_global_declarations_1 (tree globals) if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) == 0 && DECL_EXTERNAL (decl) - && !TREE_PUBLIC (decl) - && C_DECL_USED (decl)) + && !TREE_PUBLIC (decl)) { - pedwarn (input_location, 0, "%q+F used but never defined", decl); - TREE_NO_WARNING (decl) = 1; + if (C_DECL_USED (decl)) + { + pedwarn (input_location, 0, "%q+F used but never defined", decl); + TREE_NO_WARNING (decl) = 1; + } + /* For -Wunused-function warn about unused static prototypes. */ + else if (warn_unused_function + && ! DECL_ARTIFICIAL (decl) + && ! TREE_NO_WARNING (decl)) + { + warning (OPT_Wunused_function, + "%q+F declared %<static%> but never defined", decl); + TREE_NO_WARNING (decl) = 1; + } } wrapup_global_declaration_1 (decl); |