aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-12-01 15:44:08 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-12-01 15:44:08 +0000
commit8b6ab677a214c9ae86ab4644af573b93bfd84b03 (patch)
treef379aee6d108102c1d3af28866f4af7a0127481b /gcc
parent6c59645f5de1af1dff9715a5bd30f21f29cf2607 (diff)
downloadgcc-8b6ab677a214c9ae86ab4644af573b93bfd84b03.zip
gcc-8b6ab677a214c9ae86ab4644af573b93bfd84b03.tar.gz
gcc-8b6ab677a214c9ae86ab4644af573b93bfd84b03.tar.bz2
re PR middle-end/68582 (-Wunused-function doesn't warn about unused static __attribute__((noreturn)) functions)
PR middle-end/68582 * cgraphunit.c (check_global_declaration): Only depend on TREE_THIS_VOLATILE for VAR_DECLs. * c-c++-common/pr68582.c: New test. From-SVN: r231116
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cgraphunit.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/pr68582.c25
4 files changed, 37 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5b631cf..7dd3a78 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-12-01 Marek Polacek <polacek@redhat.com>
+
+ PR middle-end/68582
+ * cgraphunit.c (check_global_declaration): Only depend on TREE_THIS_VOLATILE
+ for VAR_DECLs.
+
2015-12-01 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/68474
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index f73d9a7..4ce5f9b 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -956,7 +956,7 @@ check_global_declaration (symtab_node *snode)
&& ! DECL_ABSTRACT_ORIGIN (decl)
&& ! TREE_PUBLIC (decl)
/* A volatile variable might be used in some non-obvious way. */
- && ! TREE_THIS_VOLATILE (decl)
+ && (! VAR_P (decl) || ! TREE_THIS_VOLATILE (decl))
/* Global register variables must be declared to reserve them. */
&& ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
/* Global ctors and dtors are called by the runtime. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 78d31ef..addc481 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-12-01 Marek Polacek <polacek@redhat.com>
+
+ PR middle-end/68582
+ * c-c++-common/pr68582.c: New test.
+
2015-12-01 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/68474
diff --git a/gcc/testsuite/c-c++-common/pr68582.c b/gcc/testsuite/c-c++-common/pr68582.c
new file mode 100644
index 0000000..95ca9a4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr68582.c
@@ -0,0 +1,25 @@
+/* PR middle-end/68582 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused-function" } */
+
+/* We failed to give the warning for functions with TREE_THIS_VOLATILE set. */
+
+static void
+fn1 (void) /* { dg-warning "defined but not used" } */
+{
+ __builtin_abort ();
+}
+
+__attribute__ ((noreturn))
+static void
+fn2 (void) /* { dg-warning "defined but not used" } */
+{
+ __builtin_abort ();
+}
+
+__attribute__ ((volatile))
+static void
+fn3 (void) /* { dg-warning "defined but not used" } */
+{
+ __builtin_abort ();
+}