re PR debug/66869 (-Wunused-function no longer warns for static declarations without definition)
PR debug/66869 * decl.c (wrapup_globals_for_namespace): Warn about unused static function declarations. * g++.dg/warn/Wunused-function2.C: New test. From-SVN: r232975
This commit is contained in:
parent
f597d5f73c
commit
16b77b321e
@ -1,3 +1,9 @@
|
||||
2016-01-29 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR debug/66869
|
||||
* decl.c (wrapup_globals_for_namespace): Warn about unused static
|
||||
function declarations.
|
||||
|
||||
2016-01-29 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/69509
|
||||
|
@ -879,6 +879,24 @@ wrapup_globals_for_namespace (tree name_space, void* data ATTRIBUTE_UNUSED)
|
||||
tree *vec = statics->address ();
|
||||
int len = statics->length ();
|
||||
|
||||
if (warn_unused_function)
|
||||
{
|
||||
tree decl;
|
||||
unsigned int i;
|
||||
FOR_EACH_VEC_SAFE_ELT (statics, i, decl)
|
||||
if (TREE_CODE (decl) == FUNCTION_DECL
|
||||
&& DECL_INITIAL (decl) == 0
|
||||
&& DECL_EXTERNAL (decl)
|
||||
&& !TREE_PUBLIC (decl)
|
||||
&& !DECL_ARTIFICIAL (decl)
|
||||
&& !TREE_NO_WARNING (decl))
|
||||
{
|
||||
warning (OPT_Wunused_function,
|
||||
"%q+F declared %<static%> but never defined", decl);
|
||||
TREE_NO_WARNING (decl) = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write out any globals that need to be output. */
|
||||
return wrapup_global_declarations (vec, len);
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
2016-01-29 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR debug/66869
|
||||
* g++.dg/warn/Wunused-function2.C: New test.
|
||||
|
||||
2016-01-29 Dominik Vogt <vogt@linux.vnet.ibm.com>
|
||||
|
||||
* gcc.dg/tree-ssa/ssa-dom-cse-2.c: Require a hardware vector
|
||||
|
6
gcc/testsuite/g++.dg/warn/Wunused-function2.C
Normal file
6
gcc/testsuite/g++.dg/warn/Wunused-function2.C
Normal file
@ -0,0 +1,6 @@
|
||||
// PR debug/66869
|
||||
// { dg-do compile }
|
||||
// { dg-options "-Wunused-function" }
|
||||
|
||||
static void test (void); // { dg-warning "'void test..' declared 'static' but never defined" }
|
||||
int i;
|
Loading…
Reference in New Issue
Block a user