diff options
author | Mark Mitchell <mark@codesourcery.com> | 2002-12-01 20:46:08 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2002-12-01 20:46:08 +0000 |
commit | 94fc547cecfe31473d5db4dec66e4be9f0a797f4 (patch) | |
tree | 9d31a0fdd8168751516c3447f11d0dac0956f113 | |
parent | a82d6da5fcc41ade40261bca65c7717686c1ac9f (diff) | |
download | gcc-94fc547cecfe31473d5db4dec66e4be9f0a797f4.zip gcc-94fc547cecfe31473d5db4dec66e4be9f0a797f4.tar.gz gcc-94fc547cecfe31473d5db4dec66e4be9f0a797f4.tar.bz2 |
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: r59698
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/varmod1.C | 10 |
4 files changed, 27 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8c78480..da4f597 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2002-12-01 Mark Mitchell <mark@codesourcery.com> + PR c++/5919 + * pt.c (unify): Use variably_modified_type_p to test validity of + template argument types. + PR c++/8727 * cp-tree.h (lang_type_class): Add typeinfo_var. (CLASSTYPE_TYPEINFO_VAR): New macro. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 77b2fd9..9f1a382 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8852,21 +8852,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 844d592..0d87d1e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2002-12-01 Mark Mitchell <mark@codesourcery.com> + PR c++/5919 + * g++.dg/template/varmod1.C: New test. + PR c++/8727 * g++.dg/inherit/typeinfo1.C: New test. diff --git a/gcc/testsuite/g++.dg/template/varmod1.C b/gcc/testsuite/g++.dg/template/varmod1.C new file mode 100644 index 0000000..21fdcb6 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/varmod1.C @@ -0,0 +1,10 @@ +// { dg-options "-w" } + +template<typename T> void foo(T); + +void bar() +{ + int i; + int A[i][i]; + foo(A); // { dg-error } +} |