This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR c++/17554, ice in create_tmp_var, cleanup_expr
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 5 Oct 2004 10:45:42 -0400
- Subject: [PATCH] PR c++/17554, ice in create_tmp_var, cleanup_expr
- References: <BD67D0DC-1685-11D9-B1A5-000A95D692F4@physics.uc.edu>
On Oct 5, 2004, at 12:19 AM, Andrew Pinski wrote:
I don't know if this is the right fix but it works for this testcase.
But should the cleanup point expression have the same type as what is
containing it or not? If have it set to the same as the expression
which contains, we ICE in create_tmp_var as we are creating a temporary
variable for struct which we cannot do.
Here is a patch which is safer and only changes the type to void if
the type was an aggregate before.
OK? Bootstrapped and tested on powerpc-darwin with no regressions
Thanks,
Andrew Pinski
Testcase:
struct A { int i; A(); A(const A&); };
void bar()
{
A a;
for ( ;; a=A() ) ;
}
ChangeLog:
* semantics.c (maybe_cleanup_point_expr): Set the type of the
cleanup point expression to void type if we have an aggregate
type.
Index: semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.441
diff -u -p -r1.441 semantics.c
--- semantics.c 1 Oct 2004 15:11:21 -0000 1.441
+++ semantics.c 5 Oct 2004 14:44:23 -0000
@@ -358,7 +358,12 @@ static tree
maybe_cleanup_point_expr (tree expr)
{
if (!processing_template_decl && stmts_are_full_exprs_p ())
- expr = build1 (CLEANUP_POINT_EXPR, TREE_TYPE (expr), expr);
+ {
+ tree type = TREE_TYPE (expr);
+ if (AGGREGATE_TYPE_P (type))
+ type = void_type_node;
+ expr = build1 (CLEANUP_POINT_EXPR, type, fold (expr));
+ }
return expr;
}