Commit 16b77b32 by Jakub Jelinek Committed by Jakub Jelinek

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
parent f597d5f7
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> 2016-01-29 Marek Polacek <polacek@redhat.com>
PR c++/69509 PR c++/69509
......
...@@ -879,6 +879,24 @@ wrapup_globals_for_namespace (tree name_space, void* data ATTRIBUTE_UNUSED) ...@@ -879,6 +879,24 @@ wrapup_globals_for_namespace (tree name_space, void* data ATTRIBUTE_UNUSED)
tree *vec = statics->address (); tree *vec = statics->address ();
int len = statics->length (); 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. */ /* Write out any globals that need to be output. */
return wrapup_global_declarations (vec, len); return wrapup_global_declarations (vec, len);
} }
......
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> 2016-01-29 Dominik Vogt <vogt@linux.vnet.ibm.com>
* gcc.dg/tree-ssa/ssa-dom-cse-2.c: Require a hardware vector * gcc.dg/tree-ssa/ssa-dom-cse-2.c: Require a hardware vector
......
// 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment