OSDN Git Service

PR c++/25492
[pf3gnuchains/gcc-fork.git] / gcc / gimplify.c
index 156e567..8783dc6 100644 (file)
@@ -236,7 +236,7 @@ append_to_statement_list_1 (tree t, tree *list_p)
   tsi_link_after (&i, t, TSI_CONTINUE_LINKING);
 }
 
-/* Add T to the end of the list container pointed by LIST_P.
+/* Add T to the end of the list container pointed to by LIST_P.
    If T is an expression with no effects, it is ignored.  */
 
 void
@@ -298,6 +298,48 @@ create_artificial_label (void)
   return lab;
 }
 
+/* Subroutine for find_single_pointer_decl.  */
+
+static tree
+find_single_pointer_decl_1 (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
+                           void *data)
+{
+  tree *pdecl = (tree *) data;
+
+  if (DECL_P (*tp) && POINTER_TYPE_P (TREE_TYPE (*tp)))
+    {
+      if (*pdecl)
+       {
+         /* We already found a pointer decl; return anything other
+            than NULL_TREE to unwind from walk_tree signalling that
+            we have a duplicate.  */
+         return *tp;
+       }
+      *pdecl = *tp;
+    }
+
+  return NULL_TREE;
+}
+
+/* Find the single DECL of pointer type in the tree T and return it.
+   If there are zero or more than one such DECLs, return NULL.  */
+
+static tree
+find_single_pointer_decl (tree t)
+{
+  tree decl = NULL_TREE;
+
+  if (walk_tree (&t, find_single_pointer_decl_1, &decl, NULL))
+    {
+      /* find_single_pointer_decl_1 returns a non-zero value, causing
+        walk_tree to return a non-zero value, to indicate that it
+        found more than one pointer DECL.  */
+      return NULL_TREE;
+    }
+
+  return decl;
+}
+
 /* Create a new temporary name with PREFIX.  Returns an identifier.  */
 
 static GTY(()) unsigned int tmp_var_id_num;
@@ -404,7 +446,7 @@ get_name (tree t)
 static inline tree
 create_tmp_from_val (tree val)
 {
-  return create_tmp_var (TREE_TYPE (val), get_name (val));
+  return create_tmp_var (TYPE_MAIN_VARIANT (TREE_TYPE (val)), get_name (val));
 }
 
 /* Create a temporary to hold the value of VAL.  If IS_FORMAL, try to reuse
@@ -431,7 +473,7 @@ lookup_tmp_var (tree val, bool is_formal)
       slot = htab_find_slot (gimplify_ctxp->temp_htab, (void *)&elt, INSERT);
       if (*slot == NULL)
        {
-         elt_p = xmalloc (sizeof (*elt_p));
+         elt_p = XNEW (elt_t);
          elt_p->val = val;
          elt_p->temp = ret = create_tmp_from_val (val);
          *slot = (void *) elt_p;
@@ -470,10 +512,28 @@ internal_get_tmp_var (tree val, tree *pre_p, tree *post_p, bool is_formal)
 
   t = lookup_tmp_var (val, is_formal);
 
+  if (is_formal)
+    {
+      tree u = find_single_pointer_decl (val);
+
+      if (u && TREE_CODE (u) == VAR_DECL && DECL_BASED_ON_RESTRICT_P (u))
+       u = DECL_GET_RESTRICT_BASE (u);
+      if (u && TYPE_RESTRICT (TREE_TYPE (u)))
+       {
+         if (DECL_BASED_ON_RESTRICT_P (t))
+           gcc_assert (u == DECL_GET_RESTRICT_BASE (t));
+         else
+           {
+             DECL_BASED_ON_RESTRICT_P (t) = 1;
+             SET_DECL_RESTRICT_BASE (t, u);
+           }
+       }
+    }
+
   if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)
     DECL_COMPLEX_GIMPLE_REG_P (t) = 1;
 
-  mod = build (MODIFY_EXPR, TREE_TYPE (t), t, val);
+  mod = build2 (MODIFY_EXPR, TREE_TYPE (t), t, val);
 
   if (EXPR_HAS_LOCATION (val))
     SET_EXPR_LOCUS (mod, EXPR_LOCUS (val));
@@ -736,10 +796,10 @@ gimple_build_eh_filter (tree body, tree allowed, tree failure)
   tree t;
 
   /* FIXME should the allowed types go in TREE_TYPE?  */
-  t = build (EH_FILTER_EXPR, void_type_node, allowed, NULL_TREE);
+  t = build2 (EH_FILTER_EXPR, void_type_node, allowed, NULL_TREE);
   append_to_statement_list (failure, &EH_FILTER_FAILURE (t));
 
-  t = build (TRY_CATCH_EXPR, void_type_node, NULL_TREE, t);
+  t = build2 (TRY_CATCH_EXPR, void_type_node, NULL_TREE, t);
   append_to_statement_list (body, &TREE_OPERAND (t, 0));
 
   return t;
@@ -806,7 +866,7 @@ voidify_wrapper_expr (tree wrapper, tree temp)
        {
          tree ptr = TREE_OPERAND (*p, 0);
          temp = create_tmp_var (TREE_TYPE (ptr), "retval");
-         *p = build (MODIFY_EXPR, TREE_TYPE (ptr), temp, ptr);
+         *p = build2 (MODIFY_EXPR, TREE_TYPE (ptr), temp, ptr);
          temp = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (temp)), temp);
          /* If this is a BIND_EXPR for a const inline function, it might not
             have TREE_SIDE_EFFECTS set.  That is no longer accurate.  */
@@ -816,7 +876,7 @@ voidify_wrapper_expr (tree wrapper, tree temp)
        {
          if (!temp)
            temp = create_tmp_var (TREE_TYPE (wrapper), "retval");
-         *p = build (MODIFY_EXPR, TREE_TYPE (temp), temp, *p);
+         *p = build2 (MODIFY_EXPR, TREE_TYPE (temp), temp, *p);
          TREE_SIDE_EFFECTS (wrapper) = 1;
        }
 
@@ -840,7 +900,7 @@ build_stack_save_restore (tree *save, tree *restore)
                                NULL_TREE);
   tmp_var = create_tmp_var (ptr_type_node, "saved_stack");
 
