From: jakub Date: Thu, 9 Sep 2010 06:50:56 +0000 (+0000) Subject: PR c++/45588 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=75b940710fbb05f64630f0b3422e8d5f4dd12ba3;p=thirdparty%2Fgcc.git PR c++/45588 * pt.c (tsubst) : Call mark_rvalue_use before calling fold_decl_constant_value. * g++.dg/warn/Wunused-var-15.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164051 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d4171b0fc028..f2c7faa06259 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-09-08 Jakub Jelinek + + PR c++/45588 + * pt.c (tsubst) : Call mark_rvalue_use + before calling fold_decl_constant_value. + 2010-09-07 Arnaud Charlet * cp-tree.h (build_enumerator): Add new location_t parameter. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 75a9d1b25a41..5c324847268c 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 c18b432333e0..1ad764c60b37 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-09-08 Jakub Jelinek + + PR c++/45588 + * g++.dg/warn/Wunused-var-15.C: New test. + 2010-09-08 John David Anglin * 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 000000000000..9782ccbd9a7c --- /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 +struct S +{ + static const int k = 6; +}; + +template +const int S::k; + +template +void +foo () +{ + const int i = S::k; + unsigned char a[i]; + bar (a); +} + +void +baz () +{ + foo<0> (); +}