From: Jakub Jelinek Date: Tue, 5 Feb 2008 20:03:30 +0000 (+0100) Subject: re PR c++/33553 (Bogus "array bound is not an integer constant" for parameter in... X-Git-Tag: releases/gcc-4.3.0~263 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a279e922880678b6be3ae437422e146c1f76009;p=thirdparty%2Fgcc.git re PR c++/33553 (Bogus "array bound is not an integer constant" for parameter in template method of template class) PR c++/33553 * pt.c (tsubst) : Don't issue error if max is value dependent expression. * g++.dg/template/array19.C: New test. From-SVN: r132126 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5ea0490684cc..00c96e79aeb5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-02-05 Jakub Jelinek + + PR c++/33553 + * pt.c (tsubst) : Don't issue error if max is + value dependent expression. + 2008-02-05 Douglas Gregor PR c++/35074 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2b996d41ae1b..b62cc3dbaa57 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8894,9 +8894,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) /*integral_constant_expression_p=*/false); max = fold_decl_constant_value (max); - if (TREE_CODE (max) != INTEGER_CST - && TREE_CODE (max) != TEMPLATE_PARM_INDEX - && !at_function_scope_p ()) + if (TREE_CODE (max) != INTEGER_CST + && !at_function_scope_p () + && !value_dependent_expression_p (max)) { if (complain & tf_error) error ("array bound is not an integer constant"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 843406430dc1..893f72779057 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-02-05 Jakub Jelinek + + PR c++/33553 + * g++.dg/template/array19.C: New test. + 2008-02-05 Diego Novillo http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00140.html diff --git a/gcc/testsuite/g++.dg/template/array19.C b/gcc/testsuite/g++.dg/template/array19.C new file mode 100644 index 000000000000..79abf47c17a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array19.C @@ -0,0 +1,22 @@ +// PR c++/33553 +// { dg-do compile } + +template struct S { static const int sz = 2; }; +template struct U { enum { sz = 2 }; }; + +template +struct P +{ + template void bar (int (&x)[S::sz]); + template void baz (int (&x)[U::sz]); +}; + +P p; + +void +foo (void) +{ + int x[2]; + p.bar (x); + p.baz (x); +}