-  *save = build (MODIFY_EXPR, ptr_type_node, tmp_var, save_call);
+  *save = build2 (MODIFY_EXPR, ptr_type_node, tmp_var, save_call);
   *restore =
     build_function_call_expr (implicit_built_in_decls[BUILT_IN_STACK_RESTORE],
                              tree_cons (NULL_TREE, tmp_var, NULL_TREE));
@@ -860,7 +920,8 @@ gimplify_bind_expr (tree *expr_p, tree temp, tree *pre_p)
   /* Mark variables seen in this bind expr.  */
   for (t = BIND_EXPR_VARS (bind_expr); t ; t = TREE_CHAIN (t))
     {
-      DECL_SEEN_IN_BIND_EXPR_P (t) = 1;
+      if (TREE_CODE (t) == VAR_DECL)
+       DECL_SEEN_IN_BIND_EXPR_P (t) = 1;
 
       /* Preliminarily mark non-addressed complex variables as eligible
         for promotion to gimple registers.  We'll transform their uses
@@ -886,8 +947,8 @@ gimplify_bind_expr (tree *expr_p, tree temp, tree *pre_p)
         format of the emitted code: see mx_register_decls().  */
       build_stack_save_restore (&stack_save, &stack_restore);
 
-      t = build (TRY_FINALLY_EXPR, void_type_node,
-                BIND_EXPR_BODY (bind_expr), NULL_TREE);
+      t = build2 (TRY_FINALLY_EXPR, void_type_node,
+                 BIND_EXPR_BODY (bind_expr), NULL_TREE);
       append_to_statement_list (stack_restore, &TREE_OPERAND (t, 1));
 
       BIND_EXPR_BODY (bind_expr) = NULL_TREE;
@@ -977,7 +1038,7 @@ gimplify_return_expr (tree stmt, tree *pre_p)
   if (result == result_decl)
     ret_expr = result;
   else
-    ret_expr = build (MODIFY_EXPR, TREE_TYPE (result), result_decl, result);
+    ret_expr = build2 (MODIFY_EXPR, TREE_TYPE (result), result_decl, result);
   TREE_OPERAND (stmt, 0) = ret_expr;
 
   return GS_ALL_DONE;
@@ -1046,7 +1107,7 @@ gimplify_decl_expr (tree *stmt_p)
          if (!TREE_STATIC (decl))
            {
              DECL_INITIAL (decl) = NULL_TREE;
-             init = build (MODIFY_EXPR, void_type_node, decl, init);
+             init = build2 (MODIFY_EXPR, void_type_node, decl, init);
              gimplify_and_add (init, stmt_p);
            }
          else
@@ -1192,11 +1253,11 @@ gimplify_switch_expr (tree *expr_p, tree *pre_p)
        {
          /* If the switch has no default label, add one, so that we jump
             around the switch body.  */
-         default_case = build (CASE_LABEL_EXPR, void_type_node, NULL_TREE,
-                               NULL_TREE, create_artificial_label ());
+         default_case = build3 (CASE_LABEL_EXPR, void_type_node, NULL_TREE,
+                                NULL_TREE, create_artificial_label ());
          append_to_statement_list (SWITCH_BODY (switch_expr), pre_p);
-         *expr_p = build (LABEL_EXPR, void_type_node,
-                          CASE_LABEL (default_case));
+         *expr_p = build1 (LABEL_EXPR, void_type_node,
+                           CASE_LABEL (default_case));
        }
       else
        *expr_p = SWITCH_BODY (switch_expr);
@@ -1224,7 +1285,7 @@ gimplify_case_label_expr (tree *expr_p)
 
   gcc_assert (gimplify_ctxp->case_labels);
   VEC_safe_push (tree, heap, gimplify_ctxp->case_labels, expr);
-  *expr_p = build (LABEL_EXPR, void_type_node, CASE_LABEL (expr));
+  *expr_p = build1 (LABEL_EXPR, void_type_node, CASE_LABEL (expr));
   return GS_ALL_DONE;
 }
 
@@ -1258,7 +1319,7 @@ gimplify_exit_expr (tree *expr_p)
   tree expr;
 
   expr = build_and_jump (&gimplify_ctxp->exit_label);
-  expr = build (COND_EXPR, void_type_node, cond, expr, NULL_TREE);
+  expr = build3 (COND_EXPR, void_type_node, cond, expr, NULL_TREE);
   *expr_p = expr;
 
   return GS_OK;
@@ -1407,8 +1468,42 @@ gimplify_conversion (tree *expr_p)
   return GS_OK;
 }
 
+/* Gimplify a VAR_DECL or PARM_DECL.  Returns GS_OK if we expanded a 
+   DECL_VALUE_EXPR, and it's worth re-examining things.  */
+
+static enum gimplify_status
+gimplify_var_or_parm_decl (tree *expr_p)
+{
+  tree decl = *expr_p;
+
+  /* ??? If this is a local variable, and it has not been seen in any
+     outer BIND_EXPR, then it's probably the result of a duplicate
+     declaration, for which we've already issued an error.  It would
+     be really nice if the front end wouldn't leak these at all.
+     Currently the only known culprit is C++ destructors, as seen
+     in g++.old-deja/g++.jason/binding.C.  */
+  if (TREE_CODE (decl) == VAR_DECL
+      && !DECL_SEEN_IN_BIND_EXPR_P (decl)
+      && !TREE_STATIC (decl) && !DECL_EXTERNAL (decl)
+      && decl_function_context (decl) == current_function_decl)
+    {
+      gcc_assert (errorcount || sorrycount);
+      return GS_ERROR;
+    }
+
+  /* If the decl is an alias for another expression, substitute it now.  */
+  if (DECL_HAS_VALUE_EXPR_P (decl))
+    {
+      *expr_p = unshare_expr (DECL_VALUE_EXPR (decl));
+      return GS_OK;
+    }
+
+  return GS_ALL_DONE;
+}
+
+
 /* Gimplify the COMPONENT_REF, ARRAY_REF, REALPART_EXPR or IMAGPART_EXPR
-   node pointed by EXPR_P.
+   node pointed to by EXPR_P.
 
       compound_lval
              : min_lval '[' val ']'
@@ -1445,11 +1540,21 @@ gimplify_compound_lval (tree *expr_p, tree *pre_p,
   /* We can handle anything that get_inner_reference can deal with.  */
   for (p = expr_p; ; p = &TREE_OPERAND (*p, 0))
     {
+    restart:
       /* Fold INDIRECT_REFs now to turn them into ARRAY_REFs.  */
       if (TREE_CODE (*p) == INDIRECT_REF)
        *p = fold_indirect_ref (*p);
-      if (!handled_component_p (*p))
+
+      if (handled_component_p (*p))
+       ;
+      /* Expand DECL_VALUE_EXPR now.  In some cases that may expose
+        additional COMPONENT_REFs.  */
+      else if ((TREE_CODE (*p) == VAR_DECL || TREE_CODE (*p) == PARM_DECL)
+              && gimplify_var_or_parm_decl (p) == GS_OK)
+       goto restart;
+      else
        break;
+              
       VEC_safe_push (tree, heap, stack, *p);
     }
 
