public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-8468] cgraphunit: Avoid code generation differences based on -w/TREE_NO_WARNING [PR94277]
@ 2020-04-07 19:03 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-04-07 19:03 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4ac9ab60f06020a24e851ebe3eeacc1b3bffa849
commit r9-8468-g4ac9ab60f06020a24e851ebe3eeacc1b3bffa849
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 24 09:33:17 2020 +0100
cgraphunit: Avoid code generation differences based on -w/TREE_NO_WARNING [PR94277]
The following testcase FAILs with -fcompare-debug, but not because -g vs.
-g0 would make a difference, but because the second compilation is done with
-w in order not to emit warnings twice and -w seems to affect the *.gkd dump
content.
This is because TREE_NO_WARNING flag, or warn_unused_function does affect
not just whether a warning/pedwarn is printed, but also whether we set
TREE_PUBLIC on such decls.
The following patch makes sure we set it regardless of anything warning
related (TREE_NO_WARNING or warn_unused_function).
2020-03-24 Jakub Jelinek <jakub@redhat.com>
PR debug/94277
* cgraphunit.c (check_global_declaration): For DECL_EXTERNAL and
non-TREE_PUBLIC non-DECL_ARTIFICIAL FUNCTION_DECLs, set TREE_PUBLIC
regardless of whether TREE_NO_WARNING is set on it or whether
warn_unused_function is true or not.
* gcc.dg/pr94277.c: New test.
Diff:
---
gcc/ChangeLog | 10 ++++++++++
gcc/cgraphunit.c | 12 ++++++------
gcc/testsuite/ChangeLog | 5 +++++
gcc/testsuite/gcc.dg/pr94277.c | 11 +++++++++++
4 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2cd4b81ebe9..356e7c14e3b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,16 @@
2020-04-07 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2020-03-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/94277
+ * cgraphunit.c (check_global_declaration): For DECL_EXTERNAL and
+ non-TREE_PUBLIC non-DECL_ARTIFICIAL FUNCTION_DECLs, set TREE_PUBLIC
+ regardless of whether TREE_NO_WARNING is set on it or whether
+ warn_unused_function is true or not.
+
+2020-04-07 Jakub Jelinek <jakub@redhat.com>
+
2020-03-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/94211
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 4a27867b82c..0f933bdc758 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -967,15 +967,15 @@ check_global_declaration (symtab_node *snode)
&& DECL_INITIAL (decl) == 0
&& DECL_EXTERNAL (decl)
&& ! DECL_ARTIFICIAL (decl)
- && ! TREE_NO_WARNING (decl)
- && ! TREE_PUBLIC (decl)
- && (warn_unused_function
- || snode->referred_to_p (/*include_self=*/false)))
+ && ! TREE_PUBLIC (decl))
{
- if (snode->referred_to_p (/*include_self=*/false))
+ if (TREE_NO_WARNING (decl))
+ ;
+ else if (snode->referred_to_p (/*include_self=*/false))
pedwarn (input_location, 0, "%q+F used but never defined", decl);
else
- warning (OPT_Wunused_function, "%q+F declared %<static%> but never defined", decl);
+ warning (OPT_Wunused_function, "%q+F declared %<static%> but never "
+ "defined", decl);
/* This symbol is effectively an "extern" declaration now. */
TREE_PUBLIC (decl) = 1;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 650b8683387..a43da5200a2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,11 @@
2020-04-07 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2020-03-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/94277
+ * gcc.dg/pr94277.c: New test.
+
2020-03-19 Jakub Jelinek <jakub@redhat.com>
PR gcov-profile/94029
diff --git a/gcc/testsuite/gcc.dg/pr94277.c b/gcc/testsuite/gcc.dg/pr94277.c
new file mode 100644
index 00000000000..dfe38e401a9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94277.c
@@ -0,0 +1,11 @@
+/* PR debug/94277 */
+/* { dg-do compile } */
+/* { dg-options "-fcompare-debug" } */
+
+static void foo (void); /* { dg-warning "used but never defined" } */
+
+void
+bar (void)
+{
+ foo ();
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-07 19:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 19:03 [gcc r9-8468] cgraphunit: Avoid code generation differences based on -w/TREE_NO_WARNING [PR94277] Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).