diff mbox

[Fortran] PR45186 - Part 2: gfortran 4.6 emits wrong line numbers

Message ID 4C7FF725.5020704@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Sept. 2, 2010, 7:12 p.m. UTC
This patch converts the trans-expr.c, trans-intrinsic.c, trans-io.c 
and trans-openmp.c's fold_build[0-9] to fold_build[0-9]_loc.

Remaining are 414 fold_builds:
trans-array.c:198
trans-intrinsic.c:216

Note: I only regtested (check-gfortran and libgomp) with -m64; there was 
no failure (except of the expected gfortran.dg/float128_1.f90). I have 
not tried -m32, but at least pr25923.f90 fails (with and without this 
patch, cf. PR 45505).

Build and regtested on x86-64-linux.
OK for the trunk?

Tobias

Comments

Daniel Kraft Sept. 3, 2010, 10:47 a.m. UTC | #1
Tobias Burnus wrote:
>  This patch converts the trans-expr.c, trans-intrinsic.c, trans-io.c and 
> trans-openmp.c's fold_build[0-9] to fold_build[0-9]_loc.
> 
> Remaining are 414 fold_builds:
> trans-array.c:198
> trans-intrinsic.c:216
> 
> Note: I only regtested (check-gfortran and libgomp) with -m64; there was 
> no failure (except of the expected gfortran.dg/float128_1.f90). I have 
> not tried -m32, but at least pr25923.f90 fails (with and without this 
> patch, cf. PR 45505).
> 
> Build and regtested on x86-64-linux.
> OK for the trunk?

Ok.  Just one question:

  	  se->expr = fold_build3 (COND_EXPR, TREE_TYPE (args[0]), cond,
-				  build_call_expr (abs, 1, args[0]),
-				  build_call_expr (tmp, 2, args[0], args[1]));
+				  build_call_expr_loc (input_location, abs, 1,
+						       args[0]),
+				  build_call_expr_loc (input_location, tmp, 2,
+						       args[0], args[1]));

Why didn't you update the fold_build3 here?


Thanks for taking this up!

Daniel
diff mbox

Patch

2010-09-02  Tobias Burnus  <burnus@net-b.de>

	PR fortran/45186
	* trans-intrinsic.c (gfc_conv_intrinsic_sign,
	gfc_conv_intrinsic_leadz): Use build_call_expr_loc instead
	of build_call_expr.
	* trans-expr.c (gfc_conv_expr_present, gfc_conv_missing_dummy,
	gfc_conv_string_length, gfc_conv_substring,
	gfc_conv_component_ref, gfc_conv_unary_op, gfc_conv_powi,
	gfc_conv_cst_int_power, gfc_conv_string_tmp, gfc_conv_concat_op,
	gfc_conv_expr_op, gfc_build_compare_string,
	gfc_set_interface_mapping_bounds, gfc_conv_subref_array_arg,
	gfc_conv_derived_to_class, conv_isocbinding_procedure,
	gfc_conv_procedure_call, fill_with_spaces,
	gfc_trans_string_copy, gfc_trans_alloc_subarray_assign,
	gfc_trans_structure_assign, gfc_trans_pointer_assignment,
	gfc_trans_scalar_assign, gfc_trans_zero_assign,
	gfc_trans_array_copy, gfc_trans_array_constructor_copy): Change
	fold_build[0-9] to fold_build[0-9]_loc.
	* trans-io.c (set_parameter_const, set_parameter_value,
	set_parameter_ref, gfc_convert_array_to_string, set_string,
	set_internal_unit, io_result, set_error_locus,
	nml_get_addr_expr, build_dt): Ditto.
	* trans-openmp.c (gfc_omp_clause_default_ctor,
	gfc_omp_clause_copy_ctor, gfc_omp_clause_assign_op,
	gfc_trans_omp_array_reduction, gfc_trans_omp_atomic,
	gfc_trans_omp_do): Ditto.
	* trans.c (gfc_add_modify, gfc_build_addr_expr,
	gfc_build_array_ref, gfc_trans_runtime_error_vararg,
	gfc_trans_runtime_check, gfc_call_malloc,
	gfc_allocate_with_status, gfc_allocate_array_with_status,
	gfc_call_free, gfc_deallocate_with_status,
	gfc_call_realloc): Ditto.

Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c	(Revision 163788)
+++ gcc/fortran/trans-expr.c	(Arbeitskopie)
@@ -137,8 +137,8 @@  gfc_conv_expr_present (gfc_symbol * sym)
       decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
     }
 
-  cond = fold_build2 (NE_EXPR, boolean_type_node, decl,
-		      fold_convert (TREE_TYPE (decl), null_pointer_node));
+  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, decl,
+			  fold_convert (TREE_TYPE (decl), null_pointer_node));
 
   /* Fortran 2008 allows to pass null pointers and non-associated pointers
      as actual argument to denote absent dummies. For array descriptors,
@@ -150,9 +150,10 @@  gfc_conv_expr_present (gfc_symbol * sym)
       tree tmp;
       tmp = build_fold_indirect_ref_loc (input_location, decl);
       tmp = gfc_conv_array_data (tmp);
-      tmp = fold_build2 (NE_EXPR, boolean_type_node, tmp,
-			 fold_convert (TREE_TYPE (tmp), null_pointer_node));
-      cond = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node, cond, tmp);
+      tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, tmp,
+			     fold_convert (TREE_TYPE (tmp), null_pointer_node));
+      cond = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+			      boolean_type_node, cond, tmp);
     }
 
   return cond;
@@ -193,8 +194,8 @@  gfc_conv_missing_dummy (gfc_se * se, gfc
   if (ts.type == BT_CHARACTER)
     {
       tmp = build_int_cst (gfc_charlen_type_node, 0);
-      tmp = fold_build3 (COND_EXPR, gfc_charlen_type_node,
-			 present, se->string_length, tmp);
+      tmp = fold_build3_loc (input_location, COND_EXPR, gfc_charlen_type_node,
+			     present, se->string_length, tmp);
       tmp = gfc_evaluate_now (tmp, &se->pre);
       se->string_length = tmp;
     }
@@ -358,8 +359,8 @@  gfc_conv_string_length (gfc_charlen * cl
   gcc_assert (cl->length);
 
   gfc_conv_expr_type (&se, cl->length, gfc_charlen_type_node);
-  se.expr = fold_build2 (MAX_EXPR, gfc_charlen_type_node, se.expr,
-			 build_int_cst (gfc_charlen_type_node, 0));
+  se.expr = fold_build2_loc (input_location, MAX_EXPR, gfc_charlen_type_node,
+			     se.expr, build_int_cst (gfc_charlen_type_node, 0));
   gfc_add_block_to_block (pblock, &se.pre);
 
   if (cl->backend_decl)
@@ -423,14 +424,16 @@  gfc_conv_substring (gfc_se * se, gfc_ref
 
   if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
     {
-      tree nonempty = fold_build2 (LE_EXPR, boolean_type_node,
-				   start.expr, end.expr);
+      tree nonempty = fold_build2_loc (input_location, LE_EXPR,
+				       boolean_type_node, start.expr,
+				       end.expr);
 
       /* Check lower bound.  */
-      fault = fold_build2 (LT_EXPR, boolean_type_node, start.expr,
-                           build_int_cst (gfc_charlen_type_node, 1));
-      fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node,
-			   nonempty, fault);
+      fault = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
+			       start.expr,
+			       build_int_cst (gfc_charlen_type_node, 1));
+      fault = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+			       boolean_type_node, nonempty, fault);
       if (name)
 	asprintf (&msg, "Substring out of bounds: lower bound (%%ld) of '%s' "
 		  "is less than one", name);
@@ -443,10 +446,10 @@  gfc_conv_substring (gfc_se * se, gfc_ref
       gfc_free (msg);
 
       /* Check upper bound.  */
-      fault = fold_build2 (GT_EXPR, boolean_type_node, end.expr,
-                           se->string_length);
-      fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node,
-			   nonempty, fault);
+      fault = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
+			       end.expr, se->string_length);
+      fault = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+			       boolean_type_node, nonempty, fault);
       if (name)
 	asprintf (&msg, "Substring out of bounds: upper bound (%%ld) of '%s' "
 		  "exceeds string length (%%ld)", name);
@@ -460,12 +463,12 @@  gfc_conv_substring (gfc_se * se, gfc_ref
       gfc_free (msg);
     }
 
-  tmp = fold_build2 (MINUS_EXPR, gfc_charlen_type_node,
-		     end.expr, start.expr);
-  tmp = fold_build2 (PLUS_EXPR, gfc_charlen_type_node,
-		     build_int_cst (gfc_charlen_type_node, 1), tmp);
-  tmp = fold_build2 (MAX_EXPR, gfc_charlen_type_node, tmp,
-		     build_int_cst (gfc_charlen_type_node, 0));
+  tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_charlen_type_node,
+			 end.expr, start.expr);
+  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_charlen_type_node,
+			 build_int_cst (gfc_charlen_type_node, 1), tmp);
+  tmp = fold_build2_loc (input_location, MAX_EXPR, gfc_charlen_type_node, tmp,
+			 build_int_cst (gfc_charlen_type_node, 0));
   se->string_length = tmp;
 }
 
@@ -487,7 +490,8 @@  gfc_conv_component_ref (gfc_se * se, gfc
   field = c->backend_decl;
   gcc_assert (TREE_CODE (field) == FIELD_DECL);
   decl = se->expr;
-  tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field), decl, field, NULL_TREE);
+  tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (field),
+			 decl, field, NULL_TREE);
 
   se->expr = tmp;
 
@@ -769,10 +773,10 @@  gfc_conv_unary_op (enum tree_code code,
      We must convert it to a compare to 0 (e.g. EQ_EXPR (op1, 0)).
      All other unary operators have an equivalent GIMPLE unary operator.  */
   if (code == TRUTH_NOT_EXPR)
-    se->expr = fold_build2 (EQ_EXPR, type, operand.expr,
-			    build_int_cst (type, 0));
+    se->expr = fold_build2_loc (input_location, EQ_EXPR, type, operand.expr,
+				build_int_cst (type, 0));
   else
-    se->expr = fold_build1 (code, type, operand.expr);
+    se->expr = fold_build1_loc (input_location, code, type, operand.expr);
 
 }
 
@@ -859,7 +863,7 @@  gfc_conv_powi (gfc_se * se, unsigned HOS
       op1 = op0;
     }
 
-  tmp = fold_build2 (MULT_EXPR, TREE_TYPE (op0), op0, op1);
+  tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (op0), op0, op1);
   tmp = gfc_evaluate_now (tmp, &se->pre);
 
   if (n < POWI_TABLE_SIZE)