@@ -1531,8 +1636,11 @@ gimplify_compound_lval (tree *expr_p, tree *pre_p,
        }
     }
 
-  /* Step 2 is to gimplify the base expression.  */
-  tret = gimplify_expr (p, pre_p, post_p, is_gimple_min_lval, fallback);
+  /* Step 2 is to gimplify the base expression.  Make sure lvalue is set
+     so as to match the min_lval predicate.  Failure to do so may result
+     in the creation of large aggregate temporaries.  */
+  tret = gimplify_expr (p, pre_p, post_p, is_gimple_min_lval,
+                       fallback | fb_lvalue);
   ret = MIN (ret, tret);
 
   /* And finally, the indices and operands to BIT_FIELD_REF.  During this
@@ -1592,7 +1700,8 @@ gimplify_compound_lval (tree *expr_p, tree *pre_p,
   return ret;
 }
 
-/*  Gimplify the self modifying expression pointed by EXPR_P (++, --, +=, -=).
+/*  Gimplify the self modifying expression pointed to by EXPR_P
+    (++, --, +=, -=).
 
     PRE_P points to the list where side effects that must happen before
        *EXPR_P should be stored.
@@ -1650,8 +1759,8 @@ gimplify_self_mod_expr (tree *expr_p, tree *pre_p, tree *post_p,
        return ret;
     }
 
-  t1 = build (arith_code, TREE_TYPE (*expr_p), lhs, rhs);
-  t1 = build (MODIFY_EXPR, TREE_TYPE (lvalue), lvalue, t1);
+  t1 = build2 (arith_code, TREE_TYPE (*expr_p), lhs, rhs);
+  t1 = build2 (MODIFY_EXPR, TREE_TYPE (lvalue), lvalue, t1);
 
   if (postfix)
     {
@@ -1720,7 +1829,7 @@ gimplify_arg (tree *expr_p, tree *pre_p)
   return gimplify_expr (expr_p, pre_p, NULL, test, fb);
 }
 
-/* Gimplify the CALL_EXPR node pointed by EXPR_P.  PRE_P points to the
+/* Gimplify the CALL_EXPR node pointed to by EXPR_P.  PRE_P points to the
    list where side effects that must happen before *EXPR_P should be stored.
    WANT_VALUE is true if the result of the call is desired.  */
 
@@ -1898,17 +2007,17 @@ shortcut_cond_r (tree pred, tree *true_label_p, tree *false_label_p)
           if (b) goto yes; else goto no;
         else
           if (c) goto yes; else goto no;  */
-      expr = build (COND_EXPR, void_type_node, TREE_OPERAND (pred, 0),
-                   shortcut_cond_r (TREE_OPERAND (pred, 1), true_label_p,
-                                    false_label_p),
-                   shortcut_cond_r (TREE_OPERAND (pred, 2), true_label_p,
-                                    false_label_p));
+      expr = build3 (COND_EXPR, void_type_node, TREE_OPERAND (pred, 0),
+                    shortcut_cond_r (TREE_OPERAND (pred, 1), true_label_p,
+                                     false_label_p),
+                    shortcut_cond_r (TREE_OPERAND (pred, 2), true_label_p,
+                                     false_label_p));
     }
   else
     {
-      expr = build (COND_EXPR, void_type_node, pred,
-                   build_and_jump (true_label_p),
-                   build_and_jump (false_label_p));
+      expr = build3 (COND_EXPR, void_type_node, pred,
+                    build_and_jump (true_label_p),
+                    build_and_jump (false_label_p));
     }
 
   if (local_label)
@@ -1943,7 +2052,7 @@ shortcut_cond_expr (tree expr)
          then_ = shortcut_cond_expr (expr);
          then_se = then_ && TREE_SIDE_EFFECTS (then_);
          pred = TREE_OPERAND (pred, 0);
-         expr = build (COND_EXPR, void_type_node, pred, then_, NULL_TREE);
+         expr = build3 (COND_EXPR, void_type_node, pred, then_, NULL_TREE);
        }
     }
   if (!then_se)
@@ -1958,7 +2067,7 @@ shortcut_cond_expr (tree expr)
          else_ = shortcut_cond_expr (expr);
          else_se = else_ && TREE_SIDE_EFFECTS (else_);
          pred = TREE_OPERAND (pred, 0);
-         expr = build (COND_EXPR, void_type_node, pred, NULL_TREE, else_);
+         expr = build3 (COND_EXPR, void_type_node, pred, NULL_TREE, else_);
        }
     }
 
@@ -2110,7 +2219,7 @@ gimple_boolify (tree expr)
     }
 }
 
-/*  Convert the conditional expression pointed by EXPR_P '(p) ? a : b;'
+/*  Convert the conditional expression pointed to by EXPR_P '(p) ? a : b;'
     into
 
     if (p)                     if (p)
@@ -2173,8 +2282,8 @@ gimplify_cond_expr (tree *expr_p, tree *pre_p, tree *post_p, tree target,
          
          tmp2 = tmp = create_tmp_var (type, "iftmp");
 
-         expr = build (COND_EXPR, void_type_node, TREE_OPERAND (expr, 0),
-                       TREE_OPERAND (expr, 1), TREE_OPERAND (expr, 2));
+         expr = build3 (COND_EXPR, void_type_node, TREE_OPERAND (expr, 0),
+                        TREE_OPERAND (expr, 1), TREE_OPERAND (expr, 2));
 
          result = build_fold_indirect_ref (tmp);
          ret = GS_ALL_DONE;
@@ -2184,12 +2293,12 @@ gimplify_cond_expr (tree *expr_p, tree *pre_p, tree *post_p, tree target,
         if this branch is void; in C++ it can be, if it's a throw.  */
       if (TREE_TYPE (TREE_OPERAND (expr, 1)) != void_type_node)
        TREE_OPERAND (expr, 1)
