diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cgraphunit.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr68582.c | 25 |
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 (); +} |