@@ -910,27 +914,29 @@  gfc_conv_cst_int_power (gfc_se * se, tre
   /* If rhs < 0 and lhs is an integer, the result is -1, 0 or 1.  */
   if ((sgn == -1) && (TREE_CODE (type) == INTEGER_TYPE))
     {
-      tmp = fold_build2 (EQ_EXPR, boolean_type_node,
-			 lhs, build_int_cst (TREE_TYPE (lhs), -1));
-      cond = fold_build2 (EQ_EXPR, boolean_type_node,
-			  lhs, build_int_cst (TREE_TYPE (lhs), 1));
+      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
+			     lhs, build_int_cst (TREE_TYPE (lhs), -1));
+      cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
+			      lhs, build_int_cst (TREE_TYPE (lhs), 1));
 
       /* If rhs is even,
 	 result = (lhs == 1 || lhs == -1) ? 1 : 0.  */
       if ((n & 1) == 0)
         {
-	  tmp = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, tmp, cond);
-	  se->expr = fold_build3 (COND_EXPR, type,
-				  tmp, build_int_cst (type, 1),
-				  build_int_cst (type, 0));
+	  tmp = fold_build2_loc (input_location, TRUTH_OR_EXPR,
+				 boolean_type_node, tmp, cond);
+	  se->expr = fold_build3_loc (input_location, COND_EXPR, type,
+				      tmp, build_int_cst (type, 1),
+				      build_int_cst (type, 0));
 	  return 1;
 	}
       /* If rhs is odd,
 	 result = (lhs == 1) ? 1 : (lhs == -1) ? -1 : 0.  */
-      tmp = fold_build3 (COND_EXPR, type, tmp, build_int_cst (type, -1),
-			 build_int_cst (type, 0));
-      se->expr = fold_build3 (COND_EXPR, type,
-			      cond, build_int_cst (type, 1), tmp);
+      tmp = fold_build3_loc (input_location, COND_EXPR, type, tmp,
+			     build_int_cst (type, -1),
+			     build_int_cst (type, 0));
+      se->expr = fold_build3_loc (input_location, COND_EXPR, type,
+				  cond, build_int_cst (type, 1), tmp);
       return 1;
     }
 
@@ -939,7 +945,8 @@  gfc_conv_cst_int_power (gfc_se * se, tre
   if (sgn == -1)
     {
       tmp = gfc_build_const (type, integer_one_node);
-      vartmp[1] = fold_build2 (RDIV_EXPR, type, tmp, vartmp[1]);
+      vartmp[1] = fold_build2_loc (input_location, RDIV_EXPR, type, tmp,
+				   vartmp[1]);
     }
 
   se->expr = gfc_conv_powi (se, n, vartmp);
@@ -1115,8 +1122,9 @@  gfc_conv_string_tmp (gfc_se * se, tree t
   if (gfc_can_put_var_on_stack (len))
     {
       /* Create a temporary variable to hold the result.  */
-      tmp = fold_build2 (MINUS_EXPR, gfc_charlen_type_node, len,
-			 build_int_cst (gfc_charlen_type_node, 1));
+      tmp = fold_build2_loc (input_location, MINUS_EXPR,
+			     gfc_charlen_type_node, len,
+			     build_int_cst (gfc_charlen_type_node, 1));
       tmp = build_range_type (gfc_array_index_type, gfc_index_zero_node, tmp);
 
       if (TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE)
@@ -1132,9 +1140,10 @@  gfc_conv_string_tmp (gfc_se * se, tree t
       /* Allocate a temporary to hold the result.  */
       var = gfc_create_var (type, "pstr");
       tmp = gfc_call_malloc (&se->pre, type,
-			     fold_build2 (MULT_EXPR, TREE_TYPE (len), len,
-					  fold_convert (TREE_TYPE (len),
-							TYPE_SIZE (type))));
+			     fold_build2_loc (input_location, MULT_EXPR,
+					      TREE_TYPE (len), len,
+					      fold_convert (TREE_TYPE (len),
+							    TYPE_SIZE (type))));
       gfc_add_modify (&se->pre, var, tmp);
 
       /* Free the temporary afterwards.  */
@@ -1173,8 +1182,9 @@  gfc_conv_concat_op (gfc_se * se, gfc_exp
   len = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
   if (len == NULL_TREE)
     {
-      len = fold_build2 (PLUS_EXPR, TREE_TYPE (lse.string_length),
-			 lse.string_length, rse.string_length);
+      len = fold_build2_loc (input_location, PLUS_EXPR,
+			     TREE_TYPE (lse.string_length),
+			     lse.string_length, rse.string_length);
     }
 
   type = build_pointer_type (type);
@@ -1377,11 +1387,12 @@  gfc_conv_expr_op (gfc_se * se, gfc_expr
   if (lop)
     {
       /* The result of logical ops is always boolean_type_node.  */
-      tmp = fold_build2 (code, boolean_type_node, lse.expr, rse.expr);
+      tmp = fold_build2_loc (input_location, code, boolean_type_node,
+			     lse.expr, rse.expr);
       se->expr = convert (type, tmp);
     }
   else
-    se->expr = fold_build2 (code, type, lse.expr, rse.expr);
+    se->expr = fold_build2_loc (input_location, code, type, lse.expr, rse.expr);
 
   /* Add the post blocks.  */
   gfc_add_block_to_block (&se->post, &rse.post);
@@ -1553,7 +1564,8 @@  gfc_build_compare_string (tree len1, tre
       /* Deal with single character specially.  */
       sc1 = fold_convert (integer_type_node, sc1);
       sc2 = fold_convert (integer_type_node, sc2);
-      return fold_build2 (MINUS_EXPR, integer_type_node, sc1, sc2);
+      return fold_build2_loc (input_location, MINUS_EXPR, integer_type_node,
+			      sc1, sc2);
     }
 
   if ((code == EQ_EXPR || code == NE_EXPR)
@@ -1750,19 +1762,21 @@  gfc_set_interface_mapping_bounds (stmtbl
 	}
       else if (GFC_TYPE_ARRAY_UBOUND (type, n) == NULL_TREE)
 	{
-	  tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
-			     gfc_conv_descriptor_ubound_get (desc, dim),
-			     gfc_conv_descriptor_lbound_get (desc, dim));
-	  tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
-			     GFC_TYPE_ARRAY_LBOUND (type, n),
-			     tmp);
+	  tmp = fold_build2_loc (input_location, MINUS_EXPR,
+				 gfc_array_index_type,
+				 gfc_conv_descriptor_ubound_get (desc, dim),
+				 gfc_conv_descriptor_lbound_get (desc, dim));
+	  tmp = fold_build2_loc (input_location, PLUS_EXPR,
+				 gfc_array_index_type,
+				 GFC_TYPE_ARRAY_LBOUND (type, n), tmp);
 	  tmp = gfc_evaluate_now (tmp, block);
 	  GFC_TYPE_ARRAY_UBOUND (type, n) = tmp;
 	}
-      tmp = fold_build2 (MULT_EXPR, gfc_array_index_type,
-			 GFC_TYPE_ARRAY_LBOUND (type, n),
-			 GFC_TYPE_ARRAY_STRIDE (type, n));
-      offset = fold_build2 (MINUS_EXPR, gfc_array_index_type, offset, tmp);
+      tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			     GFC_TYPE_ARRAY_LBOUND (type, n),
+			     GFC_TYPE_ARRAY_STRIDE (type, n));
+      offset = fold_build2_loc (input_location, MINUS_EXPR,
+				gfc_array_index_type, offset, tmp);
     }
   offset = gfc_evaluate_now (offset, block);
   GFC_TYPE_ARRAY_OFFSET (type) = offset;
@@ -2400,26 +2414,30 @@  gfc_conv_subref_array_arg (gfc_se * parm
     {
       tree tmp_str;
       tmp = rse.loop->loopvar[n];
-      tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
-			 tmp, rse.loop->from[n]);
-      tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
-			 tmp, tmp_index);
-
-      tmp_str = fold_build2 (MINUS_EXPR, gfc_array_index_type,
-			     rse.loop->to[n-1], rse.loop->from[n-1]);
-      tmp_str = fold_build2 (PLUS_EXPR, gfc_array_index_type,
-			     tmp_str, gfc_index_one_node);
-
-      tmp_index = fold_build2 (MULT_EXPR, gfc_array_index_type,
-			       tmp, tmp_str);
-    }
-
-  tmp_index = fold_build2 (MINUS_EXPR, gfc_array_index_type,
-  			   tmp_index, rse.loop->from[0]);
+      tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+			     tmp, rse.loop->from[n]);
+      tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+			     tmp, tmp_index);
+
+      tmp_str = fold_build2_loc (input_location, MINUS_EXPR,
+				 gfc_array_index_type,
+				 rse.loop->to[n-1], rse.loop->from[n-1]);
+      tmp_str = fold_build2_loc (input_location, PLUS_EXPR,
+				 gfc_array_index_type,
+				 tmp_str, gfc_index_one_node);
+
+      tmp_index = fold_build2_loc (input_location, MULT_EXPR,
+				   gfc_array_index_type, tmp, tmp_str);
+    }
+
+  tmp_index = fold_build2_loc (input_location, MINUS_EXPR,
+			       gfc_array_index_type,
+			       tmp_index, rse.loop->from[0]);
   gfc_add_modify (&rse.loop->code[0], offset, tmp_index);
 