-         = build (MODIFY_EXPR, void_type_node, tmp, TREE_OPERAND (expr, 1));
+         = build2 (MODIFY_EXPR, void_type_node, tmp, TREE_OPERAND (expr, 1));
 
       /* Build the else clause, 't1 = b;'.  */
       if (TREE_TYPE (TREE_OPERAND (expr, 2)) != void_type_node)
        TREE_OPERAND (expr, 2)
-         = build (MODIFY_EXPR, void_type_node, tmp2, TREE_OPERAND (expr, 2));
+         = build2 (MODIFY_EXPR, void_type_node, tmp2, TREE_OPERAND (expr, 2));
 
       TREE_TYPE (expr) = void_type_node;
       recalculate_side_effects (expr);
@@ -2384,9 +2493,12 @@ gimplify_init_ctor_preeval (tree *expr_p, tree *pre_p, tree *post_p,
   /* Recurse for nested constructors.  */
   if (TREE_CODE (*expr_p) == CONSTRUCTOR)
     {
-      tree list;
-      for (list = CONSTRUCTOR_ELTS (*expr_p); list ; list = TREE_CHAIN (list))
-       gimplify_init_ctor_preeval (&TREE_VALUE (list), pre_p, post_p, data);
+      unsigned HOST_WIDE_INT ix;
+      constructor_elt *ce;
+      VEC(constructor_elt,gc) *v = CONSTRUCTOR_ELTS (*expr_p);
+
+      for (ix = 0; VEC_iterate (constructor_elt, v, ix, ce); ix++)
+       gimplify_init_ctor_preeval (&ce->value, pre_p, post_p, data);
       return;
     }
 
@@ -2445,7 +2557,8 @@ gimplify_init_ctor_preeval (tree *expr_p, tree *pre_p, tree *post_p,
    Note that we never have to deal with SAVE_EXPRs here, because this has
    already been taken care of for us, in gimplify_init_ctor_preeval().  */
 
-static void gimplify_init_ctor_eval (tree, tree, tree *, bool);
+static void gimplify_init_ctor_eval (tree, VEC(constructor_elt,gc) *,
+                                    tree *, bool);
 
 static void
 gimplify_init_ctor_eval_range (tree object, tree lower, tree upper,
@@ -2527,26 +2640,37 @@ zero_sized_field_decl (tree fdecl)
   return false;
 }
 
+/* Return true if TYPE is zero sized.  */
+   
+static bool
+zero_sized_type (tree type)
+{
+  if (AGGREGATE_TYPE_P (type) && TYPE_SIZE (type)
+      && integer_zerop (TYPE_SIZE (type)))
+    return true;
+  return false;
+}
+
 /* A subroutine of gimplify_init_constructor.  Generate individual
    MODIFY_EXPRs for a CONSTRUCTOR.  OBJECT is the LHS against which the
-   assignments should happen.  LIST is the CONSTRUCTOR_ELTS of the
+   assignments should happen.  ELTS is the CONSTRUCTOR_ELTS of the
    CONSTRUCTOR.  CLEARED is true if the entire LHS object has been
    zeroed first.  */
 
 static void
-gimplify_init_ctor_eval (tree object, tree list, tree *pre_p, bool cleared)
+gimplify_init_ctor_eval (tree object, VEC(constructor_elt,gc) *elts,
+                        tree *pre_p, bool cleared)
 {
   tree array_elt_type = NULL;
+  unsigned HOST_WIDE_INT ix;
+  tree purpose, value;
 
   if (TREE_CODE (TREE_TYPE (object)) == ARRAY_TYPE)
     array_elt_type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (object)));
 
-  for (; list; list = TREE_CHAIN (list))
+  FOR_EACH_CONSTRUCTOR_ELT (elts, ix, purpose, value)
     {
-      tree purpose, value, cref, init;
-
-      purpose = TREE_PURPOSE (list);
-      value = TREE_VALUE (list);
+      tree cref, init;
 
       /* NULL values are created above for gimplification errors.  */
       if (value == NULL)
@@ -2559,7 +2683,12 @@ gimplify_init_ctor_eval (tree object, tree list, tree *pre_p, bool cleared)
         so we don't have to figure out what's missing ourselves.  */
       gcc_assert (purpose);
 
-      if (zero_sized_field_decl (purpose))
+      /* Skip zero-sized fields, unless value has side-effects.  This can
+        happen with calls to functions returning a zero-sized type, which
+        we shouldn't discard.  As a number of downstream passes don't
+        expect sets of zero-sized fields, we rely on the gimplification of
+        the MODIFY_EXPR we make below to drop the assignment statement.  */
+      if (! TREE_SIDE_EFFECTS (value) && zero_sized_field_decl (purpose))
        continue;
 
       /* If we have a RANGE_EXPR, we have to build a loop to assign the
@@ -2583,19 +2712,23 @@ gimplify_init_ctor_eval (tree object, tree list, tree *pre_p, bool cleared)
 
       if (array_elt_type)
        {
-         cref = build (ARRAY_REF, array_elt_type, unshare_expr (object),
-                       purpose, NULL_TREE, NULL_TREE);
+         cref = build4 (ARRAY_REF, array_elt_type, unshare_expr (object),
+                        purpose, NULL_TREE, NULL_TREE);
        }
       else
-       cref = build (COMPONENT_REF, TREE_TYPE (purpose),
-                     unshare_expr (object), purpose, NULL_TREE);
+       {
+         gcc_assert (TREE_CODE (purpose) == FIELD_DECL);
+         cref = build3 (COMPONENT_REF, TREE_TYPE (purpose),
+                        unshare_expr (object), purpose, NULL_TREE);
+       }
 
-      if (TREE_CODE (value) == CONSTRUCTOR)
+      if (TREE_CODE (value) == CONSTRUCTOR
+         && TREE_CODE (TREE_TYPE (value)) != VECTOR_TYPE)
        gimplify_init_ctor_eval (cref, CONSTRUCTOR_ELTS (value),
                                 pre_p, cleared);
       else
        {
-         init = build (MODIFY_EXPR, TREE_TYPE (cref), cref, value);
+         init = build2 (MODIFY_EXPR, TREE_TYPE (cref), cref, value);
          gimplify_and_add (init, pre_p);
        }
     }
@@ -2616,7 +2749,7 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
   tree ctor = TREE_OPERAND (*expr_p, 1);
   tree type = TREE_TYPE (ctor);
   enum gimplify_status ret;
-  tree elt_list;
+  VEC(constructor_elt,gc) *elts;
 
   if (TREE_CODE (ctor) != CONSTRUCTOR)
     return GS_UNHANDLED;
@@ -2627,7 +2760,7 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
     return ret;
   object = TREE_OPERAND (*expr_p, 0);
 
-  elt_list = CONSTRUCTOR_ELTS (ctor);
+  elts = CONSTRUCTOR_ELTS (ctor);
 
   ret = GS_ALL_DONE;
   switch (TREE_CODE (type))
@@ -2645,7 +2778,7 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
        /* Aggregate types must lower constructors to initialization of
           individual elements.  The exception is that a CONSTRUCTOR node
           with no elements indicates zero-initialization of the whole.  */
-       if (elt_list == NULL)
+       if (VEC_empty (constructor_elt, elts))
          break;
 
        categorize_ctor_elements (ctor, &num_nonzero_elements,
@@ -2685,13 +2818,18 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
           parts in, then generate code for the non-constant parts.  */
        /* TODO.  There's code in cp/typeck.c to do this.  */
 
-       num_type_elements = count_type_elements (TREE_TYPE (ctor));
+       num_type_elements = count_type_elements (type, true);
 
+       /* If count_type_elements could not determine number of type elements
+          for a constant-sized object, assume clearing is needed.
+          Don't do this for variable-sized objects, as store_constructor
+          will ignore the clearing of variable-sized objects.  */
+       if (num_type_elements < 0 && int_size_in_bytes (type) >= 0)
+         cleared = true;
        /* If there are "lots" of zeros, then block clear the object first.  */
-       if (num_type_elements - num_nonzero_elements > CLEAR_RATIO
-           && num_nonzero_elements < num_type_elements/4)
+       else if (num_type_elements - num_nonzero_elements > CLEAR_RATIO
+                && num_nonzero_elements < num_type_elements/4)
          cleared = true;
-
        /* ??? This bit ought not be needed.  For any element not present
           in the initializer, we should simply set them to zero.  Except
           we'd need to *find* the elements that are not present, and that
@@ -2757,7 +2895,7 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
            /* Zap the CONSTRUCTOR element list, which simplifies this case.
               Note that we still have to gimplify, in order to handle the
               case of variable sized types.  Avoid shared tree structures.  */
-           CONSTRUCTOR_ELTS (ctor) = NULL_TREE;
+           CONSTRUCTOR_ELTS (ctor) = NULL;
            object = unshare_expr (object);
            gimplify_stmt (expr_p);
            append_to_statement_list (*expr_p, pre_p);
@@ -2775,7 +2913,7 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
 
            gimplify_init_ctor_preeval (&TREE_OPERAND (*expr_p, 1),
                                        pre_p, post_p, &preeval_data);
-           gimplify_init_ctor_eval (object, elt_list, pre_p, cleared);
+           gimplify_init_ctor_eval (object, elts, pre_p, cleared);
          }
 
        *expr_p = NULL_TREE;
@@ -2787,17 +2925,9 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
        tree r, i;
 
        /* Extract the real and imaginary parts out of the ctor.  */
-       r = i = NULL_TREE;
-       if (elt_list)
-         {
-           r = TREE_VALUE (elt_list);
-           elt_list = TREE_CHAIN (elt_list);
-           if (elt_list)
-             {
-               i = TREE_VALUE (elt_list);
-               gcc_assert (!TREE_CHAIN (elt_list));
-             }
-         }
+       gcc_assert (VEC_length (constructor_elt, elts) == 2);
+       r = VEC_index (constructor_elt, elts, 0)->value;
+       i = VEC_index (constructor_elt, elts, 1)->value;
        if (r == NULL || i == NULL)
          {
            tree zero = convert (TREE_TYPE (type), integer_zero_node);
@@ -2816,7 +2946,7 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
          }
        else
          {
-           ctor = build (COMPLEX_EXPR, type, r, i);
+           ctor = build2 (COMPLEX_EXPR, type, r, i);
            TREE_OPERAND (*expr_p, 1) = ctor;
            ret = gimplify_expr (&TREE_OPERAND (*expr_p, 1), pre_p, post_p,
                                 rhs_predicate_for (TREE_OPERAND (*expr_p, 0)),
@@ -2826,35 +2956,44 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p,
       break;
 
     case VECTOR_TYPE:
-      /* Go ahead and simplify constant constructors to VECTOR_CST.  */
-      if (TREE_CONSTANT (ctor))
-       {
-         tree tem;
+      {
+       unsigned HOST_WIDE_INT ix;
+       constructor_elt *ce;
 
-         /* Even when ctor is constant, it might contain non-*_CST
-            elements (e.g. { 1.0/0.0 - 1.0/0.0, 0.0 }) and those don't
-            belong into VECTOR_CST nodes.  */
-         for (tem = elt_list; tem; tem = TREE_CHAIN (tem))
-           if (! CONSTANT_CLASS_P (TREE_VALUE (tem)))
-             break;
+       /* Go ahead and simplify constant constructors to VECTOR_CST.  */
+       if (TREE_CONSTANT (ctor))
+         {
+           bool constant_p = true;
+           tree value;
+
+           /* Even when ctor is constant, it might contain non-*_CST
+             elements (e.g. { 1.0/0.0 - 1.0/0.0, 0.0 }) and those don't
+             belong into VECTOR_CST nodes.  */
+           FOR_EACH_CONSTRUCTOR_VALUE (elts, ix, value)
+             if (!CONSTANT_CLASS_P (value))
+               {
+                 constant_p = false;
+                 break;
+               }
 
-         if (! tem)
-           {
-             TREE_OPERAND (*expr_p, 1) = build_vector (type, elt_list);
-             break;
-           }
-       }
+           if (constant_p)
+             {
+               TREE_OPERAND (*expr_p, 1) = build_vector_from_ctor (type, elts);
+               break;
+             }
+         }
 
-      /* Vector types use CONSTRUCTOR all the way through gimple
-        compilation as a general initializer.  */
-      for (; elt_list; elt_list = TREE_CHAIN (elt_list))
-       {
-         enum gimplify_status tret;
-         tret = gimplify_expr (&TREE_VALUE (elt_list), pre_p, post_p,
-                               is_gimple_val, fb_rvalue);
-         if (tret == GS_ERROR)
-           ret = GS_ERROR;
-       }
+       /* Vector types use CONSTRUCTOR all the way through gimple
+         compilation as a general initializer.  */
+       for (ix = 0; VEC_iterate (constructor_elt, elts, ix, ce); ix++)
+         {
+           enum gimplify_status tret;
+           tret = gimplify_expr (&ce->value, pre_p, post_p,
+                                 is_gimple_val, fb_rvalue);
+           if (tret == GS_ERROR)
+             ret = GS_ERROR;
+         }
+      }
       break;
 
     default:
@@ -2918,9 +3057,10 @@ fold_indirect_ref_rhs (tree t)
     {
       tree type_domain;
       tree min_val = size_zero_node;
+      tree osub = sub;
       sub = fold_indirect_ref_rhs (sub);
       if (! sub)
-       sub = build1 (INDIRECT_REF, TREE_TYPE (subtype), sub);
+       sub = build1 (INDIRECT_REF, TREE_TYPE (subtype), osub);
       type_domain = TYPE_DOMAIN (TREE_TYPE (sub));
       if (type_domain && TYPE_MIN_VALUE (type_domain))
         min_val = TYPE_MIN_VALUE (type_domain);
@@ -3035,7 +3175,8 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, tree *pre_p,
                 When optimizing, the return_slot pass marks more functions
                 as safe after we have escape info.  */
              use_target = false;
-           else if (DECL_GIMPLE_FORMAL_TEMP_P (*to_p))
+           else if (TREE_CODE (*to_p) != PARM_DECL 
+                    && DECL_GIMPLE_FORMAL_TEMP_P (*to_p))
              /* Don't use the original target if it's a formal temp; we
                 don't want to take their addresses.  */
              use_target = false;
@@ -3102,7 +3243,7 @@ gimplify_modify_expr_complex_part (tree *expr_p, tree *pre_p, bool want_value)
   return GS_ALL_DONE;
 }
 
-/* Gimplify the MODIFY_EXPR node pointed by EXPR_P.
+/* Gimplify the MODIFY_EXPR node pointed to by EXPR_P.
 
       modify_expr
              : varname '=' rhs
@@ -3130,6 +3271,18 @@ gimplify_modify_expr (tree *expr_p, tree *pre_p, tree *post_p, bool want_value)
   /* The distinction between MODIFY_EXPR and INIT_EXPR is no longer useful.  */
   if (TREE_CODE (*expr_p) == INIT_EXPR)
     TREE_SET_CODE (*expr_p, MODIFY_EXPR);
+  
+  /* For zero sized types only gimplify the left hand side and right hand side
+     as statements and throw away the assignment.  */
+  if (zero_sized_type (TREE_TYPE (*from_p)))
+    {
+      gimplify_stmt (from_p);
+      gimplify_stmt (to_p);
+      append_to_statement_list (*from_p, pre_p);
+      append_to_statement_list (*to_p, pre_p);
+      *expr_p = NULL_TREE;
+      return GS_ALL_DONE;
+    }
 
   /* See if any simplifications can be done based on what the RHS is.  */
   ret = gimplify_modify_expr_rhs (expr_p, from_p, to_p, pre_p, post_p,
@@ -3224,7 +3377,7 @@ gimplify_variable_sized_compare (tree *expr_p)
   t = implicit_built_in_decls[BUILT_IN_MEMCMP];
   t = build_function_call_expr (t, args);
   *expr_p
-    = build (TREE_CODE (*expr_p), TREE_TYPE (*expr_p), t, integer_zero_node);
+    = build2 (TREE_CODE (*expr_p), TREE_TYPE (*expr_p), t, integer_zero_node);
 
   return GS_OK;
 }
@@ -3247,9 +3400,9 @@ gimplify_boolean_expr (tree *expr_p)
   /* Preserve the original type of the expression.  */
   tree type = TREE_TYPE (*expr_p);
 
-  *expr_p = build (COND_EXPR, type, *expr_p,
-                  convert (type, boolean_true_node),
-                  convert (type, boolean_false_node));
+  *expr_p = build3 (COND_EXPR, type, *expr_p,
+                   convert (type, boolean_true_node),
+                   convert (type, boolean_false_node));
 
   return GS_OK;
 }
@@ -3365,7 +3518,7 @@ gimplify_save_expr (tree *expr_p, tree *pre_p, tree *post_p)
   return ret;
 }
 
-/*  Re-write the ADDR_EXPR node pointed by EXPR_P
+/*  Re-write the ADDR_EXPR node pointed to by EXPR_P
 
       unary_expr
              : ...
@@ -3458,7 +3611,7 @@ gimplify_addr_expr (tree *expr_p, tree *pre_p, tree *post_p)
 
          /* Make sure TREE_INVARIANT, TREE_CONSTANT, and TREE_SIDE_EFFECTS
             is set properly.  */
-         recompute_tree_invarant_for_addr_expr (expr);
+         recompute_tree_invariant_for_addr_expr (expr);
 
          /* Mark the RHS addressable.  */
          lang_hooks.mark_addressable (TREE_OPERAND (expr, 0));
@@ -3552,7 +3705,7 @@ gimplify_asm_expr (tree *expr_p, tree *pre_p, tree *post_p)
                        break;
                    }
 
-                 str = alloca (len);
+                 str = (char *) alloca (len);
                  for (beg = p + 1, dst = str;;)
                    {
                      const char *tem;
@@ -3657,14 +3810,18 @@ gimplify_cleanup_point_expr (tree *expr_p, tree *pre_p)
   tree temp = voidify_wrapper_expr (*expr_p, NULL);
 
   /* We only care about the number of conditions between the innermost
-     CLEANUP_POINT_EXPR and the cleanup.  So save and reset the count.  */
+     CLEANUP_POINT_EXPR and the cleanup.  So save and reset the count and
+     any cleanups collected outside the CLEANUP_POINT_EXPR.  */
   int old_conds = gimplify_ctxp->conditions;
+  tree old_cleanups = gimplify_ctxp->conditional_cleanups;
   gimplify_ctxp->conditions = 0;
+  gimplify_ctxp->conditional_cleanups = NULL_TREE;
 
   body = TREE_OPERAND (*expr_p, 0);
   gimplify_to_stmt_list (&body);
 
   gimplify_ctxp->conditions = old_conds;
+  gimplify_ctxp->conditional_cleanups = old_cleanups;
 
   for (iter = tsi_start (body); !tsi_end_p (iter); )
     {
@@ -3690,7 +3847,7 @@ gimplify_cleanup_point_expr (tree *expr_p, tree *pre_p)
                code = TRY_FINALLY_EXPR;
 
              sl = tsi_split_statement_list_after (&iter);
-             tfe = build (code, void_type_node, sl, NULL_TREE);
+             tfe = build2 (code, void_type_node, sl, NULL_TREE);
              append_to_statement_list (TREE_OPERAND (wce, 0),
                                        &TREE_OPERAND (tfe, 1));
              *wce_p = tfe;
@@ -3751,12 +3908,12 @@ gimple_push_cleanup (tree var, tree cleanup, bool eh_only, tree *pre_p)
       */
 
       tree flag = create_tmp_var (boolean_type_node, "cleanup");
-      tree ffalse = build (MODIFY_EXPR, void_type_node, flag,
-                          boolean_false_node);
-      tree ftrue = build (MODIFY_EXPR, void_type_node, flag,
-                         boolean_true_node);
-      cleanup = build (COND_EXPR, void_type_node, flag, cleanup, NULL);
-      wce = build (WITH_CLEANUP_EXPR, void_type_node, cleanup);
+      tree ffalse = build2 (MODIFY_EXPR, void_type_node, flag,
+                           boolean_false_node);
+      tree ftrue = build2 (MODIFY_EXPR, void_type_node, flag,
+                          boolean_true_node);
+      cleanup = build3 (COND_EXPR, void_type_node, flag, cleanup, NULL);
+      wce = build1 (WITH_CLEANUP_EXPR, void_type_node, cleanup);
       append_to_statement_list (ffalse, &gimplify_ctxp->conditional_cleanups);
       append_to_statement_list (wce, &gimplify_ctxp->conditional_cleanups);
       append_to_statement_list (ftrue, pre_p);
@@ -3768,7 +3925,7 @@ gimple_push_cleanup (tree var, tree cleanup, bool eh_only, tree *pre_p)
     }
   else
     {
-      wce = build (WITH_CLEANUP_EXPR, void_type_node, cleanup);
+      wce = build1 (WITH_CLEANUP_EXPR, void_type_node, cleanup);
       CLEANUP_EH_ONLY (wce) = eh_only;
       append_to_statement_list (wce, pre_p);
     }
@@ -3804,7 +3961,7 @@ gimplify_target_expr (tree *expr_p, tree *pre_p, tree *post_p)
            gimplify_bind_expr (&init, temp, pre_p);
          if (init != temp)
            {
-             init = build (MODIFY_EXPR, void_type_node, temp, init);
+             init = build2 (MODIFY_EXPR, void_type_node, temp, init);
              ret = gimplify_expr (&init, pre_p, post_p, is_gimple_stmt,
                                   fb_none);
            }
@@ -3861,7 +4018,7 @@ gimplify_to_stmt_list (tree *stmt_p)
 }
 
 
-/*  Gimplifies the expression tree pointed by EXPR_P.  Return 0 if
+/*  Gimplifies the expression tree pointed to by EXPR_P.  Return 0 if
     gimplification failed.
 
     PRE_P points to the list where side effects that must happen before
@@ -4157,16 +4314,30 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
             gimplify any element that has side-effects.  */
          if (fallback == fb_none)
            {
-             for (tmp = CONSTRUCTOR_ELTS (*expr_p); tmp;
-                  tmp = TREE_CHAIN (tmp))
-               if (TREE_SIDE_EFFECTS (TREE_VALUE (tmp)))
-                 gimplify_expr (&TREE_VALUE (tmp), pre_p, post_p,
-                                gimple_test_f, fallback);
-
-             *expr_p = NULL_TREE;
+             unsigned HOST_WIDE_INT ix;
+             constructor_elt *ce;
+             tree temp = NULL_TREE;
+             for (ix = 0;
+                  VEC_iterate (constructor_elt, CONSTRUCTOR_ELTS (*expr_p),
+                               ix, ce);
+                  ix++)
+               if (TREE_SIDE_EFFECTS (ce->value))
+                 append_to_statement_list (ce->value, &temp);
+
+             *expr_p = temp;
+             ret = GS_OK;
            }
-
-         ret = GS_ALL_DONE;
+         /* C99 code may assign to an array in a constructed
+            structure or union, and this has undefined behavior only
+            on execution, so create a temporary if an lvalue is
+            required.  */
+         else if (fallback == fb_lvalue)
+           {
+             *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p);
+             lang_hooks.mark_addressable (*expr_p);
+           }
+         else
+           ret = GS_ALL_DONE;
          break;
 
          /* The following are special cases that are not handled by the
@@ -4261,36 +4432,8 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
          break;
 
        case VAR_DECL:
-         /* ??? If this is a local variable, and it has not been seen in any
-            outer BIND_EXPR, then it's probably the result of a duplicate
-            declaration, for which we've already issued an error.  It would
-            be really nice if the front end wouldn't leak these at all.
-            Currently the only known culprit is C++ destructors, as seen
-            in g++.old-deja/g++.jason/binding.C.  */
-         tmp = *expr_p;
-         if (!TREE_STATIC (tmp) && !DECL_EXTERNAL (tmp)
-             && decl_function_context (tmp) == current_function_decl
-             && !DECL_SEEN_IN_BIND_EXPR_P (tmp))
-           {
-             gcc_assert (errorcount || sorrycount);
-             ret = GS_ERROR;
-             break;
-           }
-         /* FALLTHRU */
-
        case PARM_DECL:
