Patchwork PATCH to gimplify_decl_expr for handling of undeclared anonymous variables

login
register
mail settings
Submitter Jason Merrill
Date Oct. 27, 2010, 3:33 p.m.
Message ID <4CC84630.20600@redhat.com>
Download mbox | patch
Permalink /patch/69365/
State New
Headers show

Comments

Jason Merrill - Oct. 27, 2010, 3:33 p.m.
The code in gimplify_decl_expr for handling temporary variables that 
were generated by a front end but never declared doesn't support 
variables with DECL_INITIAL set, as it tries to process an INIT_EXPR 
with the variable on the LHS before declaring it.  Fixed by reversing 
the order of those two hunks.

Tested x86_64-pc-linux-gnu, applied to trunk.

Patch

commit 7d93fac60a6a161b14cd55773344428424c02e9f
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Oct 26 14:48:56 2010 -0400

    	* gimplify.c (gimplify_decl_expr): Handle anonymous artificial
    	variables sooner.

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 542c223..87b57f0 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1372,6 +1372,14 @@  gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
 				   STACK_CHECK_MAX_VAR_SIZE) > 0))
 	gimplify_vla_decl (decl, seq_p);
 
+      /* Some front ends do not explicitly declare all anonymous
+	 artificial variables.  We compensate here by declaring the
+	 variables, though it would be better if the front ends would
+	 explicitly declare them.  */
+      if (!DECL_SEEN_IN_BIND_EXPR_P (decl)
+	  && DECL_ARTIFICIAL (decl) && DECL_NAME (decl) == NULL_TREE)
+	gimple_add_tmp_var (decl);
+
       if (init && init != error_mark_node)
 	{
 	  if (!TREE_STATIC (decl))
@@ -1386,14 +1394,6 @@  gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
 	       as they may contain a label address.  */
 	    walk_tree (&init, force_labels_r, NULL, NULL);
 	}
-
-      /* Some front ends do not explicitly declare all anonymous
-	 artificial variables.  We compensate here by declaring the
-	 variables, though it would be better if the front ends would
-	 explicitly declare them.  */
-      if (!DECL_SEEN_IN_BIND_EXPR_P (decl)
-	  && DECL_ARTIFICIAL (decl) && DECL_NAME (decl) == NULL_TREE)
-	gimple_add_tmp_var (decl);
     }
 
   return GS_ALL_DONE;