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

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
This commit is contained in:
Geoffrey Keating 2003-05-05 18:29:29 +00:00 committed by Geoffrey Keating
parent 9e5f281f99
commit 36b29d7dd1
4 changed files with 19 additions and 0 deletions

View 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

View 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

View File

@ -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" } */

View 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. */