-  tmp_index = fold_build2 (PLUS_EXPR, gfc_array_index_type,
-			   rse.loop->loopvar[0], offset);
+  tmp_index = fold_build2_loc (input_location, PLUS_EXPR,
+			       gfc_array_index_type,
+			       rse.loop->loopvar[0], offset);
 
   /* Now use the offset for the reference.  */
   tmp = build_fold_indirect_ref_loc (input_location,
@@ -2467,8 +2485,9 @@  gfc_conv_subref_array_arg (gfc_se * parm
 	{
 	  tmp = gfc_conv_descriptor_ubound_get (parmse->expr,
 						gfc_rank_cst[n]);
-	  tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
-			     tmp, gfc_index_one_node);
+	  tmp = fold_build2_loc (input_location, PLUS_EXPR,
+				 gfc_array_index_type, tmp,
+				 gfc_index_one_node);
 	  gfc_conv_descriptor_ubound_set (&parmse->pre,
 					  parmse->expr,
 					  gfc_rank_cst[n],
@@ -2478,15 +2497,18 @@  gfc_conv_subref_array_arg (gfc_se * parm
 					  gfc_rank_cst[n],
 					  gfc_index_one_node);
 	  size = gfc_evaluate_now (size, &parmse->pre);
-	  offset = fold_build2 (MINUS_EXPR, gfc_array_index_type,
-				offset, size);
+	  offset = fold_build2_loc (input_location, MINUS_EXPR,
+				    gfc_array_index_type,
+				    offset, size);
 	  offset = gfc_evaluate_now (offset, &parmse->pre);
-	  tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
-			     rse.loop->to[n], rse.loop->from[n]);
-	  tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
-			     tmp, gfc_index_one_node);
-	  size = fold_build2 (MULT_EXPR, gfc_array_index_type,
-			      size, tmp);
+	  tmp = fold_build2_loc (input_location, MINUS_EXPR,
+				 gfc_array_index_type,
+				 rse.loop->to[n], rse.loop->from[n]);
+	  tmp = fold_build2_loc (input_location, PLUS_EXPR,
+				 gfc_array_index_type,
+				 tmp, gfc_index_one_node);
+	  size = fold_build2_loc (input_location, MULT_EXPR,
+				  gfc_array_index_type, size, tmp);
 	}
 
       gfc_conv_descriptor_offset_set (&parmse->pre, parmse->expr,
@@ -2548,8 +2570,9 @@  gfc_conv_derived_to_class (gfc_se *parms
 
   /* Set the vptr.  */
   cmp = gfc_find_component (declared, "$vptr", true, true);
-  ctree = fold_build3 (COMPONENT_REF, TREE_TYPE (cmp->backend_decl),
-		       var, cmp->backend_decl, NULL_TREE);
+  ctree = fold_build3_loc (input_location, COMPONENT_REF,
+			   TREE_TYPE (cmp->backend_decl),
+			   var, cmp->backend_decl, NULL_TREE);
 
   /* Remember the vtab corresponds to the derived type
      not to the class declared type.  */
@@ -2561,8 +2584,9 @@  gfc_conv_derived_to_class (gfc_se *parms
 
   /* Now set the data field.  */
   cmp = gfc_find_component (declared, "$data", true, true);
-  ctree = fold_build3 (COMPONENT_REF, TREE_TYPE (cmp->backend_decl),
-		       var, cmp->backend_decl, NULL_TREE);
+  ctree = fold_build3_loc (input_location, COMPONENT_REF,
+			   TREE_TYPE (cmp->backend_decl),
+			   var, cmp->backend_decl, NULL_TREE);
   ss = gfc_walk_expr (e);
   if (ss == gfc_ss_terminator)
     {
@@ -2668,10 +2692,11 @@  conv_isocbinding_procedure (gfc_se * se,
 	fptrse.expr = build_fold_indirect_ref_loc (input_location,
 						   fptrse.expr);
       
-      se->expr = fold_build2 (MODIFY_EXPR, TREE_TYPE (fptrse.expr),
-			      fptrse.expr,
-			      fold_convert (TREE_TYPE (fptrse.expr),
-					    cptrse.expr));
+      se->expr = fold_build2_loc (input_location, MODIFY_EXPR,
+				  TREE_TYPE (fptrse.expr),
+				  fptrse.expr,
+				  fold_convert (TREE_TYPE (fptrse.expr),
+						cptrse.expr));
 
       return 1;
     }
@@ -2692,9 +2717,10 @@  conv_isocbinding_procedure (gfc_se * se,
       if (arg->next == NULL)
 	/* Only given one arg so generate a null and do a
 	   not-equal comparison against the first arg.  */
-	se->expr = fold_build2 (NE_EXPR, boolean_type_node, arg1se.expr,
-				fold_convert (TREE_TYPE (arg1se.expr),
-					      null_pointer_node));
+	se->expr = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
+				    arg1se.expr,
+				    fold_convert (TREE_TYPE (arg1se.expr),
+						  null_pointer_node));
       else
 	{
 	  tree eq_expr;
@@ -2707,16 +2733,18 @@  conv_isocbinding_procedure (gfc_se * se,
 	  gfc_add_block_to_block (&se->post, &arg2se.post);
 
 	  /* Generate test to compare that the two args are equal.  */
-	  eq_expr = fold_build2 (EQ_EXPR, boolean_type_node,
-				 arg1se.expr, arg2se.expr);
+	  eq_expr = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
+				     arg1se.expr, arg2se.expr);
 	  /* Generate test to ensure that the first arg is not null.  */
-	  not_null_expr = fold_build2 (NE_EXPR, boolean_type_node,
-				       arg1se.expr, null_pointer_node);
+	  not_null_expr = fold_build2_loc (input_location, NE_EXPR,
+					   boolean_type_node,
+					   arg1se.expr, null_pointer_node);
 
 	  /* Finally, the generated test must check that both arg1 is not
 	     NULL and that it is equal to the second arg.  */
-	  se->expr = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
-				  not_null_expr, eq_expr);
+	  se->expr = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+				      boolean_type_node,
+				      not_null_expr, eq_expr);
 	}
 
       return 1;
@@ -2947,15 +2975,17 @@  gfc_conv_procedure_call (gfc_se * se, gf
 		      tmp = gfc_deallocate_with_status (parmse.expr, NULL_TREE,
 							true, NULL);
 		      gfc_add_expr_to_block (&block, tmp);
-		      tmp = fold_build2 (MODIFY_EXPR, void_type_node,
-					 parmse.expr, null_pointer_node);
+		      tmp = fold_build2_loc (input_location, MODIFY_EXPR,
+					     void_type_node, parmse.expr,
+					     null_pointer_node);
 		      gfc_add_expr_to_block (&block, tmp);
 
 		      if (fsym->attr.optional
 			  && e->expr_type == EXPR_VARIABLE
 			  && e->symtree->n.sym->attr.optional)
 			{
-			  tmp = fold_build3 (COND_EXPR, void_type_node,
+			  tmp = fold_build3_loc (input_location, COND_EXPR,
+				     void_type_node,
 				     gfc_conv_expr_present (e->symtree->n.sym),
 					    gfc_finish_block (&block),
 					    build_empty_stmt (input_location));
@@ -3025,7 +3055,8 @@  gfc_conv_procedure_call (gfc_se * se, gf
 		  if (fsym->attr.optional
 		      && e->expr_type == EXPR_VARIABLE
 		      && e->symtree->n.sym->attr.optional)
-		    tmp = fold_build3 (COND_EXPR, void_type_node,
+		    tmp = fold_build3_loc (input_location, COND_EXPR,
+				     void_type_node,
 				     gfc_conv_expr_present (e->symtree->n.sym),
 				       tmp, build_empty_stmt (input_location));
 		  gfc_add_expr_to_block (&se->pre, tmp);
@@ -3177,13 +3208,17 @@  gfc_conv_procedure_call (gfc_se * se, gf
 
 	      present = gfc_conv_expr_present (e->symtree->n.sym);
 	      type = TREE_TYPE (present);
-	      present = fold_build2 (EQ_EXPR, boolean_type_node, present,
-				     fold_convert (type, null_pointer_node));
+	      present = fold_build2_loc (input_location, EQ_EXPR,
+					 boolean_type_node, present,
+					 fold_convert (type,
+						       null_pointer_node));
 	      type = TREE_TYPE (parmse.expr);
-	      null_ptr = fold_build2 (EQ_EXPR, boolean_type_node, parmse.expr,
-				      fold_convert (type, null_pointer_node));
-	      cond = fold_build2 (TRUTH_ORIF_EXPR, boolean_type_node,
-				  present, null_ptr);
+	      null_ptr = fold_build2_loc (input_location, EQ_EXPR,
+					  boolean_type_node, parmse.expr,
+					  fold_convert (type,
+							null_pointer_node));
+	      cond = fold_build2_loc (input_location, TRUTH_ORIF_EXPR,
+				      boolean_type_node, present, null_ptr);
 	    }
           else
 	    {
@@ -3203,9 +3238,10 @@  gfc_conv_procedure_call (gfc_se * se, gf
 		goto end_pointer_check;
 
 
-	      cond = fold_build2 (EQ_EXPR, boolean_type_node, parmse.expr,
-				  fold_convert (TREE_TYPE (parmse.expr),
-						null_pointer_node));
+	      cond = fold_build2_loc (input_location, EQ_EXPR,
+				      boolean_type_node, parmse.expr,
+				      fold_convert (TREE_TYPE (parmse.expr),
+						    null_pointer_node));
 	    }
  
 	  gfc_trans_runtime_check (true, false, cond, &se->pre, &e->where,
@@ -3265,8 +3301,9 @@  gfc_conv_procedure_call (gfc_se * se, gf
 	  gfc_add_block_to_block (&se->post, &parmse.post);
 	  
 	  tmp = fold_convert (gfc_charlen_type_node, parmse.expr);
-	  tmp = fold_build2 (MAX_EXPR, gfc_charlen_type_node, tmp,
-			     build_int_cst (gfc_charlen_type_node, 0));
+	  tmp = fold_build2_loc (input_location, MAX_EXPR,
+				 gfc_charlen_type_node, tmp,
+				 build_int_cst (gfc_charlen_type_node, 0));
 	  cl.backend_decl = tmp;
 	}
 
@@ -3470,8 +3507,9 @@  gfc_conv_procedure_call (gfc_se * se, gf
 		  /* Check the data pointer hasn't been modified.  This would
 		     happen in a function returning a pointer.  */
 		  tmp = gfc_conv_descriptor_data_get (info->descriptor);
-		  tmp = fold_build2 (NE_EXPR, boolean_type_node,
-				     tmp, info->data);
+		  tmp = fold_build2_loc (input_location, NE_EXPR,
+					 boolean_type_node,
+					 tmp, info->data);
 		  gfc_trans_runtime_check (true, false, tmp, &se->pre, NULL,
 					   gfc_msg_fault);
 		}
@@ -3572,24 +3610,25 @@  fill_with_spaces (tree start, tree type,
   gfc_init_block (&loop);
 
   /* Exit condition.  */
-  cond = fold_build2 (LE_EXPR, boolean_type_node, i,
-		      fold_convert (sizetype, integer_zero_node));
+  cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, i,
+			  fold_convert (sizetype, integer_zero_node));
   tmp = build1_v (GOTO_EXPR, exit_label);
-  tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
-		     build_empty_stmt (input_location));
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, tmp,
+			 build_empty_stmt (input_location));
   gfc_add_expr_to_block (&loop, tmp);
 
   /* Assignment.  */
-  gfc_add_modify (&loop, fold_build1 (INDIRECT_REF, type, el),
-		       build_int_cst (type,
-				      lang_hooks.to_target_charset (' ')));
+  gfc_add_modify (&loop,
+		  fold_build1_loc (input_location, INDIRECT_REF, type, el),
+		  build_int_cst (type, lang_hooks.to_target_charset (' ')));
 
   /* Increment loop variables.  */
-  gfc_add_modify (&loop, i, fold_build2 (MINUS_EXPR, sizetype, i,
-					      TYPE_SIZE_UNIT (type)));
-  gfc_add_modify (&loop, el, fold_build2 (POINTER_PLUS_EXPR,
-					       TREE_TYPE (el), el,
-					       TYPE_SIZE_UNIT (type)));
+  gfc_add_modify (&loop, i,
+		  fold_build2_loc (input_location, MINUS_EXPR, sizetype, i,
+				   TYPE_SIZE_UNIT (type)));
+  gfc_add_modify (&loop, el,
+		  fold_build2_loc (input_location, POINTER_PLUS_EXPR,
+				   TREE_TYPE (el), el, TYPE_SIZE_UNIT (type)));
 
   /* Making the loop... actually loop!  */
   tmp = gfc_finish_block (&loop);
@@ -3655,8 +3694,8 @@  gfc_trans_string_copy (stmtblock_t * blo
     }
 
   /* Do nothing if the destination length is zero.  */
-  cond = fold_build2 (GT_EXPR, boolean_type_node, dlen,
-		      build_int_cst (size_type_node, 0));
+  cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node, dlen,
+			  build_int_cst (size_type_node, 0));
 
   /* The following code was previously in _gfortran_copy_string:
 
@@ -3684,12 +3723,14 @@  gfc_trans_string_copy (stmtblock_t * blo
   /* For non-default character kinds, we have to multiply the string
      length by the base type size.  */
   chartype = gfc_get_char_type (dkind);
-  slen = fold_build2 (MULT_EXPR, size_type_node,
-		      fold_convert (size_type_node, slen),
-		      fold_convert (size_type_node, TYPE_SIZE_UNIT (chartype)));
-  dlen = fold_build2 (MULT_EXPR, size_type_node,
-		      fold_convert (size_type_node, dlen),
-		      fold_convert (size_type_node, TYPE_SIZE_UNIT (chartype)));
+  slen = fold_build2_loc (input_location, MULT_EXPR, size_type_node,
+			  fold_convert (size_type_node, slen),
+			  fold_convert (size_type_node,
+					TYPE_SIZE_UNIT (chartype)));
+  dlen = fold_build2_loc (input_location, MULT_EXPR, size_type_node,
+			  fold_convert (size_type_node, dlen),
+			  fold_convert (size_type_node,
+					TYPE_SIZE_UNIT (chartype)));
 
   if (dlength)
     dest = fold_convert (pvoid_type_node, dest);
@@ -3702,7 +3743,8 @@  gfc_trans_string_copy (stmtblock_t * blo
     src = gfc_build_addr_expr (pvoid_type_node, src);
 
   /* Truncate string if source is too long.  */
-  cond2 = fold_build2 (GE_EXPR, boolean_type_node, slen, dlen);
+  cond2 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node, slen,
+			   dlen);
   tmp2 = build_call_expr_loc (input_location,
 			  built_in_decls[BUILT_IN_MEMMOVE],
 			  3, dest, src, dlen);
@@ -3712,11 +3754,11 @@  gfc_trans_string_copy (stmtblock_t * blo
 			  built_in_decls[BUILT_IN_MEMMOVE],
 			  3, dest, src, slen);
 
-  tmp4 = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dest), dest,
-		      fold_convert (sizetype, slen));
+  tmp4 = fold_build2_loc (input_location, POINTER_PLUS_EXPR, TREE_TYPE (dest),
+			  dest, fold_convert (sizetype, slen));
   tmp4 = fill_with_spaces (tmp4, chartype,
-			   fold_build2 (MINUS_EXPR, TREE_TYPE(dlen),
-					dlen, slen));
+			   fold_build2_loc (input_location, MINUS_EXPR,
+					    TREE_TYPE(dlen), dlen, slen));
 
   gfc_init_block (&tempblock);
   gfc_add_expr_to_block (&tempblock, tmp3);
@@ -3724,9 +3766,10 @@  gfc_trans_string_copy (stmtblock_t * blo
   tmp3 = gfc_finish_block (&tempblock);
 
   /* The whole copy_string function is there.  */
-  tmp = fold_build3 (COND_EXPR, void_type_node, cond2, tmp2, tmp3);
-  tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
-		     build_empty_stmt (input_location));
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond2,
+			 tmp2, tmp3);
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, tmp,
+			 build_empty_stmt (input_location));
   gfc_add_expr_to_block (block, tmp);
 }
 
