OSDN Git Service

PR c++/19208
authorgiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Jan 2005 02:27:16 +0000 (02:27 +0000)
committergiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Jan 2005 02:27:16 +0000 (02:27 +0000)
* pt.c (fold_decl_constant_value): Always call fold_non_dependent_expr
at least once.
(tsubst): Use fold_decl_constant_value in place of a bare call to
integral_constant_value.

PR c++/19208
* g++.dg/template/array11.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94006 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 4ac2035..9d10f68 100644 (file)
@@ -1,3 +1,11 @@
+2005-01-21  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/19208
+       * pt.c (fold_decl_constant_value): Always call fold_non_dependent_expr
+       at least once.
+       (tsubst): Use fold_decl_constant_value in place of a bare call to
+       integral_constant_value.
+
 2005-01-20  Kazu Hirata  <kazu@cs.umass.edu>
 
        * typeck.c (more_qualified_p): Remove.
index 72d4528..8233da9 100644 (file)
@@ -3332,13 +3332,13 @@ fold_non_dependent_expr (tree expr)
 tree
 fold_decl_constant_value (tree expr)
 {
-  while (true)
+  tree const_expr = expr;
+  do
     {
-      tree const_expr = integral_constant_value (expr);
-      if (expr == const_expr)
-       break;
       expr = fold_non_dependent_expr (const_expr);
+      const_expr = integral_constant_value (expr);
     }
+  while (expr != const_expr);
 
   return expr;
 }
@@ -6970,8 +6970,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
        /* The array dimension behaves like a non-type template arg,
           in that we want to fold it as much as possible.  */
        max = tsubst_template_arg (omax, args, complain, in_decl);
-       if (!processing_template_decl)
-         max = integral_constant_value (max);
+       max = fold_decl_constant_value (max);
 
        if (integer_zerop (omax))
          {
index dde2d05..e2e33ea 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-21  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/19208
+       * g++.dg/template/array11.C: New test.
+
 2005-01-20  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * gfortran.dg/data_char_1.f90: Fix typo, add dg-do directive.
diff --git a/gcc/testsuite/g++.dg/template/array11.C b/gcc/testsuite/g++.dg/template/array11.C
new file mode 100644 (file)
index 0000000..259c9fa
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
+// PR c++/19208: Fold dependent array domains
+
+template <class C> struct if_t { typedef int type; };
+template <class T> struct ffff { static const bool value = true; };
+template <class A>
+struct bound_member_action
+{
+  typedef char f[ffff<A>::value ? 1 : 2];
+  template <class CT>
+    bound_member_action(CT i, typename if_t<f>::type g)  {}
+};
+bound_member_action<int> a(0, 1);