-         tmp = *expr_p;
-
-         /* If this is a local variable sized decl, it must be accessed
-            indirectly.  Perform that substitution.  */
-         if (DECL_HAS_VALUE_EXPR_P (tmp))
-           {
-             *expr_p = unshare_expr (DECL_VALUE_EXPR (tmp));
-             ret = GS_OK;
-             break;
-           }
-
-         ret = GS_ALL_DONE;
+         ret = gimplify_var_or_parm_decl (expr_p);
          break;
 
        case SSA_NAME:
@@ -4409,8 +4552,17 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
        {
          /* Historically, the compiler has treated a bare
             reference to a volatile lvalue as forcing a load.  */
-         tree tmp = create_tmp_var (TREE_TYPE (*expr_p), "vol");
-         *expr_p = build (MODIFY_EXPR, TREE_TYPE (tmp), tmp, *expr_p);
+         tree type = TYPE_MAIN_VARIANT (TREE_TYPE (*expr_p));
+         /* Normally, we do want to create a temporary for a
+            TREE_ADDRESSABLE type because such a type should not be
+            copied by bitwise-assignment.  However, we make an
+            exception here, as all we are doing here is ensuring that
+            we read the bytes that make up the type.  We use
+            create_tmp_var_raw because create_tmp_var will abort when
+            given a TREE_ADDRESSABLE type.  */
+         tree tmp = create_tmp_var_raw (type, "vol");
+         gimple_add_tmp_var (tmp);
+         *expr_p = build2 (MODIFY_EXPR, type, tmp, *expr_p);
        }
       else
        /* We can't do anything useful with a volatile reference to
@@ -4524,15 +4676,14 @@ gimplify_type_sizes (tree type, tree *list_p)
 {
   tree field, t;
 
-  if (type == NULL)
+  if (type == NULL || type == error_mark_node)
     return;
 
   /* We first do the main variant, then copy into any other variants.  */
   type = TYPE_MAIN_VARIANT (type);
 
   /* Avoid infinite recursion.  */
