From 2855a5671ff789bbffc7ad9c4a01a8d7d2d2d6e6 Mon Sep 17 00:00:00 2001 From: giovannibajo Date: Fri, 21 Jan 2005 02:27:16 +0000 Subject: [PATCH] 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. 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 | 8 ++++++++ gcc/cp/pt.c | 11 +++++------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/array11.C | 14 ++++++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/array11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4ac2035..9d10f68 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2005-01-21 Giovanni Bajo + + 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 * typeck.c (more_qualified_p): Remove. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 72d4528..8233da9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dde2d05..e2e33ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-01-21 Giovanni Bajo + + PR c++/19208 + * g++.dg/template/array11.C: New test. + 2005-01-20 Tobias Schl"uter * 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 index 0000000..259c9fa --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array11.C @@ -0,0 +1,14 @@ +// { dg-do compile } +// Origin: Giovanni Bajo +// PR c++/19208: Fold dependent array domains + +template struct if_t { typedef int type; }; +template struct ffff { static const bool value = true; }; +template +struct bound_member_action +{ + typedef char f[ffff::value ? 1 : 2]; + template + bound_member_action(CT i, typename if_t::type g) {} +}; +bound_member_action a(0, 1); -- 2.7.4