From: Mark Mitchell Date: Sun, 1 Dec 2002 20:52:55 +0000 (+0000) Subject: re PR c++/5919 (ICE when passing variable array to template function) X-Git-Tag: releases/gcc-3.2.2~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=802ec0c6b30cbfafefb6cce44045fcda9cfcbcaa;p=thirdparty%2Fgcc.git re PR c++/5919 (ICE when passing variable array to template function) PR c++/5919 * g++.dg/template/varmod1.C: New test. PR c++/5919 * pt.c (unify): Use variably_modified_type_p to test validity of template argument types. From-SVN: r59700 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9aee794d4f14..491d6e37b338 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2002-12-01 Mark Mitchell + + PR c++/5919 + * pt.c (unify): Use variably_modified_type_p to test validity of + template argument types. + 2002-12-01 Mark Mitchell PR c++/8727 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b8e95455b577..07137c0870dc 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8789,21 +8789,17 @@ unify (tparms, targs, parm, arg, strict) return 0; else if (targ) return 1; - } - /* Make sure that ARG is not a variable-sized array. (Note that - were talking about variable-sized arrays (like `int[n]'), - rather than arrays of unknown size (like `int[]').) We'll - get very confused by such a type since the bound of the array - will not be computable in an instantiation. Besides, such - types are not allowed in ISO C++, so we can do as we please - here. */ - if (TREE_CODE (arg) == ARRAY_TYPE - && !uses_template_parms (arg) - && TYPE_DOMAIN (arg) - && (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (arg))) - != INTEGER_CST)) - return 1; + /* Make sure that ARG is not a variable-sized array. (Note + that were talking about variable-sized arrays (like + `int[n]'), rather than arrays of unknown size (like + `int[]').) We'll get very confused by such a type since + the bound of the array will not be computable in an + instantiation. Besides, such types are not allowed in + ISO C++, so we can do as we please here. */ + if (variably_modified_type_p (arg)) + return 1; + } TREE_VEC_ELT (targs, idx) = arg; return 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9ce6bf1bfcc9..e5183a06b3e8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-12-01 Mark Mitchell + + PR c++/5919 + * g++.dg/template/varmod1.C: New test. + 2002-12-01 Mark Mitchell PR c++/8727