]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/108449 - keep maybe_special_function_p behavior
authorRichard Biener <rguenther@suse.de>
Thu, 19 Jan 2023 07:44:25 +0000 (08:44 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 23 Jan 2023 07:27:19 +0000 (08:27 +0100)
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.

gcc/cgraphunit.cc
gcc/testsuite/gcc.dg/pr108449.c [new file with mode: 0644]

index 59ce2708b7be00cc36d450aa3f8e374c0054e5b1..832818d651fd83059b07b2fcd9b2a8ec65490dc2 100644 (file)
@@ -1087,8 +1087,6 @@ check_global_declaration (symtab_node *snode)
       else
        warning (OPT_Wunused_function, "%q+F declared %<static%> 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 (file)
index 0000000..4a3ae5b
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+static int vfork(); /* { dg-warning "used but never defined" } */
+void f() { vfork(); }