aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-02-05 21:03:30 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2008-02-05 21:03:30 +0100
commit6a279e922880678b6be3ae437422e146c1f76009 (patch)
tree02867e06e7df6e85d8215596e964e59f181c435d
parentdef7425b63fce3ea7dd9fed7a114c7233aee66b0 (diff)
downloadgcc-6a279e922880678b6be3ae437422e146c1f76009.zip
gcc-6a279e922880678b6be3ae437422e146c1f76009.tar.gz
gcc-6a279e922880678b6be3ae437422e146c1f76009.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/array19.C22
4 files changed, 36 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5ea0490..00c96e7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2b996d4..b62cc3d 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 8434064..893f727 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/template/array19.C b/gcc/testsuite/g++.dg/template/array19.C
new file mode 100644
index 0000000..79abf47
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/array19.C
@@ -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);
+}