This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 10635
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 12 Jun 2003 10:26:58 -0700
- Subject: C++ PATCH: PR 10635
- Reply-to: mark at codesourcery dot com
This patch fixes PR c++/10635, an ICE-on-illegal regression.
Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2003-06-12 Mark Mitchell <mark@codesourcery.com>
PR c++/10635
* typeck.c (build_c_cast): Check that the destination type is
complete.
2003-06-12 Mark Mitchell <mark@codesourcery.com>
PR c++/10635
* g++.dg/expr/cast1.C: New test.
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.463
diff -c -5 -p -r1.463 typeck.c
*** cp/typeck.c 19 May 2003 19:19:45 -0000 1.463
--- cp/typeck.c 12 Jun 2003 17:15:53 -0000
*************** build_c_cast (type, expr)
*** 5187,5196 ****
--- 5187,5200 ----
* pointer, array to pointer and lvalue to rvalue decays. */
value = convert_to_void (value, /*implicit=*/NULL);
return value;
}
+
+ if (!complete_type_or_else (type, NULL_TREE))
+ return error_mark_node;
+
/* Convert functions and arrays to pointers and
convert references to their expanded types,
but don't convert any other types. If, however, we are
casting to a class type, there's no reason to do this: the
cast will only succeed if there is a converting constructor,
Index: testsuite/g++.dg/expr/cast1.C
===================================================================
RCS file: testsuite/g++.dg/expr/cast1.C
diff -N testsuite/g++.dg/expr/cast1.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/expr/cast1.C 12 Jun 2003 17:15:54 -0000
***************
*** 0 ****
--- 1,3 ----
+ struct S; // { dg-error "forward" }
+
+ void f(S* p) { ((S) (*p)); } // { dg-error "" }