@@ -4200,21 +4243,23 @@  gfc_trans_alloc_subarray_assign (tree de
 
       /* Shift the bounds and set the offset accordingly.  */
       tmp = gfc_conv_descriptor_ubound_get (dest, gfc_rank_cst[n]);
-      span = fold_build2 (MINUS_EXPR, gfc_array_index_type, tmp,
-		gfc_conv_descriptor_lbound_get (dest, gfc_rank_cst[n]));
-      tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, span, lbound);
+      span = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+		tmp, gfc_conv_descriptor_lbound_get (dest, gfc_rank_cst[n]));
+      tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+			     span, lbound);
       gfc_conv_descriptor_ubound_set (&block, dest,
 				      gfc_rank_cst[n], tmp);
       gfc_conv_descriptor_lbound_set (&block, dest,
 				      gfc_rank_cst[n], lbound);
 
-      tmp = fold_build2 (MULT_EXPR, gfc_array_index_type,
+      tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
 			 gfc_conv_descriptor_lbound_get (dest,
 							 gfc_rank_cst[n]),
 			 gfc_conv_descriptor_stride_get (dest,
 							 gfc_rank_cst[n]));
       gfc_add_modify (&block, tmp2, tmp);
-      tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, offset, tmp2);
+      tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+			     offset, tmp2);
       gfc_conv_descriptor_offset_set (&block, dest, tmp);
     }
 
@@ -4369,18 +4414,19 @@  gfc_trans_structure_assign (tree dest, g
       if (c && c->expr && c->expr->ts.is_iso_c)
 	{
 	  field = cm->backend_decl;
-	  tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field),
-			     dest, field, NULL_TREE);
-	  tmp = fold_build2 (MODIFY_EXPR, TREE_TYPE (tmp), tmp,
-			     fold_convert (TREE_TYPE (tmp),
-					   null_pointer_node));
+	  tmp = fold_build3_loc (input_location, COMPONENT_REF,
+				 TREE_TYPE (field),
+				 dest, field, NULL_TREE);
+	  tmp = fold_build2_loc (input_location, MODIFY_EXPR, TREE_TYPE (tmp),
+				 tmp, fold_convert (TREE_TYPE (tmp),
+						    null_pointer_node));
 	  gfc_add_expr_to_block (&block, tmp);
 	  continue;
 	}
 
       field = cm->backend_decl;
-      tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field),
-			 dest, field, NULL_TREE);
+      tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (field),
+			     dest, field, NULL_TREE);
       tmp = gfc_trans_subcomponent_assign (tmp, cm, c->expr);
       gfc_add_expr_to_block (&block, tmp);
     }
@@ -4864,10 +4910,10 @@  gfc_trans_pointer_assignment (gfc_expr *
 							   gfc_rank_cst[dim]);
 		  lbound = gfc_conv_descriptor_lbound_get (rse.expr,
 							   gfc_rank_cst[dim]);
-		  tmp = fold_build2 (MULT_EXPR, gfc_array_index_type,
-				     stride, lbound);
-		  offs = fold_build2 (PLUS_EXPR, gfc_array_index_type,
-				      offs, tmp);
+		  tmp = fold_build2_loc (input_location, MULT_EXPR,
+					 gfc_array_index_type, stride, lbound);
+		  offs = fold_build2_loc (input_location, PLUS_EXPR,
+					  gfc_array_index_type, offs, tmp);
 		}
 	      gfc_conv_descriptor_offset_set (&block, desc, offs);
 
@@ -4913,17 +4959,17 @@  gfc_trans_pointer_assignment (gfc_expr *
 
 		  /* Update offset.  */
 		  offs = gfc_conv_descriptor_offset_get (desc);
-		  tmp = fold_build2 (MULT_EXPR, gfc_array_index_type,
-				     lbound, stride);
-		  offs = fold_build2 (MINUS_EXPR, gfc_array_index_type,
-				      offs, tmp);
+		  tmp = fold_build2_loc (input_location, MULT_EXPR,
+					 gfc_array_index_type, lbound, stride);
+		  offs = fold_build2_loc (input_location, MINUS_EXPR,
+					  gfc_array_index_type, offs, tmp);
 		  offs = gfc_evaluate_now (offs, &block);
 		  gfc_conv_descriptor_offset_set (&block, desc, offs);
 
 		  /* Update stride.  */
 		  tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
-		  stride = fold_build2 (MULT_EXPR, gfc_array_index_type,
-					stride, tmp);
+		  stride = fold_build2_loc (input_location, MULT_EXPR,
+					    gfc_array_index_type, stride, tmp);
 		}
 	    }
 	  else
@@ -4972,7 +5018,8 @@  gfc_trans_pointer_assignment (gfc_expr *
 
 	  lsize = gfc_evaluate_now (lsize, &block);
 	  rsize = gfc_evaluate_now (rsize, &block);
-	  fault = fold_build2 (LT_EXPR, boolean_type_node, rsize, lsize);
+	  fault = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
+				   rsize, lsize);
 
 	  msg = _("Target of rank remapping is too small (%ld < %ld)");
 	  gfc_trans_runtime_check (true, false, fault, &block, &expr2->where,
@@ -5069,9 +5116,9 @@  gfc_trans_scalar_assign (gfc_se * lse, g
       /* Are the rhs and the lhs the same?  */
       if (r_is_var)
 	{
-	  cond = fold_build2 (EQ_EXPR, boolean_type_node,
-			      gfc_build_addr_expr (NULL_TREE, lse->expr),
-			      gfc_build_addr_expr (NULL_TREE, rse->expr));
+	  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
+				  gfc_build_addr_expr (NULL_TREE, lse->expr),
+				  gfc_build_addr_expr (NULL_TREE, rse->expr));
 	  cond = gfc_evaluate_now (cond, &lse->pre);
 	}
 
@@ -5109,7 +5156,8 @@  gfc_trans_scalar_assign (gfc_se * lse, g
     {
       gfc_add_block_to_block (&block, &lse->pre);
       gfc_add_block_to_block (&block, &rse->pre);
-      tmp = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lse->expr), rse->expr);
+      tmp = fold_build1_loc (input_location, VIEW_CONVERT_EXPR,
+			     TREE_TYPE (lse->expr), rse->expr);
       gfc_add_modify (&block, lse->expr, tmp);
     }
   else
@@ -5322,8 +5370,8 @@  gfc_trans_zero_assign (gfc_expr * expr)
     return NULL_TREE;
 
   tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
-  len = fold_build2 (MULT_EXPR, gfc_array_index_type, len,
-		     fold_convert (gfc_array_index_type, tmp));
+  len = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, len,
+			 fold_convert (gfc_array_index_type, tmp));
 
   /* If we are zeroing a local array avoid taking its address by emitting
      a = {} instead.  */
@@ -5401,15 +5449,15 @@  gfc_trans_array_copy (gfc_expr * expr1,
   if (!dlen || TREE_CODE (dlen) != INTEGER_CST)
     return NULL_TREE;
   tmp = TYPE_SIZE_UNIT (gfc_get_element_type (dtype));
-  dlen = fold_build2 (MULT_EXPR, gfc_array_index_type, dlen,
-		      fold_convert (gfc_array_index_type, tmp));
+  dlen = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			  dlen, fold_convert (gfc_array_index_type, tmp));
 
   slen = GFC_TYPE_ARRAY_SIZE (stype);
   if (!slen || TREE_CODE (slen) != INTEGER_CST)
     return NULL_TREE;
   tmp = TYPE_SIZE_UNIT (gfc_get_element_type (stype));
