This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tuples] wrap body in a GIMPLE_BIND correctly


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]