diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-09-09 08:50:56 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2010-09-09 08:50:56 +0200 |
commit | e8e399c334841b355b7996a7f3f453e116b4652b (patch) | |
tree | b0b38c49c94ce39b461a9dd891042f51b4b4d0a5 | |
parent | c8a27c401821b4d29c28add396177637f9f381d5 (diff) | |
download | gcc-e8e399c334841b355b7996a7f3f453e116b4652b.zip gcc-e8e399c334841b355b7996a7f3f453e116b4652b.tar.gz gcc-e8e399c334841b355b7996a7f3f453e116b4652b.tar.bz2 |
re PR c++/45588 (unused-but-set-variable false trigger building gold)
PR c++/45588
* pt.c (tsubst) <case INTEGER_TYPE>: Call mark_rvalue_use
before calling fold_decl_constant_value.
* g++.dg/warn/Wunused-var-15.C: New test.
From-SVN: r164051
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wunused-var-15.C | 29 |
4 files changed, 41 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d4171b0..f2c7faa 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-09-08 Jakub Jelinek <jakub@redhat.com> + + PR c++/45588 + * pt.c (tsubst) <case INTEGER_TYPE>: Call mark_rvalue_use + before calling fold_decl_constant_value. + 2010-09-07 Arnaud Charlet <charlet@adacore.com> * cp-tree.h (build_enumerator): Add new location_t parameter. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 75a9d1b..5c32484 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10116,6 +10116,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) && !TREE_TYPE (max)) TREE_TYPE (max) = TREE_TYPE (TREE_OPERAND (max, 0)); + max = mark_rvalue_use (max); max = fold_decl_constant_value (max); /* If we're in a partial instantiation, preserve the magic NOP_EXPR diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c18b432..1ad764c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-09-08 Jakub Jelinek <jakub@redhat.com> + + PR c++/45588 + * g++.dg/warn/Wunused-var-15.C: New test. + 2010-09-08 John David Anglin <dave.anglin@nrc-cnrc.gc.ca> * c-c++-common/Wunused-var-12.c: Add -fno-common to options on 32-bit diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-15.C b/gcc/testsuite/g++.dg/warn/Wunused-var-15.C new file mode 100644 index 0000000..9782ccb --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-var-15.C @@ -0,0 +1,29 @@ +// PR c++/45588 +// { dg-do compile } +// { dg-options "-Wunused" } + +void bar (unsigned char *); + +template <int N> +struct S +{ + static const int k = 6; +}; + +template <int N> +const int S<N>::k; + +template <int N> +void +foo () +{ + const int i = S<N>::k; + unsigned char a[i]; + bar (a); +} + +void +baz () +{ + foo<0> (); +} |