]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/33553 (Bogus "array bound is not an integer constant" for parameter in...
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Feb 2008 20:03:30 +0000 (21:03 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Feb 2008 20:03:30 +0000 (21:03 +0100)
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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/array19.C [new file with mode: 0644]

index 5ea0490684cc3d6b15b77f16f9073daae56d4aee..00c96e79aeb569b31a1e393aed789df81fa71e1c 100644 (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
index 2b996d41ae1b4b4621ab86f27779ecae04e0b1b0..b62cc3dbaa57e5402bf2e49d5a4340534880ab31 100644 (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");
index 843406430dc19410cbd3e86fb8714827a1dda5f0..893f72779057f9f3cf4e67f1284154a2dda41f4b 100644 (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
diff --git a/gcc/testsuite/g++.dg/template/array19.C b/gcc/testsuite/g++.dg/template/array19.C
new file mode 100644 (file)
index 0000000..79abf47
--- /dev/null
@@ -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);
+}