On Mon, Feb 02, 2026 at 04:48:48PM +0100, Michal Jires wrote:
> Alright, v5 is suppressing OPT_Wunused.
Thanks, this looks right to me already, so just small nits.
> --- a/gcc/c/c-decl.cc
> +++ b/gcc/c/c-decl.cc
> @@ -13669,24 +13669,22 @@ c_write_global_declarations_1 (tree globals)
> if (TREE_CODE (decl) == FUNCTION_DECL
> && DECL_INITIAL (decl) == NULL_TREE
> && DECL_EXTERNAL (decl)
> - && !TREE_PUBLIC (decl))
> + && !TREE_PUBLIC (decl)
> + && !warning_suppressed_p (decl, OPT_Wunused))
> {
> if (C_DECL_USED (decl))
> {
> - /* TODO: Add OPT_Wundefined-inline. */
> if (pedwarn (input_location, 0, "%q+F used but never defined",
> decl))
> - suppress_warning (decl /* OPT_Wundefined-inline. */);
> + suppress_warning (decl, OPT_Wunused);
> }
> /* For -Wunused-function warn about unused static prototypes. */
> - else if (warn_unused_function
> - && ! DECL_ARTIFICIAL (decl)
> - && ! warning_suppressed_p (decl, OPT_Wunused_function))
> + else if (warn_unused_function && ! DECL_ARTIFICIAL (decl))
> {
> if (warning (OPT_Wunused_function,
> "%q+F declared %<static%> but never defined",
> decl))
> - suppress_warning (decl, OPT_Wunused_function);
> + suppress_warning (decl, OPT_Wunused);
> }
This last part could be
/* For -Wunused-function warn about unused static prototypes. */
else if (warn_unused_function
&& ! DECL_ARTIFICIAL (decl)
&& warning (OPT_Wunused_function,
"%q+F declared %<static%> but never defined",
decl))
suppress_warning (decl, OPT_Wunused);
> --- a/gcc/cgraphunit.cc
> +++ b/gcc/cgraphunit.cc
> @@ -1111,10 +1111,16 @@ check_global_declaration (symtab_node *snode)
> if (warning_suppressed_p (decl, OPT_Wunused))
> ;
> else if (snode->referred_to_p (/*include_self=*/false))
> - pedwarn (input_location, 0, "%q+F used but never defined", decl);
> + {
> + if (pedwarn (input_location, 0, "%q+F used but never defined", decl))
> + suppress_warning (decl, OPT_Wunused);
> + }
> else
> - warning (OPT_Wunused_function, "%q+F declared %<static%> but never "
> - "defined", decl);
> + {
> + if (warning (OPT_Wunused_function,
> + "%q+F declared %<static%> but never defined", decl))
> + suppress_warning (decl, OPT_Wunused);
> + }
> }
Similarly here
else if (warning (OPT_Wunused_function,
"%q+F declared %<static%> but never defined", decl))
suppress_warning (decl, OPT_Wunused);
> --- a/gcc/cp/decl.cc
> +++ b/gcc/cp/decl.cc
> @@ -1015,10 +1015,13 @@ wrapup_namespace_globals ()
> && !TREE_PUBLIC (decl)
> && !DECL_ARTIFICIAL (decl)
> && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl)
> - && !warning_suppressed_p (decl, OPT_Wunused_function))
> - warning_at (DECL_SOURCE_LOCATION (decl),
> - OPT_Wunused_function,
> - "%qF declared %<static%> but never defined", decl);
> + && !warning_suppressed_p (decl, OPT_Wunused))
> + {
> + if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_function,
> + "%qF declared %<static%> but never defined",
> + decl))
> + suppress_warning (decl, OPT_Wunused);
> + }
And ditto here
...
&& !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl)
&& !warning_suppressed_p (decl, OPT_Wunused)
&& warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_function,
"%qF declared %<static%> but never defined",
decl))
suppress_warning (decl, OPT_Wunused);
Ok with those nits fixed.
Jakub