-  if (TYPE_SIZES_GIMPLIFIED (type)
-      || type == error_mark_node)
+  if (TYPE_SIZES_GIMPLIFIED (type))
     return;
 
   TYPE_SIZES_GIMPLIFIED (type) = 1;
@@ -4598,18 +4749,46 @@ gimplify_type_sizes (tree type, tree *list_p)
 void
 gimplify_one_sizepos (tree *expr_p, tree *stmt_p)
 {
+  tree type, expr = *expr_p;
+
   /* We don't do anything if the value isn't there, is constant, or contains
      A PLACEHOLDER_EXPR.  We also don't want to do anything if it's already
      a VAR_DECL.  If it's a VAR_DECL from another function, the gimplifier
      will want to replace it with a new variable, but that will cause problems
      if this type is from outside the function.  It's OK to have that here.  */
-  if (*expr_p == NULL_TREE || TREE_CONSTANT (*expr_p)
-      || TREE_CODE (*expr_p) == VAR_DECL
-      || CONTAINS_PLACEHOLDER_P (*expr_p))
+  if (expr == NULL_TREE || TREE_CONSTANT (expr)
+      || TREE_CODE (expr) == VAR_DECL
+      || CONTAINS_PLACEHOLDER_P (expr))
     return;
 
-  *expr_p = unshare_expr (*expr_p);
+  type = TREE_TYPE (expr);
+  *expr_p = unshare_expr (expr);
+
   gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue);
