From: Giovanni Bajo Date: Mon, 25 Jul 2005 21:13:18 +0000 (+0000) Subject: re PR c++/19208 (Spurious error about variably modified type) X-Git-Tag: releases/gcc-3.4.5~310 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae437c1680c8e879a260592207da6a3395b04d53;p=thirdparty%2Fgcc.git re PR c++/19208 (Spurious error about variably modified type) cp/ PR c++/19208 * pt.c (tsubst): Use fold_non_dependent_expr to fold array domains. testsuite/ PR c++/19208 * g++.dg/template/array11.C: New test. From-SVN: r102370 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index caaefb9fd0db..676dbcc2d08d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2005-07-25 Giovanni Bajo + + PR c++/19208 + * pt.c (tsubst): Use fold_non_dependent_expr to fold array domains. + 2005-06-14 Mark Mitchell PR c++/21987 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ac0f8ceae288..c61b26b4134e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6720,8 +6720,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 = decl_constant_value (max); + max = fold_non_dependent_expr (max); if (integer_zerop (omax)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 15e86a758579..7233b8c65a98 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-07-25 Giovanni Bajo + + PR c++/19208 + * g++.dg/template/array11.C: New test. + 2005-07-21 Janis Johnson PR target/20191 diff --git a/gcc/testsuite/g++.dg/template/array11.C b/gcc/testsuite/g++.dg/template/array11.C index 259c9fabc036..cac087aece55 100644 --- a/gcc/testsuite/g++.dg/template/array11.C +++ b/gcc/testsuite/g++.dg/template/array11.C @@ -1,14 +1,17 @@ -// { 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); +// { dg-do compile } +// Origin: Giovanni Bajo +// PR c++/19208: Fold dependent array domains + +template struct if_t { typedef int type; }; +template struct hhhh { static const bool value = true; }; +template struct gggg { static const bool value = hhhh::value; }; +template struct ffff { static const bool value = gggg::value; }; +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);