toplev.c (check_global_declarations): Suppress not-used warning for volatile variables.
authorGeoffrey Keating <geoffk@apple.com>
Mon, 5 May 2003 18:29:29 +0000 (18:29 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Mon, 5 May 2003 18:29:29 +0000 (18:29 +0000)
2003-05-05  Geoffrey Keating  <geoffk@apple.com>

* toplev.c (check_global_declarations): Suppress not-used warning
for volatile variables.

Index: testsuite/ChangeLog
2003-05-05  Geoffrey Keating  <geoffk@apple.com>

* gcc.dg/unused-5.c: New test.

From-SVN: r66493

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/unused-5.c [new file with mode: 0644]
gcc/toplev.c

index 0f8cad843e347c1c9be447f99d73466b508adfcd..4d765a3c8b367fc67b60cd1e4ebee49241ae39a2 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-05  Geoffrey Keating  <geoffk@apple.com>
+
+       * toplev.c (check_global_declarations): Suppress not-used warning
+       for volatile variables.
+
 2003-05-05  Olivier Hainque  <hainque@act-europe.fr>
 
         * expr.c (expand_expr, case BIT_FIELD_REF): Refine the test forcing
index c86b9217d6f90c75259dd5d36bae742570cbde46..92a767911e1b9fd157426f990d02c429275667ad 100644 (file)
@@ -1,3 +1,7 @@
+2003-05-05  Geoffrey Keating  <geoffk@apple.com>
+
+       * gcc.dg/unused-5.c: New test.
+
 2003-05-05  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/10496
diff --git a/gcc/testsuite/gcc.dg/unused-5.c b/gcc/testsuite/gcc.dg/unused-5.c
new file mode 100644 (file)
index 0000000..5ccc3f3
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-Wunused" } */
+/* { dg-final { scan-assembler "string_to_look_for" } } */
+
+/* 'volatile' variables get output and don't produce a warning about being
+   unused.  */
+static volatile char string[] 
+  = "string_to_look_for";  /* { dg-bogus "not used" } */
index 30bae577992f7afd5c86e9f800a9199975a61eff..8dcc44c3e541d88c156e0c795640c085916828ee 100644 (file)
@@ -2132,6 +2132,8 @@ check_global_declarations (vec, len)
          && ! TREE_USED (DECL_NAME (decl))
          && ! DECL_EXTERNAL (decl)
          && ! TREE_PUBLIC (decl)
+         /* A volatile variable might be used in some non-obvious way.  */
+         && ! TREE_THIS_VOLATILE (decl)
          /* Global register variables must be declared to reserve them.  */
          && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
          /* Otherwise, ask the language.  */