* [tuples] wrap body in a GIMPLE_BIND correctly
@ 2007-10-28 11:20 Aldy Hernandez
0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2007-10-28 11:20 UTC (permalink / raw)
To: dnovillo, gcc-patches; +Cc: jason
Hi folks.
[Jason/Diego: This addresses the problem I brought up with C++ returning
a BIND followed by multiple statements. I was assigning blame
incorrectly. This is the correct fix.]
The consumers of gimplify_body expect one and only one statement, a
GIMPLE_BIND. The C++ FE will sometimes have a BIND_EXPR as the first
statement, which will end up as a GIMPLE_BIND followed by other
statements. Gimplify_body was getting confused and throwing away the
rest of the statements after the GIMPLE_BIND.
This patch will wrap the above case in a GIMPLE_BIND, as the mainline
gimplifier does. With it, we can now gimplify simple C++ programs
containing try.
Tested on x86-64 and committed to branch.
* gimplify.c (gimplify_body): Make work when body contains more than
a GIMPLE_BIND statement.
Index: gimplify.c
===================================================================
--- gimplify.c (revision 129675)
+++ gimplify.c (working copy)
@@ -6691,8 +6691,12 @@ gimplify_body (tree *body_p, tree fndecl
gimple_seq_add (&seq, outer_bind);
}
- /* If there isn't an outer GIMPLE_BIND, add one. */
- if (gimple_code (outer_bind) != GIMPLE_BIND)
+ /* The body must contain exactly one statement, a GIMPLE_BIND. If this is
+ not the case, wrap everything in a GIMPLE_BIND to make it so. */
+ if (gimple_code (outer_bind) == GIMPLE_BIND
+ && gimple_seq_first (&seq) == gimple_seq_last (&seq))
+ ;
+ else
outer_bind = gimple_build_bind (NULL_TREE, &seq);
*body_p = NULL_TREE;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-10-28 8:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-28 11:20 [tuples] wrap body in a GIMPLE_BIND correctly Aldy Hernandez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).