From: Mark Mitchell Date: Thu, 31 Oct 2002 00:02:35 +0000 (+0000) Subject: re PR c++/8160 (ICE in build_modify_expr, at cp/typeck.c:5494: Array initialization) X-Git-Tag: releases/gcc-3.2.1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a8ce27bed6caaf486aa9df982ab90879a895199;p=thirdparty%2Fgcc.git re PR c++/8160 (ICE in build_modify_expr, at cp/typeck.c:5494: Array initialization) PR c++/8160 * g++.dg/template/complit1.C: New test. PR c++/8149 * g++.dg/template/typename4.C: Likewise. PR c++/8160 * typeck2.c (process_init_constructor): Call complete_array_type. PR c++/8149 * decl.c (make_typename_type): Issue errors about invalid results. From-SVN: r58662 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dd372fbee1bb..aa6923a16832 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2002-10-30 Mark Mitchell + + PR c++/8160 + * typeck2.c (process_init_constructor): Call complete_array_type. + + PR c++/8149 + * decl.c (make_typename_type): Issue errors about invalid results. + 2002-10-29 Mark Mitchell PR c++/8287 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 613766253f3b..06b081c2831d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5759,6 +5759,12 @@ make_typename_type (context, name, complain) t = lookup_field (context, name, 0, 1); if (t) { + if (TREE_CODE (t) != TYPE_DECL) + { + if (complain & tf_error) + error ("no type named `%#T' in `%#T'", name, context); + return error_mark_node; + } if (DECL_ARTIFICIAL (t) || !(complain & tf_keep_type_decl)) t = TREE_TYPE (t); if (IMPLICIT_TYPENAME_P (t)) diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 3f7a004d3b57..f8e612bf6a87 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -975,6 +975,8 @@ process_init_constructor (type, init, elts) return error_mark_node; result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (members)); + if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == NULL_TREE) + complete_array_type (type, result, /*do_default=*/0); if (init) TREE_HAS_CONSTRUCTOR (result) = TREE_HAS_CONSTRUCTOR (init); if (allconstant) TREE_CONSTANT (result) = 1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4b1531d85f70..22fecac0d347 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2002-10-30 Mark Mitchell + + PR c++/8160 + * g++.dg/template/complit1.C: New test. + + PR c++/8149 + * g++.dg/template/typename4.C: Likewise. + 2002-10-29 Mark Mitchell PR c++/8287 diff --git a/gcc/testsuite/g++.dg/template/complit1.C b/gcc/testsuite/g++.dg/template/complit1.C new file mode 100644 index 000000000000..ab057b3b7ee8 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/complit1.C @@ -0,0 +1,11 @@ +// { dg-options "" } + +template struct C { + int d[3]; + C(); +}; + +template +C::C() : d((int[]){1,2,3}) {}; + +template class C<1>; diff --git a/gcc/testsuite/g++.dg/template/typename4.C b/gcc/testsuite/g++.dg/template/typename4.C new file mode 100644 index 000000000000..add95156cec2 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typename4.C @@ -0,0 +1,3 @@ +struct B { template struct C; }; +template struct A { typedef typename T::C V; }; // { dg-error "" } +void f () { A::V p; } // { dg-error "" }