-  slen = fold_build2 (MULT_EXPR, gfc_array_index_type, slen,
-		      fold_convert (gfc_array_index_type, tmp));
+  slen = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			  slen, fold_convert (gfc_array_index_type, tmp));
 
   /* Sanity check that they are the same.  This should always be
      the case, as we should already have checked for conformance.  */
@@ -5454,8 +5502,8 @@  gfc_trans_array_constructor_copy (gfc_ex
     return NULL_TREE;
 
   tmp = TYPE_SIZE_UNIT (gfc_get_element_type (dtype));
-  len = fold_build2 (MULT_EXPR, gfc_array_index_type, len,
-		     fold_convert (gfc_array_index_type, tmp));
+  len = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, len,
+			 fold_convert (gfc_array_index_type, tmp));
 
   stype = gfc_typenode_for_spec (&expr2->ts);
   src = gfc_build_constant_array_constructor (expr2, stype);
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c	(Revision 163788)
+++ gcc/fortran/trans-intrinsic.c	(Arbeitskopie)
@@ -1306,8 +1306,10 @@  gfc_conv_intrinsic_sign (gfc_se * se, gf
 	  zero = build_real_from_int_cst (TREE_TYPE (args[1]), integer_zero_node);
 	  cond = fold_build2 (EQ_EXPR, boolean_type_node, args[1], zero);
 	  se->expr = fold_build3 (COND_EXPR, TREE_TYPE (args[0]), cond,
-				  build_call_expr (abs, 1, args[0]),
-				  build_call_expr (tmp, 2, args[0], args[1]));
+				  build_call_expr_loc (input_location, abs, 1,
+						       args[0]),
+				  build_call_expr_loc (input_location, tmp, 2,
+						       args[0], args[1]));
 	}
       else
         se->expr = build_call_expr_loc (input_location, tmp, 2,
@@ -3404,7 +3406,8 @@  gfc_conv_intrinsic_leadz (gfc_se * se, g
 
   /* Compute LEADZ for the case i .ne. 0.  */
   s = TYPE_PRECISION (arg_type) - argsize;
-  tmp = fold_convert (result_type, build_call_expr (func, 1, arg));
+  tmp = fold_convert (result_type, build_call_expr_loc (input_location, func,
+							1, arg));
   leadz = fold_build2 (MINUS_EXPR, result_type,
 		       tmp, build_int_cst (result_type, s));
 
Index: gcc/fortran/trans-io.c
===================================================================
--- gcc/fortran/trans-io.c	(Revision 163788)
+++ gcc/fortran/trans-io.c	(Arbeitskopie)
@@ -428,10 +428,11 @@  set_parameter_const (stmtblock_t *block,
   gfc_st_parameter_field *p = &st_parameter_field[type];
 
   if (p->param_type == IOPARM_ptype_common)
-    var = fold_build3 (COMPONENT_REF, st_parameter[IOPARM_ptype_common].type,
-		       var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
-  tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field), var, p->field,
-		     NULL_TREE);
+    var = fold_build3_loc (input_location, COMPONENT_REF,
+			   st_parameter[IOPARM_ptype_common].type,
+			   var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
+  tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
+			 var, p->field, NULL_TREE);
   gfc_add_modify (block, tmp, build_int_cst (TREE_TYPE (p->field), val));
   return p->mask;
 }
@@ -464,16 +465,18 @@  set_parameter_value (stmtblock_t *block,
       /* UNIT numbers should be greater than the min.  */
       i = gfc_validate_kind (BT_INTEGER, 4, false);
       val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].pedantic_min_int, 4);
-      cond = fold_build2 (LT_EXPR, boolean_type_node, se.expr,
-			  fold_convert (TREE_TYPE (se.expr), val));
+      cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
+			      se.expr,
+			      fold_convert (TREE_TYPE (se.expr), val));
       gfc_trans_io_runtime_check (cond, var, LIBERROR_BAD_UNIT,
 			       "Unit number in I/O statement too small",
 			       &se.pre);
     
       /* UNIT numbers should be less than the max.  */
       val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].huge, 4);
-      cond = fold_build2 (GT_EXPR, boolean_type_node, se.expr,
-			  fold_convert (TREE_TYPE (se.expr), val));
+      cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node,
+			      se.expr,
+			      fold_convert (TREE_TYPE (se.expr), val));
       gfc_trans_io_runtime_check (cond, var, LIBERROR_BAD_UNIT,
 			       "Unit number in I/O statement too large",
 			       &se.pre);
@@ -484,10 +487,12 @@  set_parameter_value (stmtblock_t *block,
   gfc_add_block_to_block (block, &se.pre);
 
   if (p->param_type == IOPARM_ptype_common)
-    var = fold_build3 (COMPONENT_REF, st_parameter[IOPARM_ptype_common].type,
-		       var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
+    var = fold_build3_loc (input_location, COMPONENT_REF,
+			   st_parameter[IOPARM_ptype_common].type,
+			   var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
 
-  tmp = fold_build3 (COMPONENT_REF, dest_type, var, p->field, NULL_TREE);
+  tmp = fold_build3_loc (input_location, COMPONENT_REF, dest_type, var,
+			 p->field, NULL_TREE);
   gfc_add_modify (block, tmp, se.expr);
   return p->mask;
 }
@@ -542,10 +547,11 @@  set_parameter_ref (stmtblock_t *block, s
      }
 
   if (p->param_type == IOPARM_ptype_common)
-    var = fold_build3 (COMPONENT_REF, st_parameter[IOPARM_ptype_common].type,
-		       var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
-  tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field),
-		     var, p->field, NULL_TREE);
+    var = fold_build3_loc (input_location, COMPONENT_REF,
+			   st_parameter[IOPARM_ptype_common].type,
+			   var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
+  tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
+			 var, p->field, NULL_TREE);
   gfc_add_modify (block, tmp, addr);
   return p->mask;
 }
@@ -583,21 +589,26 @@  gfc_convert_array_to_string (gfc_se * se
 	{
 	  gcc_assert (GFC_DESCRIPTOR_TYPE_P (type));
 	  size = gfc_conv_array_stride (array, rank);
-	  tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
-			     gfc_conv_array_ubound (array, rank),
-			     gfc_conv_array_lbound (array, rank));
-	  tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp,
-			     gfc_index_one_node);
-	  size = fold_build2 (MULT_EXPR, gfc_array_index_type, tmp, size);
+	  tmp = fold_build2_loc (input_location, MINUS_EXPR,
+				 gfc_array_index_type,
+				 gfc_conv_array_ubound (array, rank),
+				 gfc_conv_array_lbound (array, rank));
+	  tmp = fold_build2_loc (input_location, PLUS_EXPR,
+				 gfc_array_index_type, tmp,
+				 gfc_index_one_node);
+	  size = fold_build2_loc (input_location, MULT_EXPR,
+				  gfc_array_index_type, tmp, size);
 	}
       gcc_assert (size);
 
-      size = fold_build2 (MINUS_EXPR, gfc_array_index_type, size,
-			  TREE_OPERAND (se->expr, 1));
+      size = fold_build2_loc (input_location, MINUS_EXPR,
+			      gfc_array_index_type, size,
+			      TREE_OPERAND (se->expr, 1));
       se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
       tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
-      size = fold_build2 (MULT_EXPR, gfc_array_index_type, size,
-			  fold_convert (gfc_array_index_type, tmp));
+      size = fold_build2_loc (input_location, MULT_EXPR,
+			      gfc_array_index_type, size,
+			      fold_convert (gfc_array_index_type, tmp));
       se->string_length = fold_convert (gfc_charlen_type_node, size);
       return;
     }
@@ -623,12 +634,14 @@  set_string (stmtblock_t * block, stmtblo
   gfc_init_se (&se, NULL);
 
   if (p->param_type == IOPARM_ptype_common)
-    var = fold_build3 (COMPONENT_REF, st_parameter[IOPARM_ptype_common].type,
-		       var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
-  io = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field),
+    var = fold_build3_loc (input_location, COMPONENT_REF,
+			   st_parameter[IOPARM_ptype_common].type,
+			   var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
+  io = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
 		    var, p->field, NULL_TREE);
-  len = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field_len),
-		     var, p->field_len, NULL_TREE);
+  len = fold_build3_loc (input_location, COMPONENT_REF,
+			 TREE_TYPE (p->field_len),
+			 var, p->field_len, NULL_TREE);
 
   /* Integer variable assigned a format label.  */
   if (e->ts.type == BT_INTEGER
@@ -640,8 +653,8 @@  set_string (stmtblock_t * block, stmtblo
 
       gfc_conv_label_variable (&se, e);
       tmp = GFC_DECL_STRING_LEN (se.expr);
-      cond = fold_build2 (LT_EXPR, boolean_type_node,
-			  tmp, build_int_cst (TREE_TYPE (tmp), 0));
+      cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
+			      tmp, build_int_cst (TREE_TYPE (tmp), 0));
 
       asprintf(&msg, "Label assigned to variable '%s' (%%ld) is not a format "
 	       "label", e->symtree->name);
@@ -694,13 +707,13 @@  set_internal_unit (stmtblock_t * block,
 
   p = &st_parameter_field[IOPARM_dt_internal_unit];
   mask = p->mask;
-  io = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field),
-		    var, p->field, NULL_TREE);
-  len = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field_len),
-		     var, p->field_len,	NULL_TREE);
+  io = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
+			var, p->field, NULL_TREE);
+  len = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field_len),
+			 var, p->field_len,	NULL_TREE);
   p = &st_parameter_field[IOPARM_dt_internal_unit_desc];
-  desc = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field),
-		      var, p->field, NULL_TREE);
+  desc = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
+			  var, p->field, NULL_TREE);
 
   gcc_assert (e->ts.type == BT_CHARACTER);
 
@@ -809,13 +822,14 @@  io_result (stmtblock_t * block, tree var
 
   tmp = gfc_finish_block (&body);
 
-  var = fold_build3 (COMPONENT_REF, st_parameter[IOPARM_ptype_common].type,
-		     var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
-  rc = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field),
-		    var, p->field, NULL_TREE);
-  rc = fold_build2 (BIT_AND_EXPR, TREE_TYPE (rc),
-		    rc, build_int_cst (TREE_TYPE (rc),
-				       IOPARM_common_libreturn_mask));
+  var = fold_build3_loc (input_location, COMPONENT_REF,
+			 st_parameter[IOPARM_ptype_common].type,
+			 var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
+  rc = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (p->field),
+			var, p->field, NULL_TREE);
+  rc = fold_build2_loc (input_location, BIT_AND_EXPR, TREE_TYPE (rc),
+			rc, build_int_cst (TREE_TYPE (rc),
+					   IOPARM_common_libreturn_mask));
 
   tmp = build3_v (SWITCH_EXPR, rc, tmp, NULL_TREE);
 
