This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PRs 8149 and 8160
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 30 Oct 2002 15:56:16 -0800
- Subject: C++ PATCH: PRs 8149 and 8160
- Reply-to: mark at codesourcery dot com
This patch fixes PRs 8149 and PRs8160, high-priority C++ ICEs.
Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2002-10-30 Mark Mitchell <mark@codesourcery.com>
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-30 Mark Mitchell <mark@codesourcery.com>
PR c++/8160
* g++.dg/template/complit1.C: New test.
PR c++/8149
* g++.dg/template/typename4.C: Likewise.
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.866.2.36.2.11
diff -c -p -r1.866.2.36.2.11 decl.c
*** cp/decl.c 29 Oct 2002 23:51:09 -0000 1.866.2.36.2.11
--- cp/decl.c 30 Oct 2002 23:58:21 -0000
*************** make_typename_type (context, name, compl
*** 5759,5764 ****
--- 5759,5770 ----
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))
Index: cp/typeck2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck2.c,v
retrieving revision 1.117.2.2.2.1
diff -c -p -r1.117.2.2.2.1 typeck2.c
*** cp/typeck2.c 25 Oct 2002 15:20:30 -0000 1.117.2.2.2.1
--- cp/typeck2.c 30 Oct 2002 23:58:25 -0000
*************** process_init_constructor (type, init, el
*** 975,980 ****
--- 975,982 ----
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;
Index: testsuite/g++.dg/template/complit1.C
===================================================================
RCS file: testsuite/g++.dg/template/complit1.C
diff -N testsuite/g++.dg/template/complit1.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/complit1.C 30 Oct 2002 23:58:25 -0000
***************
*** 0 ****
--- 1,11 ----
+ // { dg-options "" }
+
+ template <int D> struct C {
+ int d[3];
+ C();
+ };
+
+ template<int D>
+ C<D>::C() : d((int[]){1,2,3}) {};
+
+ template class C<1>;
Index: testsuite/g++.dg/template/typename4.C
===================================================================
RCS file: testsuite/g++.dg/template/typename4.C
diff -N testsuite/g++.dg/template/typename4.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/typename4.C 30 Oct 2002 23:58:25 -0000
***************
*** 0 ****
--- 1,3 ----
+ struct B { template <typename U> struct C; };
+ template <typename T> struct A { typedef typename T::C V; }; // { dg-error "" }
+ void f () { A<B>::V p; } // { dg-error "" }