+  expr = *expr_p;
+
+  /* Verify that we've an exact type match with the original expression.
+     In particular, we do not wish to drop a "sizetype" in favour of a
+     type of similar dimensions.  We don't want to pollute the generic
+     type-stripping code with this knowledge because it doesn't matter
+     for the bulk of GENERIC/GIMPLE.  It only matters that TYPE_SIZE_UNIT
+     and friends retain their "sizetype-ness".  */
+  if (TREE_TYPE (expr) != type
+      && TREE_CODE (type) == INTEGER_TYPE
+      && TYPE_IS_SIZETYPE (type))
+    {
+      tree tmp;
+
+      *expr_p = create_tmp_var (type, NULL);
+      tmp = build1 (NOP_EXPR, type, expr);
+      tmp = build2 (MODIFY_EXPR, type, *expr_p, expr);
+      if (EXPR_HAS_LOCATION (expr))
+       SET_EXPR_LOCUS (tmp, EXPR_LOCUS (expr));
+      else
+       SET_EXPR_LOCATION (tmp, input_location);
+
+      gimplify_and_add (tmp, stmt_p);
+    }
 }
 \f
 #ifdef ENABLE_CHECKING
@@ -4691,7 +4870,7 @@ check_pointer_types_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
 }
 #endif
 
