From: Richard Biener Date: Thu, 19 Jan 2023 07:44:25 +0000 (+0100) Subject: tree-optimization/108449 - keep maybe_special_function_p behavior X-Git-Tag: basepoints/gcc-14~1922 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=106f99406312d7ed47434de53c180718225ffa5e;p=thirdparty%2Fgcc.git tree-optimization/108449 - keep maybe_special_function_p behavior When we have a static declaration without definition we diagnose that and turn it into an extern declaration. That can alter the outcome of maybe_special_function_p here and there's really no point in doing that, so don't. PR tree-optimization/108449 * cgraphunit.cc (check_global_declaration): Do not turn undefined statics into externs. * gcc.dg/pr108449.c: New testcase. --- diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc index 59ce2708b7be..832818d651fd 100644 --- a/gcc/cgraphunit.cc +++ b/gcc/cgraphunit.cc @@ -1087,8 +1087,6 @@ check_global_declaration (symtab_node *snode) else warning (OPT_Wunused_function, "%q+F declared % but never " "defined", decl); - /* This symbol is effectively an "extern" declaration now. */ - TREE_PUBLIC (decl) = 1; } /* Warn about static fns or vars defined but not used. */ diff --git a/gcc/testsuite/gcc.dg/pr108449.c b/gcc/testsuite/gcc.dg/pr108449.c new file mode 100644 index 000000000000..4a3ae5b3ed40 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr108449.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +static int vfork(); /* { dg-warning "used but never defined" } */ +void f() { vfork(); }