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) <case INTEGER_TYPE>: Don't issue error if max is
	value dependent expression.

	* g++.dg/template/array19.C: New test.

From-SVN: r132126
This commit is contained in:
Jakub Jelinek 2008-02-05 21:03:30 +01:00 committed by Jakub Jelinek
parent def7425b63
commit 6a279e9228
4 changed files with 36 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2008-02-05 Jakub Jelinek <jakub@redhat.com>
PR c++/33553
* pt.c (tsubst) <case INTEGER_TYPE>: Don't issue error if max is
value dependent expression.
2008-02-05 Douglas Gregor <doug.gregor@gmail.com>
PR c++/35074

View File

@ -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");

View File

@ -1,3 +1,8 @@
2008-02-05 Jakub Jelinek <jakub@redhat.com>
PR c++/33553
* g++.dg/template/array19.C: New test.
2008-02-05 Diego Novillo <dnovillo@google.com>
http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00140.html

View File

@ -0,0 +1,22 @@
// PR c++/33553
// { dg-do compile }
template <class T> struct S { static const int sz = 2; };
template <class T> struct U { enum { sz = 2 }; };
template <class R>
struct P
{
template <class T> void bar (int (&x)[S<T>::sz]);
template <class T> void baz (int (&x)[U<T>::sz]);
};
P<int> p;
void
foo (void)
{
int x[2];
p.bar<int> (x);
p.baz<int> (x);
}