-/* Gimplify the body of statements pointed by BODY_P.  FNDECL is the
+/* Gimplify the body of statements pointed to by BODY_P.  FNDECL is the
    function decl containing BODY.  */
 
 void
@@ -4733,8 +4912,8 @@ gimplify_body (tree *body_p, tree fndecl, bool do_parms)
   /* If there isn't an outer BIND_EXPR, add one.  */
   if (TREE_CODE (body) != BIND_EXPR)
     {
-      tree b = build (BIND_EXPR, void_type_node, NULL_TREE,
-                     NULL_TREE, NULL_TREE);
+      tree b = build3 (BIND_EXPR, void_type_node, NULL_TREE,
+                      NULL_TREE, NULL_TREE);
       TREE_SIDE_EFFECTS (b) = 1;
       append_to_statement_list_force (body, &BIND_EXPR_BODY (b));
       body = b;
@@ -4804,7 +4983,7 @@ gimplify_function_tree (tree fndecl)
     {
       tree tf, x, bind;
 
-      tf = build (TRY_FINALLY_EXPR, void_type_node, NULL, NULL);
+      tf = build2 (TRY_FINALLY_EXPR, void_type_node, NULL, NULL);
       TREE_SIDE_EFFECTS (tf) = 1;
       x = DECL_SAVED_TREE (fndecl);
       append_to_statement_list (x, &TREE_OPERAND (tf, 0));
@@ -4812,7 +4991,7 @@ gimplify_function_tree (tree fndecl)
       x = build_function_call_expr (x, NULL);
       append_to_statement_list (x, &TREE_OPERAND (tf, 1));
 
-      bind = build (BIND_EXPR, void_type_node, NULL, NULL, NULL);
+      bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
       TREE_SIDE_EFFECTS (bind) = 1;
       x = implicit_built_in_decls[BUILT_IN_PROFILE_FUNC_ENTER];
       x = build_function_call_expr (x, NULL);
@@ -4850,7 +5029,7 @@ force_gimple_operand (tree expr, tree *stmts, bool simple, tree var)
   gimplify_ctxp->into_ssa = in_ssa_p;
 
   if (var)
-    expr = build (MODIFY_EXPR, TREE_TYPE (var), var, expr);
+    expr = build2 (MODIFY_EXPR, TREE_TYPE (var), var, expr);
 
   ret = gimplify_expr (&expr, stmts, NULL,
                       gimple_test_f, fb_rvalue);