@@ -834,11 +848,12 @@  set_error_locus (stmtblock_t * block, tr
   int line;
   gfc_st_parameter_field *p = &st_parameter_field[IOPARM_common_filename];
 
-  locus_file = fold_build3 (COMPONENT_REF,
-			    st_parameter[IOPARM_ptype_common].type,
-			    var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
-  locus_file = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field),
-			    locus_file, p->field, NULL_TREE);
+  locus_file = fold_build3_loc (input_location, COMPONENT_REF,
+				st_parameter[IOPARM_ptype_common].type,
+				var, TYPE_FIELDS (TREE_TYPE (var)), NULL_TREE);
+  locus_file = fold_build3_loc (input_location, COMPONENT_REF,
+				TREE_TYPE (p->field), locus_file,
+				p->field, NULL_TREE);
   f = where->lb->file;
   str = gfc_build_cstring_const (f->filename);
 
@@ -1448,8 +1463,8 @@  nml_get_addr_expr (gfc_symbol * sym, gfc
      the derived type.  */
 
   if (TREE_CODE (decl) == FIELD_DECL)
-    tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (tmp),
-		       base_addr, tmp, NULL_TREE);
+    tmp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (tmp),
+			   base_addr, tmp, NULL_TREE);
 
   /* If we have a derived type component, a reference to the first
      element of the array is built.  This is done so that base_addr,
@@ -1786,13 +1801,15 @@  build_dt (tree function, gfc_code * code
     {
       gfc_st_parameter_field *p = &st_parameter_field[IOPARM_common_flags];
 
-      tmp = fold_build3 (COMPONENT_REF, st_parameter[IOPARM_ptype_common].type,
-			 dt_parm, TYPE_FIELDS (TREE_TYPE (dt_parm)), NULL_TREE);
-      tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (p->field),
-			  tmp, p->field, NULL_TREE);
-      tmp = fold_build2 (BIT_AND_EXPR, TREE_TYPE (tmp),
-			  tmp, build_int_cst (TREE_TYPE (tmp),
-			  IOPARM_common_libreturn_mask));
+      tmp = fold_build3_loc (input_location, COMPONENT_REF,
+			     st_parameter[IOPARM_ptype_common].type,
+			     dt_parm, TYPE_FIELDS (TREE_TYPE (dt_parm)),
+			     NULL_TREE);
+      tmp = fold_build3_loc (input_location, COMPONENT_REF,
+			     TREE_TYPE (p->field), tmp, p->field, NULL_TREE);
+      tmp = fold_build2_loc (input_location, BIT_AND_EXPR, TREE_TYPE (tmp),
+			     tmp, build_int_cst (TREE_TYPE (tmp),
+			     IOPARM_common_libreturn_mask));
     }
   else /* IOLENGTH */
     tmp = NULL_TREE;
Index: gcc/fortran/trans-openmp.c
===================================================================
--- gcc/fortran/trans-openmp.c	(Revision 163788)
+++ gcc/fortran/trans-openmp.c	(Arbeitskopie)
@@ -176,16 +176,17 @@  gfc_omp_clause_default_ctor (tree clause
   gfc_add_modify (&cond_block, decl, outer);
   rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
   size = gfc_conv_descriptor_ubound_get (decl, rank);
-  size = fold_build2 (MINUS_EXPR, gfc_array_index_type, size,
-		      gfc_conv_descriptor_lbound_get (decl, rank));
-  size = fold_build2 (PLUS_EXPR, gfc_array_index_type, size,
-		      gfc_index_one_node);
+  size = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+			  size, gfc_conv_descriptor_lbound_get (decl, rank));
+  size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+			  size, gfc_index_one_node);
   if (GFC_TYPE_ARRAY_RANK (type) > 1)
-    size = fold_build2 (MULT_EXPR, gfc_array_index_type, size,
-			gfc_conv_descriptor_stride_get (decl, rank));
+    size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			    size, gfc_conv_descriptor_stride_get (decl, rank));
   esize = fold_convert (gfc_array_index_type,
 			TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-  size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, esize);
+  size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			  size, esize);
   size = gfc_evaluate_now (fold_convert (size_type_node, size), &cond_block);
   ptr = gfc_allocate_array_with_status (&cond_block,
 					build_int_cst (pvoid_type_node, 0),
@@ -197,10 +198,10 @@  gfc_omp_clause_default_ctor (tree clause
   gfc_conv_descriptor_data_set (&cond_block, decl, null_pointer_node);
   else_b = gfc_finish_block (&cond_block);
 
-  cond = fold_build2 (NE_EXPR, boolean_type_node,
-		      fold_convert (pvoid_type_node,
-				    gfc_conv_descriptor_data_get (outer)),
-		      null_pointer_node);
+  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
+			  fold_convert (pvoid_type_node,
+					gfc_conv_descriptor_data_get (outer)),
+			  null_pointer_node);
   gfc_add_expr_to_block (&block, build3 (COND_EXPR, void_type_node,
 			 cond, then_b, else_b));
 
@@ -228,16 +229,17 @@  gfc_omp_clause_copy_ctor (tree clause, t
   gfc_add_modify (&block, dest, src);
   rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
   size = gfc_conv_descriptor_ubound_get (dest, rank);
-  size = fold_build2 (MINUS_EXPR, gfc_array_index_type, size,
-		      gfc_conv_descriptor_lbound_get (dest, rank));
-  size = fold_build2 (PLUS_EXPR, gfc_array_index_type, size,
-		      gfc_index_one_node);
+  size = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+			  size, gfc_conv_descriptor_lbound_get (dest, rank));
+  size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+			  size, gfc_index_one_node);
   if (GFC_TYPE_ARRAY_RANK (type) > 1)
-    size = fold_build2 (MULT_EXPR, gfc_array_index_type, size,
-			gfc_conv_descriptor_stride_get (dest, rank));
+    size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			    size, gfc_conv_descriptor_stride_get (dest, rank));
   esize = fold_convert (gfc_array_index_type,
 			TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-  size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, esize);
+  size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			  size, esize);
   size = gfc_evaluate_now (fold_convert (size_type_node, size), &block);
   ptr = gfc_allocate_array_with_status (&block,
 					build_int_cst (pvoid_type_node, 0),
@@ -270,16 +272,17 @@  gfc_omp_clause_assign_op (tree clause AT
 
   rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
   size = gfc_conv_descriptor_ubound_get (dest, rank);
-  size = fold_build2 (MINUS_EXPR, gfc_array_index_type, size,
-		      gfc_conv_descriptor_lbound_get (dest, rank));
-  size = fold_build2 (PLUS_EXPR, gfc_array_index_type, size,
-		      gfc_index_one_node);
+  size = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+			  size, gfc_conv_descriptor_lbound_get (dest, rank));
+  size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+			  size, gfc_index_one_node);
   if (GFC_TYPE_ARRAY_RANK (type) > 1)
-    size = fold_build2 (MULT_EXPR, gfc_array_index_type, size,
-			gfc_conv_descriptor_stride_get (dest, rank));
+    size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			    size, gfc_conv_descriptor_stride_get (dest, rank));
   esize = fold_convert (gfc_array_index_type,
 			TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-  size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, esize);
+  size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			  size, esize);
   size = gfc_evaluate_now (fold_convert (size_type_node, size), &block);
   call = build_call_expr_loc (input_location,
 			  built_in_decls[BUILT_IN_MEMCPY], 3,
@@ -634,16 +637,19 @@  gfc_trans_omp_array_reduction (tree c, g
       gfc_add_modify (&block, decl, outer_sym.backend_decl);
       rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
       size = gfc_conv_descriptor_ubound_get (decl, rank);
-      size = fold_build2 (MINUS_EXPR, gfc_array_index_type, size,
-			  gfc_conv_descriptor_lbound_get (decl, rank));
-      size = fold_build2 (PLUS_EXPR, gfc_array_index_type, size,
-			  gfc_index_one_node);
+      size = fold_build2_loc (input_location, MINUS_EXPR,
+			      gfc_array_index_type, size,
+			      gfc_conv_descriptor_lbound_get (decl, rank));
+      size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+			      size, gfc_index_one_node);
       if (GFC_TYPE_ARRAY_RANK (type) > 1)
-	size = fold_build2 (MULT_EXPR, gfc_array_index_type, size,
-			    gfc_conv_descriptor_stride_get (decl, rank));
+	size = fold_build2_loc (input_location, MULT_EXPR,
+				gfc_array_index_type, size,
+				gfc_conv_descriptor_stride_get (decl, rank));
       esize = fold_convert (gfc_array_index_type,
 			    TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-      size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, esize);
+      size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			      size, esize);
       size = gfc_evaluate_now (fold_convert (size_type_node, size), &block);
       ptr = gfc_allocate_array_with_status (&block,
 					    build_int_cst (pvoid_type_node, 0),
@@ -1100,7 +1106,8 @@  gfc_trans_omp_atomic (gfc_code *code)
 	      gfc_init_block (&rse.pre);
 	      gfc_conv_expr (&rse, arg->expr);
 	      gfc_add_block_to_block (&block, &rse.pre);
-	      x = fold_build2 (op, TREE_TYPE (accum), accum, rse.expr);
+	      x = fold_build2_loc (input_location, op, TREE_TYPE (accum),
+				   accum, rse.expr);
 	      gfc_add_modify (&block, accum, x);
 	    }
 
@@ -1116,13 +1123,14 @@  gfc_trans_omp_atomic (gfc_code *code)
 							 lhsaddr));
 
   if (var_on_left)
-    x = fold_build2 (op, TREE_TYPE (rhs), x, rhs);
+    x = fold_build2_loc (input_location, op, TREE_TYPE (rhs), x, rhs);
   else
-    x = fold_build2 (op, TREE_TYPE (rhs), rhs, x);
+    x = fold_build2_loc (input_location, op, TREE_TYPE (rhs), rhs, x);
 
   if (TREE_CODE (TREE_TYPE (rhs)) == COMPLEX_TYPE
       && TREE_CODE (type) != COMPLEX_TYPE)
-    x = fold_build1 (REALPART_EXPR, TREE_TYPE (TREE_TYPE (rhs)), x);
+    x = fold_build1_loc (input_location, REALPART_EXPR,
+			 TREE_TYPE (TREE_TYPE (rhs)), x);
 
   x = build2_v (OMP_ATOMIC, lhsaddr, convert (type, x));
   gfc_add_expr_to_block (&block, x);
