]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR middle-end/68582
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Dec 2015 15:44:08 +0000 (15:44 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Dec 2015 15:44:08 +0000 (15:44 +0000)
* cgraphunit.c (check_global_declaration): Only depend on TREE_THIS_VOLATILE
for VAR_DECLs.

* c-c++-common/pr68582.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231116 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cgraphunit.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr68582.c [new file with mode: 0644]

index 5b631cf8fd8d6b3984225fe690d86fd417aa5a94..7dd3a7895605f7d372f874030598555eebb3f4da 100644 (file)
@@ -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
index f73d9a78e0303257afadc9aa10c5a3a7b5588216..4ce5f9bdd2e2da58abcab685e30ed14727045220 100644 (file)
@@ -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.  */
index 78d31efefaaf63a20449350269299c40ef7a1331..addc48127943fcc1937453176ec3a8551952e072 100644 (file)
@@ -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 (file)
index 0000000..95ca9a4
--- /dev/null
@@ -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 ();
+}