@@ -1254,11 +1262,16 @@  gfc_trans_omp_do (gfc_code *code, stmtbl
       if (simple)
 	{
 	  TREE_VEC_ELT (init, i) = build2_v (MODIFY_EXPR, dovar, from);
-	  TREE_VEC_ELT (cond, i) = fold_build2 (simple > 0 ? LE_EXPR : GE_EXPR,
-						boolean_type_node, dovar, to);
-	  TREE_VEC_ELT (incr, i) = fold_build2 (PLUS_EXPR, type, dovar, step);
-	  TREE_VEC_ELT (incr, i) = fold_build2 (MODIFY_EXPR, type, dovar,
-						TREE_VEC_ELT (incr, i));
+	  TREE_VEC_ELT (cond, i) = fold_build2_loc (input_location, simple > 0
+						    ? LE_EXPR : GE_EXPR,
+						    boolean_type_node, dovar,
+						    to);
+	  TREE_VEC_ELT (incr, i) = fold_build2_loc (input_location, PLUS_EXPR,
+						    type, dovar, step);
+	  TREE_VEC_ELT (incr, i) = fold_build2_loc (input_location,
+						    MODIFY_EXPR,
+						    type, dovar,
+						    TREE_VEC_ELT (incr, i));
 	}
       else
 	{
@@ -1269,23 +1282,27 @@  gfc_trans_omp_do (gfc_code *code, stmtbl
 		 body;
 	       cycle_label:;
 	       }  */
-	  tmp = fold_build2 (MINUS_EXPR, type, step, from);
-	  tmp = fold_build2 (PLUS_EXPR, type, to, tmp);
-	  tmp = fold_build2 (TRUNC_DIV_EXPR, type, tmp, step);
+	  tmp = fold_build2_loc (input_location, MINUS_EXPR, type, step, from);
+	  tmp = fold_build2_loc (input_location, PLUS_EXPR, type, to, tmp);
+	  tmp = fold_build2_loc (input_location, TRUNC_DIV_EXPR, type, tmp,
+				 step);
 	  tmp = gfc_evaluate_now (tmp, pblock);
 	  count = gfc_create_var (type, "count");
 	  TREE_VEC_ELT (init, i) = build2_v (MODIFY_EXPR, count,
 					     build_int_cst (type, 0));
-	  TREE_VEC_ELT (cond, i) = fold_build2 (LT_EXPR, boolean_type_node,
-						count, tmp);
-	  TREE_VEC_ELT (incr, i) = fold_build2 (PLUS_EXPR, type, count,
-						build_int_cst (type, 1));
-	  TREE_VEC_ELT (incr, i) = fold_build2 (MODIFY_EXPR, type,
-						count, TREE_VEC_ELT (incr, i));
+	  TREE_VEC_ELT (cond, i) = fold_build2_loc (input_location, LT_EXPR,
+						    boolean_type_node,
+						    count, tmp);
+	  TREE_VEC_ELT (incr, i) = fold_build2_loc (input_location, PLUS_EXPR,
+						    type, count,
+						    build_int_cst (type, 1));
+	  TREE_VEC_ELT (incr, i) = fold_build2_loc (input_location,
+						    MODIFY_EXPR, type, count,
+						    TREE_VEC_ELT (incr, i));
 
 	  /* Initialize DOVAR.  */
-	  tmp = fold_build2 (MULT_EXPR, type, count, step);
-	  tmp = fold_build2 (PLUS_EXPR, type, from, tmp);
+	  tmp = fold_build2_loc (input_location, MULT_EXPR, type, count, step);
+	  tmp = fold_build2_loc (input_location, PLUS_EXPR, type, from, tmp);
 	  di = VEC_safe_push (dovar_init, heap, inits, NULL);
 	  di->var = dovar;
 	  di->init = tmp;
@@ -1310,8 +1327,10 @@  gfc_trans_omp_do (gfc_code *code, stmtbl
 		 will have the value on entry of the last loop, rather
 		 than value after iterator increment.  */
 	      tmp = gfc_evaluate_now (step, pblock);
-	      tmp = fold_build2 (PLUS_EXPR, type, dovar, tmp);
-	      tmp = fold_build2 (MODIFY_EXPR, type, dovar, tmp);
+	      tmp = fold_build2_loc (input_location, PLUS_EXPR, type, dovar,
+				     tmp);
+	      tmp = fold_build2_loc (input_location, MODIFY_EXPR, type,
+				     dovar, tmp);
 	      for (c = omp_clauses; c ; c = OMP_CLAUSE_CHAIN (c))
 		if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
 		    && OMP_CLAUSE_DECL (c) == dovar_decl)
Index: gcc/fortran/trans.c
===================================================================
--- gcc/fortran/trans.c	(Revision 163788)
+++ gcc/fortran/trans.c	(Arbeitskopie)
@@ -167,7 +167,8 @@  gfc_add_modify (stmtblock_t * pblock, tr
 	      || AGGREGATE_TYPE_P (TREE_TYPE (lhs)));
 #endif
 
-  tmp = fold_build2 (MODIFY_EXPR, void_type_node, lhs, rhs);
+  tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node, lhs,
+			 rhs);
   gfc_add_expr_to_block (pblock, tmp);
 }
 
@@ -296,7 +297,7 @@  gfc_build_addr_expr (tree type, tree t)
       tree base = get_base_address (t);
       if (base && DECL_P (base))
         TREE_ADDRESSABLE (base) = 1;
-      t = fold_build1 (ADDR_EXPR, natural_type, t);
+      t = fold_build1_loc (input_location, ADDR_EXPR, natural_type, t);
     }
 
   if (type && natural_type != type)
@@ -332,11 +333,13 @@  gfc_build_array_ref (tree base, tree off
 	&& GFC_DECL_SUBREF_ARRAY_P (decl)
 	&& !integer_zerop (GFC_DECL_SPAN(decl)))
     {
-      offset = fold_build2 (MULT_EXPR, gfc_array_index_type,
-			    offset, GFC_DECL_SPAN(decl));
+      offset = fold_build2_loc (input_location, MULT_EXPR,
+				gfc_array_index_type,
+				offset, GFC_DECL_SPAN(decl));
       tmp = gfc_build_addr_expr (pvoid_type_node, base);
-      tmp = fold_build2 (POINTER_PLUS_EXPR, pvoid_type_node,
-			 tmp, fold_convert (sizetype, offset));
+      tmp = fold_build2_loc (input_location, POINTER_PLUS_EXPR,
+			     pvoid_type_node, tmp,
+			     fold_convert (sizetype, offset));
       tmp = fold_convert (build_pointer_type (type), tmp);
       if (!TYPE_STRING_FLAG (type))
 	tmp = build_fold_indirect_ref_loc (input_location, tmp);
@@ -421,11 +424,11 @@  gfc_trans_runtime_error_vararg (bool err
     fntype = TREE_TYPE (gfor_fndecl_runtime_warning_at);
 
   tmp = fold_builtin_call_array (input_location, TREE_TYPE (fntype),
-				 fold_build1 (ADDR_EXPR,
-					      build_pointer_type (fntype),
-					      error
-					      ? gfor_fndecl_runtime_error_at
-					      : gfor_fndecl_runtime_warning_at),
+				 fold_build1_loc (input_location, ADDR_EXPR,
+					     build_pointer_type (fntype),
+					     error
+					     ? gfor_fndecl_runtime_error_at
+					     : gfor_fndecl_runtime_warning_at),
 				 nargs + 2, argarray);
   gfc_add_expr_to_block (&block, tmp);
 
@@ -477,8 +480,8 @@  gfc_trans_runtime_check (bool error, boo
     {
       /* Tell the compiler that this isn't likely.  */
       if (once)
-	cond = fold_build2 (TRUTH_AND_EXPR, long_integer_type_node, tmpvar,
-			    cond);
+	cond = fold_build2_loc (input_location, TRUTH_AND_EXPR,
+				long_integer_type_node, tmpvar, cond);
       else
 	cond = fold_convert (long_integer_type_node, cond);
 
@@ -513,8 +516,8 @@  gfc_call_malloc (stmtblock_t * block, tr
   /* Call malloc.  */
   gfc_start_block (&block2);
 
-  size = fold_build2 (MAX_EXPR, size_type_node, size,
-		      build_int_cst (size_type_node, 1));
+  size = fold_build2_loc (input_location, MAX_EXPR, size_type_node, size,
+			  build_int_cst (size_type_node, 1));
 
   gfc_add_modify (&block2, res,
 		  fold_convert (prvoid_type_node,
@@ -524,11 +527,13 @@  gfc_call_malloc (stmtblock_t * block, tr
   /* Optionally check whether malloc was successful.  */
   if (gfc_option.rtcheck & GFC_RTCHECK_MEM)
     {
-      null_result = fold_build2 (EQ_EXPR, boolean_type_node, res,
-				 build_int_cst (pvoid_type_node, 0));
+      null_result = fold_build2_loc (input_location, EQ_EXPR,
+				     boolean_type_node, res,
+				     build_int_cst (pvoid_type_node, 0));
       msg = gfc_build_addr_expr (pchar_type_node,
 	      gfc_build_localized_cstring_const ("Memory allocation failed"));
-      tmp = fold_build3 (COND_EXPR, void_type_node, null_result,
+      tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+			     null_result,
 	      build_call_expr_loc (input_location,
 				   gfor_fndecl_os_error, 1, msg),
 				   build_empty_stmt (input_location));
@@ -601,13 +606,15 @@  gfc_allocate_with_status (stmtblock_t *
   /* Set the optional status variable to zero.  */
   if (status != NULL_TREE && !integer_zerop (status))
     {
-      tmp = fold_build2 (MODIFY_EXPR, status_type,
-			 fold_build1 (INDIRECT_REF, status_type, status),
-			 build_int_cst (status_type, 0));
-      tmp = fold_build3 (COND_EXPR, void_type_node,
-			 fold_build2 (NE_EXPR, boolean_type_node, status,
-				      build_int_cst (TREE_TYPE (status), 0)),
-			 tmp, build_empty_stmt (input_location));
+      tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
+			     fold_build1_loc (input_location, INDIRECT_REF,
+					      status_type, status),
+			     build_int_cst (status_type, 0));
+      tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+			     fold_build2_loc (input_location, NE_EXPR,
+					boolean_type_node, status,
+					build_int_cst (TREE_TYPE (status), 0)),
+			     tmp, build_empty_stmt (input_location));
       gfc_add_expr_to_block (block, tmp);
     }
 
@@ -625,15 +632,16 @@  gfc_allocate_with_status (stmtblock_t *
 
       gfc_start_block (&set_status_block);
       gfc_add_modify (&set_status_block,
-		      fold_build1 (INDIRECT_REF, status_type, status),
+		      fold_build1_loc (input_location, INDIRECT_REF,
+				       status_type, status),
 			   build_int_cst (status_type, LIBERROR_ALLOCATION));
       gfc_add_modify (&set_status_block, res,
 			   build_int_cst (prvoid_type_node, 0));
 
-      tmp = fold_build2 (EQ_EXPR, boolean_type_node, status,
-			 build_int_cst (TREE_TYPE (status), 0));
-      error = fold_build3 (COND_EXPR, void_type_node, tmp, error,
-			   gfc_finish_block (&set_status_block));
+      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
+			     status, build_int_cst (TREE_TYPE (status), 0));
+      error = fold_build3_loc (input_location, COND_EXPR, void_type_node, tmp,
+			       error, gfc_finish_block (&set_status_block));
     }
 
   /* The allocation itself.  */
@@ -642,9 +650,10 @@  gfc_allocate_with_status (stmtblock_t *
 		  fold_convert (prvoid_type_node,
 				build_call_expr_loc (input_location,
 				   built_in_decls[BUILT_IN_MALLOC], 1,
-					fold_build2 (MAX_EXPR, size_type_node,
-						     size,
-						     build_int_cst (size_type_node, 1)))));
+					fold_build2_loc (input_location,
+					    MAX_EXPR, size_type_node, size,
+					    build_int_cst (size_type_node,
+							   1)))));
 
   msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
 						("Out of memory"));
@@ -656,25 +665,27 @@  gfc_allocate_with_status (stmtblock_t *
       /* Set the status variable if it's present.  */
       tree tmp2;
 
-      cond = fold_build2 (EQ_EXPR, boolean_type_node, status,
-			  build_int_cst (TREE_TYPE (status), 0));
-      tmp2 = fold_build2 (MODIFY_EXPR, status_type,
-			  fold_build1 (INDIRECT_REF, status_type, status),
-			  build_int_cst (status_type, LIBERROR_ALLOCATION));
-      tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
-			 tmp2);
+      cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
+			      status, build_int_cst (TREE_TYPE (status), 0));
+      tmp2 = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
+			      fold_build1_loc (input_location, INDIRECT_REF,
+					       status_type, status),
+			      build_int_cst (status_type, LIBERROR_ALLOCATION));
+      tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond,
+			     tmp, tmp2);
     }
 
-  tmp = fold_build3 (COND_EXPR, void_type_node,
-		     fold_build2 (EQ_EXPR, boolean_type_node, res,
-				  build_int_cst (prvoid_type_node, 0)),
-		     tmp, build_empty_stmt (input_location));
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+			 fold_build2_loc (input_location, EQ_EXPR,
+					  boolean_type_node, res,
+					  build_int_cst (prvoid_type_node, 0)),
+			 tmp, build_empty_stmt (input_location));
   gfc_add_expr_to_block (&alloc_block, tmp);
 
-  cond = fold_build2 (LT_EXPR, boolean_type_node, size,
-		      build_int_cst (TREE_TYPE (size), 0));
-  tmp = fold_build3 (COND_EXPR, void_type_node, cond, error,
-		     gfc_finish_block (&alloc_block));
+  cond = fold_build2_loc (input_location, LT_EXPR, boolean_type_node, size,
+			  build_int_cst (TREE_TYPE (size), 0));
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, error,
+			 gfc_finish_block (&alloc_block));
   gfc_add_expr_to_block (block, tmp);
 
   return res;
@@ -721,8 +732,8 @@  gfc_allocate_array_with_status (stmtbloc
 
   /* Create a variable to hold the result.  */
   res = gfc_create_var (type, NULL);
-  null_mem = fold_build2 (EQ_EXPR, boolean_type_node, mem,
-			  build_int_cst (type, 0));
+  null_mem = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, mem,
+			      build_int_cst (type, 0));
 
   /* If mem is NULL, we call gfc_allocate_with_status.  */
   gfc_start_block (&alloc_block);
@@ -764,16 +775,18 @@  gfc_allocate_array_with_status (stmtbloc
       gfc_add_modify (&set_status_block, res, fold_convert (type, tmp));
 
       gfc_add_modify (&set_status_block,
-			   fold_build1 (INDIRECT_REF, status_type, status),
+			   fold_build1_loc (input_location, INDIRECT_REF,
+					    status_type, status),
 			   build_int_cst (status_type, LIBERROR_ALLOCATION));
 
-      tmp = fold_build2 (EQ_EXPR, boolean_type_node, status,
-			 build_int_cst (status_type, 0));
-      error = fold_build3 (COND_EXPR, void_type_node, tmp, error,
-			   gfc_finish_block (&set_status_block));
+      tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
+			     status, build_int_cst (status_type, 0));
+      error = fold_build3_loc (input_location, COND_EXPR, void_type_node, tmp,
+			       error, gfc_finish_block (&set_status_block));
     }
 
-  tmp = fold_build3 (COND_EXPR, void_type_node, null_mem, alloc, error);
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, null_mem,
+			 alloc, error);
   gfc_add_expr_to_block (block, tmp);
 
   return res;
@@ -792,12 +805,12 @@  gfc_call_free (tree var)
 
   gfc_start_block (&block);
   var = gfc_evaluate_now (var, &block);
-  cond = fold_build2 (NE_EXPR, boolean_type_node, var,
-		      build_int_cst (pvoid_type_node, 0));
+  cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, var,
+			  build_int_cst (pvoid_type_node, 0));
   call = build_call_expr_loc (input_location,
-			  built_in_decls[BUILT_IN_FREE], 1, var);
-  tmp = fold_build3 (COND_EXPR, void_type_node, cond, call,
-		     build_empty_stmt (input_location));
+			      built_in_decls[BUILT_IN_FREE], 1, var);
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, call,
+			 build_empty_stmt (input_location));
   gfc_add_expr_to_block (&block, tmp);
 
   return gfc_finish_block (&block);
@@ -841,8 +854,8 @@  gfc_deallocate_with_status (tree pointer
   stmtblock_t null, non_null;
   tree cond, tmp, error;
 
-  cond = fold_build2 (EQ_EXPR, boolean_type_node, pointer,
-		      build_int_cst (TREE_TYPE (pointer), 0));
+  cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, pointer,
+			  build_int_cst (TREE_TYPE (pointer), 0));
 
   /* When POINTER is NULL, we set STATUS to 1 if it's present, otherwise
      we emit a runtime error.  */
@@ -868,12 +881,14 @@  gfc_deallocate_with_status (tree pointer
       tree status_type = TREE_TYPE (TREE_TYPE (status));
       tree cond2;
 
-      cond2 = fold_build2 (NE_EXPR, boolean_type_node, status,
-			   build_int_cst (TREE_TYPE (status), 0));
-      tmp = fold_build2 (MODIFY_EXPR, status_type,
-			 fold_build1 (INDIRECT_REF, status_type, status),
-			 build_int_cst (status_type, 1));
-      error = fold_build3 (COND_EXPR, void_type_node, cond2, tmp, error);
+      cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
+			       status, build_int_cst (TREE_TYPE (status), 0));
+      tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
+			     fold_build1_loc (input_location, INDIRECT_REF,
+					      status_type, status),
+			     build_int_cst (status_type, 1));
+      error = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+			       cond2, tmp, error);
     }
 
   gfc_add_expr_to_block (&null, error);
@@ -891,18 +906,20 @@  gfc_deallocate_with_status (tree pointer
       tree status_type = TREE_TYPE (TREE_TYPE (status));
       tree cond2;
 
-      cond2 = fold_build2 (NE_EXPR, boolean_type_node, status,
-			   build_int_cst (TREE_TYPE (status), 0));
-      tmp = fold_build2 (MODIFY_EXPR, status_type,
-			 fold_build1 (INDIRECT_REF, status_type, status),
-			 build_int_cst (status_type, 0));
-      tmp = fold_build3 (COND_EXPR, void_type_node, cond2, tmp,
-			 build_empty_stmt (input_location));
+      cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
+			       status, build_int_cst (TREE_TYPE (status), 0));
+      tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
+			     fold_build1_loc (input_location, INDIRECT_REF,
+					      status_type, status),
+			     build_int_cst (status_type, 0));
+      tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond2,
+			     tmp, build_empty_stmt (input_location));
       gfc_add_expr_to_block (&non_null, tmp);
     }
 
-  return fold_build3 (COND_EXPR, void_type_node, cond,
-		      gfc_finish_block (&null), gfc_finish_block (&non_null));
+  return fold_build3_loc (input_location, COND_EXPR, void_type_node, cond,
+			  gfc_finish_block (&null),
+			  gfc_finish_block (&non_null));
 }
 
 
@@ -938,14 +955,14 @@  gfc_call_realloc (stmtblock_t * block, t
   res = gfc_create_var (type, NULL);
 
   /* size < 0 ?  */
-  negative = fold_build2 (LT_EXPR, boolean_type_node, size,
-			  build_int_cst (size_type_node, 0));
+  negative = fold_build2_loc (input_location, LT_EXPR, boolean_type_node, size,
+			      build_int_cst (size_type_node, 0));
   msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
       ("Attempt to allocate a negative amount of memory."));
-  tmp = fold_build3 (COND_EXPR, void_type_node, negative,
-		     build_call_expr_loc (input_location,
-				      gfor_fndecl_runtime_error, 1, msg),
-		     build_empty_stmt (input_location));
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, negative,
+			 build_call_expr_loc (input_location,
+					    gfor_fndecl_runtime_error, 1, msg),
+			 build_empty_stmt (input_location));
   gfc_add_expr_to_block (block, tmp);
 
   /* Call realloc and check the result.  */
@@ -953,25 +970,28 @@  gfc_call_realloc (stmtblock_t * block, t
 			 built_in_decls[BUILT_IN_REALLOC], 2,
 			 fold_convert (pvoid_type_node, mem), size);
   gfc_add_modify (block, res, fold_convert (type, tmp));
-  null_result = fold_build2 (EQ_EXPR, boolean_type_node, res,
-			     build_int_cst (pvoid_type_node, 0));
-  nonzero = fold_build2 (NE_EXPR, boolean_type_node, size,
-			 build_int_cst (size_type_node, 0));
-  null_result = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, null_result,
-			     nonzero);
+  null_result = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node,
+				 res, build_int_cst (pvoid_type_node, 0));
+  nonzero = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, size,
+			     build_int_cst (size_type_node, 0));
+  null_result = fold_build2_loc (input_location, TRUTH_AND_EXPR, boolean_type_node,
+				 null_result, nonzero);
   msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
 						("Out of memory"));
-  tmp = fold_build3 (COND_EXPR, void_type_node, null_result,
-		     build_call_expr_loc (input_location,
-				      gfor_fndecl_os_error, 1, msg),
-		     build_empty_stmt (input_location));
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
+			 null_result,
+			 build_call_expr_loc (input_location,
+					      gfor_fndecl_os_error, 1, msg),
+			 build_empty_stmt (input_location));
   gfc_add_expr_to_block (block, tmp);
 
   /* if (size == 0) then the result is NULL.  */
-  tmp = fold_build2 (MODIFY_EXPR, type, res, build_int_cst (type, 0));
-  zero = fold_build1 (TRUTH_NOT_EXPR, boolean_type_node, nonzero);
-  tmp = fold_build3 (COND_EXPR, void_type_node, zero, tmp,
-		     build_empty_stmt (input_location));
+  tmp = fold_build2_loc (input_location, MODIFY_EXPR, type, res,
+			 build_int_cst (type, 0));
+  zero = fold_build1_loc (input_location, TRUTH_NOT_EXPR, boolean_type_node,
+			  nonzero);
+  tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, zero, tmp,
+			 build_empty_stmt (input_location));
   gfc_add_expr_to_block (block, tmp);
 
   return res;