Commit bc98ed60 by Tobias Burnus Committed by Tobias Burnus

re PR fortran/45186 (Gfortran 4.5.0 emits wrong linenumbers)

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

        PR fortran/45186
        * trans-common.c (create_common): Change build[0-9] to
        build[0-9]_loc.
        * trans-const.c (gfc_conv_constant_to_tree,
        gfc_conv_constant_to_tree): Ditto.
        * trans-decl.c (gfc_build_qualified_array, build_entry_thunks,
        gfc_get_fake_result_decl, gfc_trans_auto_character_variable,
        add_argument_checking, create_main_function,
        gfc_generate_return): Ditto.
        * trans-types.c (gfc_get_dtype, gfc_get_array_type_bounds):
        * Ditto.
        * trans-stmt.c (allocate_temp_for_forall_nest_1,
        compute_inner_temp_size, compute_overall_iter_number,
        generate_loop_for_rhs_to_temp, generate_loop_for_temp_to_lhs,
        gfc_conv_elemental_dependencies, gfc_do_allocate,
        gfc_evaluate_where_mask, gfc_trans_allocate,
        gfc_trans_arithmetic_if, gfc_trans_call,
        gfc_trans_character_select, gfc_trans_deallocate,
        gfc_trans_do, gfc_trans_do_while, gfc_trans_forall_1,
        gfc_trans_forall_loop, gfc_trans_goto, gfc_trans_if_1,
        gfc_trans_integer_select, gfc_trans_logical_select,
        gfc_trans_pointer_assign_need_temp, gfc_trans_return,
        gfc_trans_simple_do, gfc_trans_sync, gfc_trans_where_2,
        gfc_trans_where_assign) Ditto.

From-SVN: r163776
parent 6b8c9df8
2010-09-02 Tobias Burnus <burnus@net-b.de>
PR fortran/45186
* trans-common.c (create_common): Change build[0-9] to
build[0-9]_loc.
* trans-const.c (gfc_conv_constant_to_tree,
gfc_conv_constant_to_tree): Ditto.
* trans-decl.c (gfc_build_qualified_array, build_entry_thunks,
gfc_get_fake_result_decl, gfc_trans_auto_character_variable,
add_argument_checking, create_main_function,
gfc_generate_return): Ditto.
* trans-types.c (gfc_get_dtype, gfc_get_array_type_bounds): Ditto.
* trans-stmt.c (allocate_temp_for_forall_nest_1,
compute_inner_temp_size, compute_overall_iter_number,
generate_loop_for_rhs_to_temp, generate_loop_for_temp_to_lhs,
gfc_conv_elemental_dependencies, gfc_do_allocate,
gfc_evaluate_where_mask, gfc_trans_allocate,
gfc_trans_arithmetic_if, gfc_trans_call,
gfc_trans_character_select, gfc_trans_deallocate,
gfc_trans_do, gfc_trans_do_while, gfc_trans_forall_1,
gfc_trans_forall_loop, gfc_trans_goto, gfc_trans_if_1,
gfc_trans_integer_select, gfc_trans_logical_select,
gfc_trans_pointer_assign_need_temp, gfc_trans_return,
gfc_trans_simple_do, gfc_trans_sync, gfc_trans_where_2,
gfc_trans_where_assign) Ditto.
2010-09-02 Janus Weil <janus@gcc.gnu.org> 2010-09-02 Janus Weil <janus@gcc.gnu.org>
PR fortran/44541 PR fortran/44541
......
...@@ -703,8 +703,9 @@ create_common (gfc_common_head *com, segment_info *head, bool saw_equiv) ...@@ -703,8 +703,9 @@ create_common (gfc_common_head *com, segment_info *head, bool saw_equiv)
gfc_add_decl_to_function (var_decl); gfc_add_decl_to_function (var_decl);
SET_DECL_VALUE_EXPR (var_decl, SET_DECL_VALUE_EXPR (var_decl,
fold_build3 (COMPONENT_REF, TREE_TYPE (s->field), fold_build3_loc (input_location, COMPONENT_REF,
decl, s->field, NULL_TREE)); TREE_TYPE (s->field),
decl, s->field, NULL_TREE));
DECL_HAS_VALUE_EXPR_P (var_decl) = 1; DECL_HAS_VALUE_EXPR_P (var_decl) = 1;
GFC_DECL_COMMON_OR_EQUIV (var_decl) = 1; GFC_DECL_COMMON_OR_EQUIV (var_decl) = 1;
......
...@@ -266,29 +266,29 @@ gfc_conv_constant_to_tree (gfc_expr * expr) ...@@ -266,29 +266,29 @@ gfc_conv_constant_to_tree (gfc_expr * expr)
{ {
case BT_INTEGER: case BT_INTEGER:
if (expr->representation.string) if (expr->representation.string)
return fold_build1 (VIEW_CONVERT_EXPR, return fold_build1_loc (input_location, VIEW_CONVERT_EXPR,
gfc_get_int_type (expr->ts.kind), gfc_get_int_type (expr->ts.kind),
gfc_build_string_const (expr->representation.length, gfc_build_string_const (expr->representation.length,
expr->representation.string)); expr->representation.string));
else else
return gfc_conv_mpz_to_tree (expr->value.integer, expr->ts.kind); return gfc_conv_mpz_to_tree (expr->value.integer, expr->ts.kind);
case BT_REAL: case BT_REAL:
if (expr->representation.string) if (expr->representation.string)
return fold_build1 (VIEW_CONVERT_EXPR, return fold_build1_loc (input_location, VIEW_CONVERT_EXPR,
gfc_get_real_type (expr->ts.kind), gfc_get_real_type (expr->ts.kind),
gfc_build_string_const (expr->representation.length, gfc_build_string_const (expr->representation.length,
expr->representation.string)); expr->representation.string));
else else
return gfc_conv_mpfr_to_tree (expr->value.real, expr->ts.kind, expr->is_snan); return gfc_conv_mpfr_to_tree (expr->value.real, expr->ts.kind, expr->is_snan);
case BT_LOGICAL: case BT_LOGICAL:
if (expr->representation.string) if (expr->representation.string)
{ {
tree tmp = fold_build1 (VIEW_CONVERT_EXPR, tree tmp = fold_build1_loc (input_location, VIEW_CONVERT_EXPR,
gfc_get_int_type (expr->ts.kind), gfc_get_int_type (expr->ts.kind),
gfc_build_string_const (expr->representation.length, gfc_build_string_const (expr->representation.length,
expr->representation.string)); expr->representation.string));
if (!integer_zerop (tmp) && !integer_onep (tmp)) if (!integer_zerop (tmp) && !integer_onep (tmp))
gfc_warning ("Assigning value other than 0 or 1 to LOGICAL" gfc_warning ("Assigning value other than 0 or 1 to LOGICAL"
" has undefined result at %L", &expr->where); " has undefined result at %L", &expr->where);
...@@ -300,10 +300,10 @@ gfc_conv_constant_to_tree (gfc_expr * expr) ...@@ -300,10 +300,10 @@ gfc_conv_constant_to_tree (gfc_expr * expr)
case BT_COMPLEX: case BT_COMPLEX:
if (expr->representation.string) if (expr->representation.string)
return fold_build1 (VIEW_CONVERT_EXPR, return fold_build1_loc (input_location, VIEW_CONVERT_EXPR,
gfc_get_complex_type (expr->ts.kind), gfc_get_complex_type (expr->ts.kind),
gfc_build_string_const (expr->representation.length, gfc_build_string_const (expr->representation.length,
expr->representation.string)); expr->representation.string));
else else
{ {
tree real = gfc_conv_mpfr_to_tree (mpc_realref (expr->value.complex), tree real = gfc_conv_mpfr_to_tree (mpc_realref (expr->value.complex),
......
...@@ -724,8 +724,8 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) ...@@ -724,8 +724,8 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
{ {
tree size, range; tree size, range;
size = fold_build2 (MINUS_EXPR, gfc_array_index_type, size = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
GFC_TYPE_ARRAY_SIZE (type), gfc_index_one_node); GFC_TYPE_ARRAY_SIZE (type), gfc_index_one_node);
range = build_range_type (gfc_array_index_type, gfc_index_zero_node, range = build_range_type (gfc_array_index_type, gfc_index_zero_node,
size); size);
TYPE_DOMAIN (type) = range; TYPE_DOMAIN (type) = range;
...@@ -2108,8 +2108,8 @@ build_entry_thunks (gfc_namespace * ns, bool global) ...@@ -2108,8 +2108,8 @@ build_entry_thunks (gfc_namespace * ns, bool global)
pushdecl (union_decl); pushdecl (union_decl);
DECL_CONTEXT (union_decl) = current_function_decl; DECL_CONTEXT (union_decl) = current_function_decl;
tmp = fold_build2 (MODIFY_EXPR, TREE_TYPE (union_decl), tmp = fold_build2_loc (input_location, MODIFY_EXPR,
union_decl, tmp); TREE_TYPE (union_decl), union_decl, tmp);
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
for (field = TYPE_FIELDS (TREE_TYPE (union_decl)); for (field = TYPE_FIELDS (TREE_TYPE (union_decl));
...@@ -2118,9 +2118,10 @@ build_entry_thunks (gfc_namespace * ns, bool global) ...@@ -2118,9 +2118,10 @@ build_entry_thunks (gfc_namespace * ns, bool global)
thunk_sym->result->name) == 0) thunk_sym->result->name) == 0)
break; break;
gcc_assert (field != NULL_TREE); gcc_assert (field != NULL_TREE);
tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field), tmp = fold_build3_loc (input_location, COMPONENT_REF,
union_decl, field, NULL_TREE); TREE_TYPE (field), union_decl, field,
tmp = fold_build2 (MODIFY_EXPR, NULL_TREE);
tmp = fold_build2_loc (input_location, MODIFY_EXPR,
TREE_TYPE (DECL_RESULT (current_function_decl)), TREE_TYPE (DECL_RESULT (current_function_decl)),
DECL_RESULT (current_function_decl), tmp); DECL_RESULT (current_function_decl), tmp);
tmp = build1_v (RETURN_EXPR, tmp); tmp = build1_v (RETURN_EXPR, tmp);
...@@ -2128,7 +2129,7 @@ build_entry_thunks (gfc_namespace * ns, bool global) ...@@ -2128,7 +2129,7 @@ build_entry_thunks (gfc_namespace * ns, bool global)
else if (TREE_TYPE (DECL_RESULT (current_function_decl)) else if (TREE_TYPE (DECL_RESULT (current_function_decl))
!= void_type_node) != void_type_node)
{ {
tmp = fold_build2 (MODIFY_EXPR, tmp = fold_build2_loc (input_location, MODIFY_EXPR,
TREE_TYPE (DECL_RESULT (current_function_decl)), TREE_TYPE (DECL_RESULT (current_function_decl)),
DECL_RESULT (current_function_decl), tmp); DECL_RESULT (current_function_decl), tmp);
tmp = build1_v (RETURN_EXPR, tmp); tmp = build1_v (RETURN_EXPR, tmp);
...@@ -2256,8 +2257,8 @@ gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag) ...@@ -2256,8 +2257,8 @@ gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag)
break; break;
gcc_assert (field != NULL_TREE); gcc_assert (field != NULL_TREE);
decl = fold_build3 (COMPONENT_REF, TREE_TYPE (field), decl = fold_build3_loc (input_location, COMPONENT_REF,
decl, field, NULL_TREE); TREE_TYPE (field), decl, field, NULL_TREE);
} }
var = create_tmp_var_raw (TREE_TYPE (decl), sym->name); var = create_tmp_var_raw (TREE_TYPE (decl), sym->name);
...@@ -2949,7 +2950,7 @@ gfc_trans_auto_character_variable (gfc_symbol * sym, gfc_wrapped_block * block) ...@@ -2949,7 +2950,7 @@ gfc_trans_auto_character_variable (gfc_symbol * sym, gfc_wrapped_block * block)
/* Emit a DECL_EXPR for this variable, which will cause the /* Emit a DECL_EXPR for this variable, which will cause the
gimplifier to allocate storage, and all that good stuff. */ gimplifier to allocate storage, and all that good stuff. */
tmp = fold_build1 (DECL_EXPR, TREE_TYPE (decl), decl); tmp = fold_build1_loc (input_location, DECL_EXPR, TREE_TYPE (decl), decl);
gfc_add_expr_to_block (&init, tmp); gfc_add_expr_to_block (&init, tmp);
gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE); gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
...@@ -4198,27 +4199,29 @@ add_argument_checking (stmtblock_t *block, gfc_symbol *sym) ...@@ -4198,27 +4199,29 @@ add_argument_checking (stmtblock_t *block, gfc_symbol *sym)
/* Build the condition. For optional arguments, an actual length /* Build the condition. For optional arguments, an actual length
of 0 is also acceptable if the associated string is NULL, which of 0 is also acceptable if the associated string is NULL, which
means the argument was not passed. */ means the argument was not passed. */
cond = fold_build2 (comparison, boolean_type_node, cond = fold_build2_loc (input_location, comparison, boolean_type_node,
cl->passed_length, cl->backend_decl); cl->passed_length, cl->backend_decl);
if (fsym->attr.optional) if (fsym->attr.optional)
{ {
tree not_absent; tree not_absent;
tree not_0length; tree not_0length;
tree absent_failed; tree absent_failed;
not_0length = fold_build2 (NE_EXPR, boolean_type_node, not_0length = fold_build2_loc (input_location, NE_EXPR,
cl->passed_length, boolean_type_node,
fold_convert (gfc_charlen_type_node, cl->passed_length,
integer_zero_node)); fold_convert (gfc_charlen_type_node,
integer_zero_node));
/* The symbol needs to be referenced for gfc_get_symbol_decl. */ /* The symbol needs to be referenced for gfc_get_symbol_decl. */
fsym->attr.referenced = 1; fsym->attr.referenced = 1;
not_absent = gfc_conv_expr_present (fsym); not_absent = gfc_conv_expr_present (fsym);
absent_failed = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, absent_failed = fold_build2_loc (input_location, TRUTH_OR_EXPR,
not_0length, not_absent); boolean_type_node, not_0length,
not_absent);
cond = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, cond = fold_build2_loc (input_location, TRUTH_AND_EXPR,
cond, absent_failed); boolean_type_node, cond, absent_failed);
} }
/* Build the runtime check. */ /* Build the runtime check. */
...@@ -4431,8 +4434,9 @@ create_main_function (tree fndecl) ...@@ -4431,8 +4434,9 @@ create_main_function (tree fndecl)
TREE_USED (fndecl) = 1; TREE_USED (fndecl) = 1;
/* "return 0". */ /* "return 0". */
tmp = fold_build2 (MODIFY_EXPR, integer_type_node, DECL_RESULT (ftn_main), tmp = fold_build2_loc (input_location, MODIFY_EXPR, integer_type_node,
build_int_cst (integer_type_node, 0)); DECL_RESULT (ftn_main),
build_int_cst (integer_type_node, 0));
tmp = build1_v (RETURN_EXPR, tmp); tmp = build1_v (RETURN_EXPR, tmp);
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
...@@ -4503,8 +4507,9 @@ gfc_generate_return (void) ...@@ -4503,8 +4507,9 @@ gfc_generate_return (void)
if (result != NULL_TREE) if (result != NULL_TREE)
{ {
result = convert (TREE_TYPE (DECL_RESULT (fndecl)), result); result = convert (TREE_TYPE (DECL_RESULT (fndecl)), result);
result = fold_build2 (MODIFY_EXPR, TREE_TYPE (result), result = fold_build2_loc (input_location, MODIFY_EXPR,
DECL_RESULT (fndecl), result); TREE_TYPE (result), DECL_RESULT (fndecl),
result);
} }
} }
......
...@@ -149,8 +149,8 @@ gfc_trans_goto (gfc_code * code) ...@@ -149,8 +149,8 @@ gfc_trans_goto (gfc_code * code)
gfc_start_block (&se.pre); gfc_start_block (&se.pre);
gfc_conv_label_variable (&se, code->expr1); gfc_conv_label_variable (&se, code->expr1);
tmp = GFC_DECL_STRING_LEN (se.expr); tmp = GFC_DECL_STRING_LEN (se.expr);
tmp = fold_build2 (NE_EXPR, boolean_type_node, tmp, tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, tmp,
build_int_cst (TREE_TYPE (tmp), -1)); build_int_cst (TREE_TYPE (tmp), -1));
gfc_trans_runtime_check (true, false, tmp, &se.pre, &loc, gfc_trans_runtime_check (true, false, tmp, &se.pre, &loc,
"Assigned label is not a target label"); "Assigned label is not a target label");
...@@ -162,7 +162,8 @@ gfc_trans_goto (gfc_code * code) ...@@ -162,7 +162,8 @@ gfc_trans_goto (gfc_code * code)
that's a very fragile business and may break with optimization. So that's a very fragile business and may break with optimization. So
just ignore it. */ just ignore it. */
target = fold_build1 (GOTO_EXPR, void_type_node, assigned_goto); target = fold_build1_loc (input_location, GOTO_EXPR, void_type_node,
assigned_goto);
gfc_add_expr_to_block (&se.pre, target); gfc_add_expr_to_block (&se.pre, target);
return gfc_finish_block (&se.pre); return gfc_finish_block (&se.pre);
} }
...@@ -321,10 +322,11 @@ gfc_conv_elemental_dependencies (gfc_se * se, gfc_se * loopse, ...@@ -321,10 +322,11 @@ gfc_conv_elemental_dependencies (gfc_se * se, gfc_se * loopse,
{ {
tmp = gfc_conv_descriptor_stride_get (info->descriptor, tmp = gfc_conv_descriptor_stride_get (info->descriptor,
gfc_rank_cst[n]); gfc_rank_cst[n]);
tmp = fold_build2 (MULT_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, MULT_EXPR,
loopse->loop->from[n], tmp); gfc_array_index_type,
offset = fold_build2 (MINUS_EXPR, gfc_array_index_type, loopse->loop->from[n], tmp);
offset, tmp); offset = fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type, offset, tmp);
} }
info->offset = gfc_create_var (gfc_array_index_type, NULL); info->offset = gfc_create_var (gfc_array_index_type, NULL);
gfc_add_modify (&se->pre, info->offset, offset); gfc_add_modify (&se->pre, info->offset, offset);
...@@ -452,8 +454,8 @@ gfc_trans_call (gfc_code * code, bool dependency_check, ...@@ -452,8 +454,8 @@ gfc_trans_call (gfc_code * code, bool dependency_check,
index = count1; index = count1;
maskexpr = gfc_build_array_ref (mask, index, NULL); maskexpr = gfc_build_array_ref (mask, index, NULL);
if (invert) if (invert)
maskexpr = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (maskexpr), maskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
maskexpr); TREE_TYPE (maskexpr), maskexpr);
} }
/* Add the subroutine call to the block. */ /* Add the subroutine call to the block. */
...@@ -465,8 +467,9 @@ gfc_trans_call (gfc_code * code, bool dependency_check, ...@@ -465,8 +467,9 @@ gfc_trans_call (gfc_code * code, bool dependency_check,
tmp = build3_v (COND_EXPR, maskexpr, loopse.expr, tmp = build3_v (COND_EXPR, maskexpr, loopse.expr,
build_empty_stmt (input_location)); build_empty_stmt (input_location));
gfc_add_expr_to_block (&loopse.pre, tmp); gfc_add_expr_to_block (&loopse.pre, tmp);
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR,
count1, gfc_index_one_node); gfc_array_index_type,
count1, gfc_index_one_node);
gfc_add_modify (&loopse.pre, count1, tmp); gfc_add_modify (&loopse.pre, count1, tmp);
} }
else else
...@@ -520,8 +523,9 @@ gfc_trans_return (gfc_code * code) ...@@ -520,8 +523,9 @@ gfc_trans_return (gfc_code * code)
/* Note that the actually returned expression is a simple value and /* Note that the actually returned expression is a simple value and
does not depend on any pointers or such; thus we can clean-up with does not depend on any pointers or such; thus we can clean-up with
se.post before returning. */ se.post before returning. */
tmp = fold_build2 (MODIFY_EXPR, TREE_TYPE (result), result, tmp = fold_build2_loc (input_location, MODIFY_EXPR, TREE_TYPE (result),
fold_convert (TREE_TYPE (result), se.expr)); result, fold_convert (TREE_TYPE (result),
se.expr));
gfc_add_expr_to_block (&se.pre, tmp); gfc_add_expr_to_block (&se.pre, tmp);
gfc_add_block_to_block (&se.pre, &se.post); gfc_add_block_to_block (&se.pre, &se.post);
...@@ -644,8 +648,8 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type __attribute__ ((unused))) ...@@ -644,8 +648,8 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type __attribute__ ((unused)))
{ {
tree cond; tree cond;
gfc_conv_expr (&se, code->expr1); gfc_conv_expr (&se, code->expr1);
cond = fold_build2 (NE_EXPR, boolean_type_node, se.expr, cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
build_int_cst (TREE_TYPE (se.expr), 1)); se.expr, build_int_cst (TREE_TYPE (se.expr), 1));
gfc_trans_runtime_check (true, false, cond, &se.pre, gfc_trans_runtime_check (true, false, cond, &se.pre,
&code->expr1->where, "Invalid image number " &code->expr1->where, "Invalid image number "
"%d in SYNC IMAGES", "%d in SYNC IMAGES",
...@@ -734,7 +738,8 @@ gfc_trans_if_1 (gfc_code * code) ...@@ -734,7 +738,8 @@ gfc_trans_if_1 (gfc_code * code)
elsestmt = build_empty_stmt (input_location); elsestmt = build_empty_stmt (input_location);
/* Build the condition expression and add it to the condition block. */ /* Build the condition expression and add it to the condition block. */
stmt = fold_build3 (COND_EXPR, void_type_node, if_se.expr, stmt, elsestmt); stmt = fold_build3_loc (input_location, COND_EXPR, void_type_node,
if_se.expr, stmt, elsestmt);
gfc_add_expr_to_block (&if_se.pre, stmt); gfc_add_expr_to_block (&if_se.pre, stmt);
...@@ -803,11 +808,14 @@ gfc_trans_arithmetic_if (gfc_code * code) ...@@ -803,11 +808,14 @@ gfc_trans_arithmetic_if (gfc_code * code)
branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label2)); branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label2));
if (code->label1->value != code->label3->value) if (code->label1->value != code->label3->value)
tmp = fold_build2 (LT_EXPR, boolean_type_node, se.expr, zero); tmp = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
se.expr, zero);
else else
tmp = fold_build2 (NE_EXPR, boolean_type_node, se.expr, zero); tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
se.expr, zero);
branch1 = fold_build3 (COND_EXPR, void_type_node, tmp, branch1, branch2); branch1 = fold_build3_loc (input_location, COND_EXPR, void_type_node,
tmp, branch1, branch2);
} }
else else
branch1 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label1)); branch1 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label1));
...@@ -817,8 +825,10 @@ gfc_trans_arithmetic_if (gfc_code * code) ...@@ -817,8 +825,10 @@ gfc_trans_arithmetic_if (gfc_code * code)
{ {
/* if (cond <= 0) take branch1 else take branch2. */ /* if (cond <= 0) take branch1 else take branch2. */
branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label3)); branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label3));
tmp = fold_build2 (LE_EXPR, boolean_type_node, se.expr, zero); tmp = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
branch1 = fold_build3 (COND_EXPR, void_type_node, tmp, branch1, branch2); se.expr, zero);
branch1 = fold_build3_loc (input_location, COND_EXPR, void_type_node,
tmp, branch1, branch2);
} }
/* Append the COND_EXPR to the evaluation of COND, and return. */ /* Append the COND_EXPR to the evaluation of COND, and return. */
...@@ -948,7 +958,8 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar, ...@@ -948,7 +958,8 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar,
/* Check whether someone has modified the loop variable. */ /* Check whether someone has modified the loop variable. */
if (gfc_option.rtcheck & GFC_RTCHECK_DO) if (gfc_option.rtcheck & GFC_RTCHECK_DO)
{ {
tmp = fold_build2 (NE_EXPR, boolean_type_node, dovar, saved_dovar); tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
dovar, saved_dovar);
gfc_trans_runtime_check (true, false, tmp, &body, &code->loc, gfc_trans_runtime_check (true, false, tmp, &body, &code->loc,
"Loop variable has been modified"); "Loop variable has been modified");
} }
...@@ -957,17 +968,19 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar, ...@@ -957,17 +968,19 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar,
if (exit_cond) if (exit_cond)
{ {
tmp = build1_v (GOTO_EXPR, exit_label); tmp = build1_v (GOTO_EXPR, exit_label);
tmp = fold_build3 (COND_EXPR, void_type_node, exit_cond, tmp, tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
build_empty_stmt (input_location)); exit_cond, tmp,
build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
} }
/* Evaluate the loop condition. */ /* Evaluate the loop condition. */
cond = fold_build2 (EQ_EXPR, boolean_type_node, dovar, to); cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, dovar,
to);
cond = gfc_evaluate_now (cond, &body); cond = gfc_evaluate_now (cond, &body);
/* Increment the loop variable. */ /* Increment the loop variable. */
tmp = fold_build2 (PLUS_EXPR, type, dovar, step); tmp = fold_build2_loc (input_location, PLUS_EXPR, type, dovar, step);
gfc_add_modify (&body, dovar, tmp); gfc_add_modify (&body, dovar, tmp);
if (gfc_option.rtcheck & GFC_RTCHECK_DO) if (gfc_option.rtcheck & GFC_RTCHECK_DO)
...@@ -976,8 +989,8 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar, ...@@ -976,8 +989,8 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar,
/* The loop exit. */ /* The loop exit. */
tmp = build1_v (GOTO_EXPR, exit_label); tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1; TREE_USED (exit_label) = 1;
tmp = fold_build3 (COND_EXPR, void_type_node, tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
cond, tmp, build_empty_stmt (input_location)); cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
/* Finish the loop body. */ /* Finish the loop body. */
...@@ -986,11 +999,13 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar, ...@@ -986,11 +999,13 @@ gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar,
/* Only execute the loop if the number of iterations is positive. */ /* Only execute the loop if the number of iterations is positive. */
if (tree_int_cst_sgn (step) > 0) if (tree_int_cst_sgn (step) > 0)
cond = fold_build2 (LE_EXPR, boolean_type_node, dovar, to); cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, dovar,
to);
else else
cond = fold_build2 (GE_EXPR, boolean_type_node, dovar, to); cond = fold_build2_loc (input_location, GE_EXPR, boolean_type_node, dovar,
tmp = fold_build3 (COND_EXPR, void_type_node, to);
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 (pblock, tmp); gfc_add_expr_to_block (pblock, tmp);
/* Add the exit label. */ /* Add the exit label. */
...@@ -1080,8 +1095,8 @@ gfc_trans_do (gfc_code * code, tree exit_cond) ...@@ -1080,8 +1095,8 @@ gfc_trans_do (gfc_code * code, tree exit_cond)
if (gfc_option.rtcheck & GFC_RTCHECK_DO) if (gfc_option.rtcheck & GFC_RTCHECK_DO)
{ {
tmp = fold_build2 (EQ_EXPR, boolean_type_node, step, tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, step,
fold_convert (type, integer_zero_node)); fold_convert (type, integer_zero_node));
gfc_trans_runtime_check (true, false, tmp, &block, &code->loc, gfc_trans_runtime_check (true, false, tmp, &block, &code->loc,
"DO step value is zero"); "DO step value is zero");
} }
...@@ -1092,8 +1107,8 @@ gfc_trans_do (gfc_code * code, tree exit_cond) ...@@ -1092,8 +1107,8 @@ gfc_trans_do (gfc_code * code, tree exit_cond)
|| tree_int_cst_equal (step, integer_minus_one_node))) || tree_int_cst_equal (step, integer_minus_one_node)))
return gfc_trans_simple_do (code, &block, dovar, from, to, step, exit_cond); return gfc_trans_simple_do (code, &block, dovar, from, to, step, exit_cond);
pos_step = fold_build2 (GT_EXPR, boolean_type_node, step, pos_step = fold_build2_loc (input_location, GT_EXPR, boolean_type_node, step,
fold_convert (type, integer_zero_node)); fold_convert (type, integer_zero_node));
if (TREE_CODE (type) == INTEGER_TYPE) if (TREE_CODE (type) == INTEGER_TYPE)
utype = unsigned_type_for (type); utype = unsigned_type_for (type);
...@@ -1139,36 +1154,43 @@ gfc_trans_do (gfc_code * code, tree exit_cond) ...@@ -1139,36 +1154,43 @@ gfc_trans_do (gfc_code * code, tree exit_cond)
/* Calculate SIGN (1,step), as (step < 0 ? -1 : 1) */ /* Calculate SIGN (1,step), as (step < 0 ? -1 : 1) */
tmp = fold_build2 (LT_EXPR, boolean_type_node, step, tmp = fold_build2_loc (input_location, LT_EXPR, boolean_type_node, step,
build_int_cst (TREE_TYPE (step), 0)); build_int_cst (TREE_TYPE (step), 0));
step_sign = fold_build3 (COND_EXPR, type, tmp, step_sign = fold_build3_loc (input_location, COND_EXPR, type, tmp,
build_int_cst (type, -1), build_int_cst (type, -1),
build_int_cst (type, 1)); build_int_cst (type, 1));
tmp = fold_build2 (LT_EXPR, boolean_type_node, to, from); tmp = fold_build2_loc (input_location, LT_EXPR, boolean_type_node, to,
pos = fold_build3 (COND_EXPR, void_type_node, tmp, from);
build1_v (GOTO_EXPR, exit_label), pos = fold_build3_loc (input_location, COND_EXPR, void_type_node, tmp,
build_empty_stmt (input_location)); build1_v (GOTO_EXPR, exit_label),
build_empty_stmt (input_location));
tmp = fold_build2 (GT_EXPR, boolean_type_node, to, from); tmp = fold_build2_loc (input_location, GT_EXPR, boolean_type_node, to,
neg = fold_build3 (COND_EXPR, void_type_node, tmp, from);
build1_v (GOTO_EXPR, exit_label), neg = fold_build3_loc (input_location, COND_EXPR, void_type_node, tmp,
build_empty_stmt (input_location)); build1_v (GOTO_EXPR, exit_label),
tmp = fold_build3 (COND_EXPR, void_type_node, pos_step, pos, neg); build_empty_stmt (input_location));
tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
pos_step, pos, neg);
gfc_add_expr_to_block (&block, tmp); gfc_add_expr_to_block (&block, tmp);
/* Calculate the loop count. to-from can overflow, so /* Calculate the loop count. to-from can overflow, so
we cast to unsigned. */ we cast to unsigned. */
to2 = fold_build2 (MULT_EXPR, type, step_sign, to); to2 = fold_build2_loc (input_location, MULT_EXPR, type, step_sign, to);
from2 = fold_build2 (MULT_EXPR, type, step_sign, from); from2 = fold_build2_loc (input_location, MULT_EXPR, type, step_sign,
step2 = fold_build2 (MULT_EXPR, type, step_sign, step); from);
step2 = fold_build2_loc (input_location, MULT_EXPR, type, step_sign,
step);
step2 = fold_convert (utype, step2); step2 = fold_convert (utype, step2);
tmp = fold_build2 (MINUS_EXPR, type, to2, from2); tmp = fold_build2_loc (input_location, MINUS_EXPR, type, to2, from2);
tmp = fold_convert (utype, tmp); tmp = fold_convert (utype, tmp);
tmp = fold_build2 (TRUNC_DIV_EXPR, utype, tmp, step2); tmp = fold_build2_loc (input_location, TRUNC_DIV_EXPR, utype, tmp,
tmp = fold_build2 (MODIFY_EXPR, void_type_node, countm1, tmp); step2);
tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node,
countm1, tmp);
gfc_add_expr_to_block (&block, tmp); gfc_add_expr_to_block (&block, tmp);
} }
else else
...@@ -1177,18 +1199,21 @@ gfc_trans_do (gfc_code * code, tree exit_cond) ...@@ -1177,18 +1199,21 @@ gfc_trans_do (gfc_code * code, tree exit_cond)
This would probably cause more problems that it solves This would probably cause more problems that it solves
when we implement "long double" types. */ when we implement "long double" types. */
tmp = fold_build2 (MINUS_EXPR, type, to, from); tmp = fold_build2_loc (input_location, MINUS_EXPR, type, to, from);
tmp = fold_build2 (RDIV_EXPR, type, tmp, step); tmp = fold_build2_loc (input_location, RDIV_EXPR, type, tmp, step);
tmp = fold_build1 (FIX_TRUNC_EXPR, utype, tmp); tmp = fold_build1_loc (input_location, FIX_TRUNC_EXPR, utype, tmp);
gfc_add_modify (&block, countm1, tmp); gfc_add_modify (&block, countm1, tmp);
/* We need a special check for empty loops: /* We need a special check for empty loops:
empty = (step > 0 ? to < from : to > from); */ empty = (step > 0 ? to < from : to > from); */
tmp = fold_build3 (COND_EXPR, boolean_type_node, pos_step, tmp = fold_build3_loc (input_location, COND_EXPR, boolean_type_node,
fold_build2 (LT_EXPR, boolean_type_node, to, from), pos_step,
fold_build2 (GT_EXPR, boolean_type_node, to, from)); fold_build2_loc (input_location, LT_EXPR,
boolean_type_node, to, from),
fold_build2_loc (input_location, GT_EXPR,
boolean_type_node, to, from));
/* If the loop is empty, go directly to the exit label. */ /* If the loop is empty, go directly to the exit label. */
tmp = fold_build3 (COND_EXPR, void_type_node, tmp, tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, tmp,
build1_v (GOTO_EXPR, exit_label), build1_v (GOTO_EXPR, exit_label),
build_empty_stmt (input_location)); build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp); gfc_add_expr_to_block (&block, tmp);
...@@ -1216,7 +1241,8 @@ gfc_trans_do (gfc_code * code, tree exit_cond) ...@@ -1216,7 +1241,8 @@ gfc_trans_do (gfc_code * code, tree exit_cond)
/* Check whether someone has modified the loop variable. */ /* Check whether someone has modified the loop variable. */
if (gfc_option.rtcheck & GFC_RTCHECK_DO) if (gfc_option.rtcheck & GFC_RTCHECK_DO)
{ {
tmp = fold_build2 (NE_EXPR, boolean_type_node, dovar, saved_dovar); tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, dovar,
saved_dovar);
gfc_trans_runtime_check (true, false, tmp, &body, &code->loc, gfc_trans_runtime_check (true, false, tmp, &body, &code->loc,
"Loop variable has been modified"); "Loop variable has been modified");
} }
...@@ -1225,28 +1251,30 @@ gfc_trans_do (gfc_code * code, tree exit_cond) ...@@ -1225,28 +1251,30 @@ gfc_trans_do (gfc_code * code, tree exit_cond)
if (exit_cond) if (exit_cond)
{ {
tmp = build1_v (GOTO_EXPR, exit_label); tmp = build1_v (GOTO_EXPR, exit_label);
tmp = fold_build3 (COND_EXPR, void_type_node, exit_cond, tmp, tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
build_empty_stmt (input_location)); exit_cond, tmp,
build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
} }
/* Increment the loop variable. */ /* Increment the loop variable. */
tmp = fold_build2 (PLUS_EXPR, type, dovar, step); tmp = fold_build2_loc (input_location, PLUS_EXPR, type, dovar, step);
gfc_add_modify (&body, dovar, tmp); gfc_add_modify (&body, dovar, tmp);
if (gfc_option.rtcheck & GFC_RTCHECK_DO) if (gfc_option.rtcheck & GFC_RTCHECK_DO)
gfc_add_modify (&body, saved_dovar, dovar); gfc_add_modify (&body, saved_dovar, dovar);
/* End with the loop condition. Loop until countm1 == 0. */ /* End with the loop condition. Loop until countm1 == 0. */
cond = fold_build2 (EQ_EXPR, boolean_type_node, countm1, cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, countm1,
build_int_cst (utype, 0)); build_int_cst (utype, 0));
tmp = build1_v (GOTO_EXPR, exit_label); tmp = build1_v (GOTO_EXPR, exit_label);
tmp = fold_build3 (COND_EXPR, void_type_node, tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
cond, tmp, build_empty_stmt (input_location)); cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
/* Decrement the loop count. */ /* Decrement the loop count. */
tmp = fold_build2 (MINUS_EXPR, utype, countm1, build_int_cst (utype, 1)); tmp = fold_build2_loc (input_location, MINUS_EXPR, utype, countm1,
build_int_cst (utype, 1));
gfc_add_modify (&body, countm1, tmp); gfc_add_modify (&body, countm1, tmp);
/* End of loop body. */ /* End of loop body. */
...@@ -1311,13 +1339,14 @@ gfc_trans_do_while (gfc_code * code) ...@@ -1311,13 +1339,14 @@ gfc_trans_do_while (gfc_code * code)
gfc_init_se (&cond, NULL); gfc_init_se (&cond, NULL);
gfc_conv_expr_val (&cond, code->expr1); gfc_conv_expr_val (&cond, code->expr1);
gfc_add_block_to_block (&block, &cond.pre); gfc_add_block_to_block (&block, &cond.pre);
cond.expr = fold_build1 (TRUTH_NOT_EXPR, boolean_type_node, cond.expr); cond.expr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
boolean_type_node, cond.expr);
/* Build "IF (! cond) GOTO exit_label". */ /* Build "IF (! cond) GOTO exit_label". */
tmp = build1_v (GOTO_EXPR, exit_label); tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1; TREE_USED (exit_label) = 1;
tmp = fold_build3 (COND_EXPR, void_type_node, tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
cond.expr, tmp, build_empty_stmt (input_location)); cond.expr, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp); gfc_add_expr_to_block (&block, tmp);
/* The main body of the loop. */ /* The main body of the loop. */
...@@ -1470,8 +1499,8 @@ gfc_trans_integer_select (gfc_code * code) ...@@ -1470,8 +1499,8 @@ gfc_trans_integer_select (gfc_code * code)
/* Add this case label. /* Add this case label.
Add parameter 'label', make it match GCC backend. */ Add parameter 'label', make it match GCC backend. */
tmp = fold_build3 (CASE_LABEL_EXPR, void_type_node, tmp = fold_build3_loc (input_location, CASE_LABEL_EXPR,
low, high, label); void_type_node, low, high, label);
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
} }
...@@ -1586,8 +1615,8 @@ gfc_trans_logical_select (gfc_code * code) ...@@ -1586,8 +1615,8 @@ gfc_trans_logical_select (gfc_code * code)
if (f != NULL) if (f != NULL)
false_tree = gfc_trans_code (f->next); false_tree = gfc_trans_code (f->next);
stmt = fold_build3 (COND_EXPR, void_type_node, se.expr, stmt = fold_build3_loc (input_location, COND_EXPR, void_type_node,
true_tree, false_tree); se.expr, true_tree, false_tree);
gfc_add_expr_to_block (&block, stmt); gfc_add_expr_to_block (&block, stmt);
} }
...@@ -1748,8 +1777,8 @@ gfc_trans_character_select (gfc_code *code) ...@@ -1748,8 +1777,8 @@ gfc_trans_character_select (gfc_code *code)
/* Add this case label. /* Add this case label.
Add parameter 'label', make it match GCC backend. */ Add parameter 'label', make it match GCC backend. */
tmp = fold_build3 (CASE_LABEL_EXPR, void_type_node, tmp = fold_build3_loc (input_location, CASE_LABEL_EXPR,
low, high, label); void_type_node, low, high, label);
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
} }
...@@ -1828,10 +1857,11 @@ gfc_trans_character_select (gfc_code *code) ...@@ -1828,10 +1857,11 @@ gfc_trans_character_select (gfc_code *code)
for (d = c->ext.case_list; d; d = d->next) for (d = c->ext.case_list; d; d = d->next)
{ {
label = gfc_build_label_decl (NULL_TREE); label = gfc_build_label_decl (NULL_TREE);
tmp = fold_build3 (CASE_LABEL_EXPR, void_type_node, tmp = fold_build3_loc (input_location, CASE_LABEL_EXPR,
(d->low == NULL && d->high == NULL) void_type_node,
? NULL : build_int_cst (NULL_TREE, d->n), (d->low == NULL && d->high == NULL)
NULL, label); ? NULL : build_int_cst (NULL_TREE, d->n),
NULL, label);
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
} }
...@@ -2218,18 +2248,19 @@ gfc_trans_forall_loop (forall_info *forall_tmp, tree body, ...@@ -2218,18 +2248,19 @@ gfc_trans_forall_loop (forall_info *forall_tmp, tree body,
gfc_init_block (&block); gfc_init_block (&block);
/* The exit condition. */ /* The exit condition. */
cond = fold_build2 (LE_EXPR, boolean_type_node, cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
count, build_int_cst (TREE_TYPE (count), 0)); count, build_int_cst (TREE_TYPE (count), 0));
tmp = build1_v (GOTO_EXPR, exit_label); tmp = build1_v (GOTO_EXPR, exit_label);
tmp = fold_build3 (COND_EXPR, void_type_node, tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
cond, tmp, build_empty_stmt (input_location)); cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp); gfc_add_expr_to_block (&block, tmp);
/* The main loop body. */ /* The main loop body. */
gfc_add_expr_to_block (&block, body); gfc_add_expr_to_block (&block, body);
/* Increment the loop variable. */ /* Increment the loop variable. */
tmp = fold_build2 (PLUS_EXPR, TREE_TYPE (var), var, step); tmp = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (var), var,
step);
gfc_add_modify (&block, var, tmp); gfc_add_modify (&block, var, tmp);
/* Advance to the next mask element. Only do this for the /* Advance to the next mask element. Only do this for the
...@@ -2237,14 +2268,14 @@ gfc_trans_forall_loop (forall_info *forall_tmp, tree body, ...@@ -2237,14 +2268,14 @@ gfc_trans_forall_loop (forall_info *forall_tmp, tree body,
if (n == 0 && mask_flag && forall_tmp->mask) if (n == 0 && mask_flag && forall_tmp->mask)
{ {
tree maskindex = forall_tmp->maskindex; tree maskindex = forall_tmp->maskindex;
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
maskindex, gfc_index_one_node); maskindex, gfc_index_one_node);
gfc_add_modify (&block, maskindex, tmp); gfc_add_modify (&block, maskindex, tmp);
} }
/* Decrement the loop counter. */ /* Decrement the loop counter. */
tmp = fold_build2 (MINUS_EXPR, TREE_TYPE (var), count, tmp = fold_build2_loc (input_location, MINUS_EXPR, TREE_TYPE (var), count,
build_int_cst (TREE_TYPE (var), 1)); build_int_cst (TREE_TYPE (var), 1));
gfc_add_modify (&block, count, tmp); gfc_add_modify (&block, count, tmp);
body = gfc_finish_block (&block); body = gfc_finish_block (&block);
...@@ -2255,9 +2286,12 @@ gfc_trans_forall_loop (forall_info *forall_tmp, tree body, ...@@ -2255,9 +2286,12 @@ gfc_trans_forall_loop (forall_info *forall_tmp, tree body,
/* Initialize the loop counter. */ /* Initialize the loop counter. */
tmp = fold_build2 (MINUS_EXPR, TREE_TYPE (var), step, start); tmp = fold_build2_loc (input_location, MINUS_EXPR, TREE_TYPE (var), step,
tmp = fold_build2 (PLUS_EXPR, TREE_TYPE (var), end, tmp); start);
tmp = fold_build2 (TRUNC_DIV_EXPR, TREE_TYPE (var), tmp, step); tmp = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (var), end,
tmp);
tmp = fold_build2_loc (input_location, TRUNC_DIV_EXPR, TREE_TYPE (var),
tmp, step);
gfc_add_modify (&block, count, tmp); gfc_add_modify (&block, count, tmp);
/* The loop expression. */ /* The loop expression. */
...@@ -2330,10 +2364,8 @@ gfc_do_allocate (tree bytesize, tree size, tree * pdata, stmtblock_t * pblock, ...@@ -2330,10 +2364,8 @@ gfc_do_allocate (tree bytesize, tree size, tree * pdata, stmtblock_t * pblock,
tree tmp; tree tmp;
if (INTEGER_CST_P (size)) if (INTEGER_CST_P (size))
{ tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, size, size, gfc_index_one_node);
gfc_index_one_node);
}
else else
tmp = NULL_TREE; tmp = NULL_TREE;
...@@ -2391,8 +2423,8 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3, ...@@ -2391,8 +2423,8 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3,
gfc_add_block_to_block (&block, &lse.post); gfc_add_block_to_block (&block, &lse.post);
/* Increment the count1. */ /* Increment the count1. */
tmp = fold_build2 (PLUS_EXPR, TREE_TYPE (count1), count1, tmp = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (count1),
gfc_index_one_node); count1, gfc_index_one_node);
gfc_add_modify (&block, count1, tmp); gfc_add_modify (&block, count1, tmp);
tmp = gfc_finish_block (&block); tmp = gfc_finish_block (&block);
...@@ -2437,26 +2469,27 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3, ...@@ -2437,26 +2469,27 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3,
{ {
wheremaskexpr = gfc_build_array_ref (wheremask, count3, NULL); wheremaskexpr = gfc_build_array_ref (wheremask, count3, NULL);
if (invert) if (invert)
wheremaskexpr = fold_build1 (TRUTH_NOT_EXPR, wheremaskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
TREE_TYPE (wheremaskexpr), TREE_TYPE (wheremaskexpr),
wheremaskexpr); wheremaskexpr);
tmp = fold_build3 (COND_EXPR, void_type_node, tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
wheremaskexpr, tmp, wheremaskexpr, tmp,
build_empty_stmt (input_location)); build_empty_stmt (input_location));
} }
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
/* Increment count1. */ /* Increment count1. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
count1, gfc_index_one_node); count1, gfc_index_one_node);
gfc_add_modify (&body, count1, tmp); gfc_add_modify (&body, count1, tmp);
/* Increment count3. */ /* Increment count3. */
if (count3) if (count3)
{ {
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR,
count3, gfc_index_one_node); gfc_array_index_type, count3,
gfc_index_one_node);
gfc_add_modify (&body, count3, tmp); gfc_add_modify (&body, count3, tmp);
} }
...@@ -2535,11 +2568,12 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3, ...@@ -2535,11 +2568,12 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3,
{ {
wheremaskexpr = gfc_build_array_ref (wheremask, count3, NULL); wheremaskexpr = gfc_build_array_ref (wheremask, count3, NULL);
if (invert) if (invert)
wheremaskexpr = fold_build1 (TRUTH_NOT_EXPR, wheremaskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
TREE_TYPE (wheremaskexpr), TREE_TYPE (wheremaskexpr),
wheremaskexpr); wheremaskexpr);
tmp = fold_build3 (COND_EXPR, void_type_node, tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
wheremaskexpr, tmp, build_empty_stmt (input_location)); wheremaskexpr, tmp,
build_empty_stmt (input_location));
} }
gfc_add_expr_to_block (&body1, tmp); gfc_add_expr_to_block (&body1, tmp);
...@@ -2549,22 +2583,23 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3, ...@@ -2549,22 +2583,23 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3,
gfc_add_block_to_block (&block, &body1); gfc_add_block_to_block (&block, &body1);
/* Increment count1. */ /* Increment count1. */
tmp = fold_build2 (PLUS_EXPR, TREE_TYPE (count1), count1, tmp = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (count1),
gfc_index_one_node); count1, gfc_index_one_node);
gfc_add_modify (&block, count1, tmp); gfc_add_modify (&block, count1, tmp);
} }
else else
{ {
/* Increment count1. */ /* Increment count1. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
count1, gfc_index_one_node); count1, gfc_index_one_node);
gfc_add_modify (&body1, count1, tmp); gfc_add_modify (&body1, count1, tmp);
/* Increment count3. */ /* Increment count3. */
if (count3) if (count3)
{ {
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR,
count3, gfc_index_one_node); gfc_array_index_type,
count3, gfc_index_one_node);
gfc_add_modify (&body1, count3, tmp); gfc_add_modify (&body1, count3, tmp);
} }
...@@ -2637,11 +2672,13 @@ compute_inner_temp_size (gfc_expr *expr1, gfc_expr *expr2, ...@@ -2637,11 +2672,13 @@ compute_inner_temp_size (gfc_expr *expr1, gfc_expr *expr2,
/* Figure out how many elements we need. */ /* Figure out how many elements we need. */
for (i = 0; i < loop.dimen; i++) for (i = 0; i < loop.dimen; i++)
{ {
tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, MINUS_EXPR,
gfc_index_one_node, loop.from[i]); gfc_array_index_type,
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, gfc_index_one_node, loop.from[i]);
tmp, loop.to[i]); tmp = fold_build2_loc (input_location, PLUS_EXPR,
size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, tmp); gfc_array_index_type, tmp, loop.to[i]);
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size, tmp);
} }
gfc_add_block_to_block (pblock, &loop.pre); gfc_add_block_to_block (pblock, &loop.pre);
size = gfc_evaluate_now (size, pblock); size = gfc_evaluate_now (size, pblock);
...@@ -2679,8 +2716,9 @@ compute_overall_iter_number (forall_info *nested_forall_info, tree inner_size, ...@@ -2679,8 +2716,9 @@ compute_overall_iter_number (forall_info *nested_forall_info, tree inner_size,
&& !forall_tmp->mask && !forall_tmp->mask
&& INTEGER_CST_P (forall_tmp->size)) && INTEGER_CST_P (forall_tmp->size))
{ {
inner_size = fold_build2 (MULT_EXPR, gfc_array_index_type, inner_size = fold_build2_loc (input_location, MULT_EXPR,
inner_size, forall_tmp->size); gfc_array_index_type,
inner_size, forall_tmp->size);
forall_tmp = forall_tmp->prev_nest; forall_tmp = forall_tmp->prev_nest;
} }
...@@ -2697,8 +2735,8 @@ compute_overall_iter_number (forall_info *nested_forall_info, tree inner_size, ...@@ -2697,8 +2735,8 @@ compute_overall_iter_number (forall_info *nested_forall_info, tree inner_size,
if (inner_size_body) if (inner_size_body)
gfc_add_block_to_block (&body, inner_size_body); gfc_add_block_to_block (&body, inner_size_body);
if (forall_tmp) if (forall_tmp)
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR,
number, inner_size); gfc_array_index_type, number, inner_size);
else else
tmp = inner_size; tmp = inner_size;
gfc_add_modify (&body, number, tmp); gfc_add_modify (&body, number, tmp);
...@@ -2727,7 +2765,8 @@ allocate_temp_for_forall_nest_1 (tree type, tree size, stmtblock_t * block, ...@@ -2727,7 +2765,8 @@ allocate_temp_for_forall_nest_1 (tree type, tree size, stmtblock_t * block,
unit = fold_convert (gfc_array_index_type, TYPE_SIZE_UNIT (type)); unit = fold_convert (gfc_array_index_type, TYPE_SIZE_UNIT (type));
if (!integer_onep (unit)) if (!integer_onep (unit))
bytesize = fold_build2 (MULT_EXPR, gfc_array_index_type, size, unit); bytesize = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size, unit);
else else
bytesize = size; bytesize = size;
...@@ -2929,8 +2968,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2, ...@@ -2929,8 +2968,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2,
gfc_add_block_to_block (&body, &rse.post); gfc_add_block_to_block (&body, &rse.post);
/* Increment count. */ /* Increment count. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
count, gfc_index_one_node); count, gfc_index_one_node);
gfc_add_modify (&body, count, tmp); gfc_add_modify (&body, count, tmp);
tmp = gfc_finish_block (&body); tmp = gfc_finish_block (&body);
...@@ -2953,8 +2992,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2, ...@@ -2953,8 +2992,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2,
gfc_add_modify (&body, lse.expr, rse.expr); gfc_add_modify (&body, lse.expr, rse.expr);
gfc_add_block_to_block (&body, &lse.post); gfc_add_block_to_block (&body, &lse.post);
/* Increment count. */ /* Increment count. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
count, gfc_index_one_node); count, gfc_index_one_node);
gfc_add_modify (&body, count, tmp); gfc_add_modify (&body, count, tmp);
tmp = gfc_finish_block (&body); tmp = gfc_finish_block (&body);
...@@ -2998,8 +3037,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2, ...@@ -2998,8 +3037,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2,
gfc_add_block_to_block (&body, &lse.post); gfc_add_block_to_block (&body, &lse.post);
/* Increment count. */ /* Increment count. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
count, gfc_index_one_node); count, gfc_index_one_node);
gfc_add_modify (&body, count, tmp); gfc_add_modify (&body, count, tmp);
tmp = gfc_finish_block (&body); tmp = gfc_finish_block (&body);
...@@ -3022,8 +3061,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2, ...@@ -3022,8 +3061,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2,
gfc_add_block_to_block (&body, &lse.post); gfc_add_block_to_block (&body, &lse.post);
/* Increment count. */ /* Increment count. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
count, gfc_index_one_node); count, gfc_index_one_node);
gfc_add_modify (&body, count, tmp); gfc_add_modify (&body, count, tmp);
tmp = gfc_finish_block (&body); tmp = gfc_finish_block (&body);
...@@ -3199,14 +3238,16 @@ gfc_trans_forall_1 (gfc_code * code, forall_info * nested_forall_info) ...@@ -3199,14 +3238,16 @@ gfc_trans_forall_1 (gfc_code * code, forall_info * nested_forall_info)
for (n = 0; n < nvar; n++) for (n = 0; n < nvar; n++)
{ {
/* size = (end + step - start) / step. */ /* size = (end + step - start) / step. */
tmp = fold_build2 (MINUS_EXPR, TREE_TYPE (start[n]), tmp = fold_build2_loc (input_location, MINUS_EXPR, TREE_TYPE (start[n]),
step[n], start[n]); step[n], start[n]);
tmp = fold_build2 (PLUS_EXPR, TREE_TYPE (end[n]), end[n], tmp); tmp = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (end[n]),
end[n], tmp);
tmp = fold_build2 (FLOOR_DIV_EXPR, TREE_TYPE (tmp), tmp, step[n]); tmp = fold_build2_loc (input_location, FLOOR_DIV_EXPR, TREE_TYPE (tmp),
tmp, step[n]);
tmp = convert (gfc_array_index_type, tmp); tmp = convert (gfc_array_index_type, tmp);
size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, tmp); size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
size, tmp);
} }
/* Record the nvar and size of current forall level. */ /* Record the nvar and size of current forall level. */
...@@ -3273,8 +3314,8 @@ gfc_trans_forall_1 (gfc_code * code, forall_info * nested_forall_info) ...@@ -3273,8 +3314,8 @@ gfc_trans_forall_1 (gfc_code * code, forall_info * nested_forall_info)
gfc_add_modify (&body, tmp, se.expr); gfc_add_modify (&body, tmp, se.expr);
/* Advance to the next mask element. */ /* Advance to the next mask element. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
maskindex, gfc_index_one_node); maskindex, gfc_index_one_node);
gfc_add_modify (&body, maskindex, tmp); gfc_add_modify (&body, maskindex, tmp);
/* Generate the loops. */ /* Generate the loops. */
...@@ -3481,7 +3522,7 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info, ...@@ -3481,7 +3522,7 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info,
{ {
tmp = gfc_build_array_ref (mask, count, NULL); tmp = gfc_build_array_ref (mask, count, NULL);
if (invert) if (invert)
tmp = fold_build1 (TRUTH_NOT_EXPR, mask_type, tmp); tmp = fold_build1_loc (input_location, TRUTH_NOT_EXPR, mask_type, tmp);
gfc_add_modify (&body1, mtmp, tmp); gfc_add_modify (&body1, mtmp, tmp);
} }
...@@ -3490,16 +3531,18 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info, ...@@ -3490,16 +3531,18 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info,
tmp1 = gfc_build_array_ref (cmask, count, NULL); tmp1 = gfc_build_array_ref (cmask, count, NULL);
tmp = cond; tmp = cond;
if (mask) if (mask)
tmp = fold_build2 (TRUTH_AND_EXPR, mask_type, mtmp, tmp); tmp = fold_build2_loc (input_location, TRUTH_AND_EXPR, mask_type,
mtmp, tmp);
gfc_add_modify (&body1, tmp1, tmp); gfc_add_modify (&body1, tmp1, tmp);
} }
if (pmask) if (pmask)
{ {
tmp1 = gfc_build_array_ref (pmask, count, NULL); tmp1 = gfc_build_array_ref (pmask, count, NULL);
tmp = fold_build1 (TRUTH_NOT_EXPR, mask_type, cond); tmp = fold_build1_loc (input_location, TRUTH_NOT_EXPR, mask_type, cond);
if (mask) if (mask)
tmp = fold_build2 (TRUTH_AND_EXPR, mask_type, mtmp, tmp); tmp = fold_build2_loc (input_location, TRUTH_AND_EXPR, mask_type, mtmp,
tmp);
gfc_add_modify (&body1, tmp1, tmp); gfc_add_modify (&body1, tmp1, tmp);
} }
...@@ -3513,8 +3556,8 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info, ...@@ -3513,8 +3556,8 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info,
else else
{ {
/* Increment count. */ /* Increment count. */
tmp1 = fold_build2 (PLUS_EXPR, gfc_array_index_type, count, tmp1 = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
gfc_index_one_node); count, gfc_index_one_node);
gfc_add_modify (&body1, count, tmp1); gfc_add_modify (&body1, count, tmp1);
/* Generate the copying loops. */ /* Generate the copying loops. */
...@@ -3662,7 +3705,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2, ...@@ -3662,7 +3705,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
index = count1; index = count1;
maskexpr = gfc_build_array_ref (mask, index, NULL); maskexpr = gfc_build_array_ref (mask, index, NULL);
if (invert) if (invert)
maskexpr = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (maskexpr), maskexpr); maskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
TREE_TYPE (maskexpr), maskexpr);
/* Use the scalar assignment as is. */ /* Use the scalar assignment as is. */
tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts, tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts,
...@@ -3675,8 +3719,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2, ...@@ -3675,8 +3719,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
if (lss == gfc_ss_terminator) if (lss == gfc_ss_terminator)
{ {
/* Increment count1. */ /* Increment count1. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
count1, gfc_index_one_node); count1, gfc_index_one_node);
gfc_add_modify (&body, count1, tmp); gfc_add_modify (&body, count1, tmp);
/* Use the scalar assignment as is. */ /* Use the scalar assignment as is. */
...@@ -3691,8 +3735,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2, ...@@ -3691,8 +3735,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
{ {
/* Increment count1 before finish the main body of a scalarized /* Increment count1 before finish the main body of a scalarized
expression. */ expression. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR,
count1, gfc_index_one_node); gfc_array_index_type, count1, gfc_index_one_node);
gfc_add_modify (&body, count1, tmp); gfc_add_modify (&body, count1, tmp);
gfc_trans_scalarized_loop_boundary (&loop, &body); gfc_trans_scalarized_loop_boundary (&loop, &body);
...@@ -3716,8 +3760,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2, ...@@ -3716,8 +3760,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
index = count2; index = count2;
maskexpr = gfc_build_array_ref (mask, index, NULL); maskexpr = gfc_build_array_ref (mask, index, NULL);
if (invert) if (invert)
maskexpr = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (maskexpr), maskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
maskexpr); TREE_TYPE (maskexpr), maskexpr);
/* Use the scalar assignment as is. */ /* Use the scalar assignment as is. */
tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts, false, false, tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts, false, false,
...@@ -3727,15 +3771,17 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2, ...@@ -3727,15 +3771,17 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
/* Increment count2. */ /* Increment count2. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR,
count2, gfc_index_one_node); gfc_array_index_type, count2,
gfc_index_one_node);
gfc_add_modify (&body, count2, tmp); gfc_add_modify (&body, count2, tmp);
} }
else else
{ {
/* Increment count1. */ /* Increment count1. */
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR,
count1, gfc_index_one_node); gfc_array_index_type, count1,
gfc_index_one_node);
gfc_add_modify (&body, count1, tmp); gfc_add_modify (&body, count1, tmp);
} }
...@@ -3837,10 +3883,10 @@ gfc_trans_where_2 (gfc_code * code, tree mask, bool invert, ...@@ -3837,10 +3883,10 @@ gfc_trans_where_2 (gfc_code * code, tree mask, bool invert,
&inner_size_body, block); &inner_size_body, block);
/* Check whether the size is negative. */ /* Check whether the size is negative. */
cond = fold_build2 (LE_EXPR, boolean_type_node, size, cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, size,
gfc_index_zero_node); gfc_index_zero_node);
size = fold_build3 (COND_EXPR, gfc_array_index_type, cond, size = fold_build3_loc (input_location, COND_EXPR, gfc_array_index_type,
gfc_index_zero_node, size); cond, gfc_index_zero_node, size);
size = gfc_evaluate_now (size, block); size = gfc_evaluate_now (size, block);
/* Allocate temporary for WHERE mask if needed. */ /* Allocate temporary for WHERE mask if needed. */
...@@ -4351,17 +4397,20 @@ gfc_trans_allocate (gfc_code * code) ...@@ -4351,17 +4397,20 @@ gfc_trans_allocate (gfc_code * code)
tmp = gfc_allocate_with_status (&se.pre, memsz, pstat); tmp = gfc_allocate_with_status (&se.pre, memsz, pstat);
} }
tmp = fold_build2 (MODIFY_EXPR, void_type_node, se.expr, tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node,
fold_convert (TREE_TYPE (se.expr), tmp)); se.expr,
fold_convert (TREE_TYPE (se.expr), tmp));
gfc_add_expr_to_block (&se.pre, tmp); gfc_add_expr_to_block (&se.pre, tmp);
if (code->expr1 || code->expr2) if (code->expr1 || code->expr2)
{ {
tmp = build1_v (GOTO_EXPR, error_label); tmp = build1_v (GOTO_EXPR, error_label);
parm = fold_build2 (NE_EXPR, boolean_type_node, parm = fold_build2_loc (input_location, NE_EXPR,
stat, build_int_cst (TREE_TYPE (stat), 0)); boolean_type_node, stat,
tmp = fold_build3 (COND_EXPR, void_type_node, build_int_cst (TREE_TYPE (stat), 0));
parm, tmp, build_empty_stmt (input_location)); tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
parm, tmp,
build_empty_stmt (input_location));
gfc_add_expr_to_block (&se.pre, tmp); gfc_add_expr_to_block (&se.pre, tmp);
} }
...@@ -4532,14 +4581,15 @@ gfc_trans_allocate (gfc_code * code) ...@@ -4532,14 +4581,15 @@ gfc_trans_allocate (gfc_code * code)
slen = build_int_cst (gfc_charlen_type_node, ((int) strlen (msg))); slen = build_int_cst (gfc_charlen_type_node, ((int) strlen (msg)));
dlen = gfc_get_expr_charlen (code->expr2); dlen = gfc_get_expr_charlen (code->expr2);
slen = fold_build2 (MIN_EXPR, TREE_TYPE (slen), dlen, slen); slen = fold_build2_loc (input_location, MIN_EXPR, TREE_TYPE (slen), dlen,
slen);
dlen = build_call_expr_loc (input_location, dlen = build_call_expr_loc (input_location,
built_in_decls[BUILT_IN_MEMCPY], 3, built_in_decls[BUILT_IN_MEMCPY], 3,
gfc_build_addr_expr (pvoid_type_node, se.expr), errmsg, slen); gfc_build_addr_expr (pvoid_type_node, se.expr), errmsg, slen);
tmp = fold_build2 (NE_EXPR, boolean_type_node, stat, tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, stat,
build_int_cst (TREE_TYPE (stat), 0)); build_int_cst (TREE_TYPE (stat), 0));
tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt (input_location)); tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt (input_location));
...@@ -4621,8 +4671,9 @@ gfc_trans_deallocate (gfc_code *code) ...@@ -4621,8 +4671,9 @@ gfc_trans_deallocate (gfc_code *code)
tmp = gfc_deallocate_with_status (se.expr, pstat, false, expr); tmp = gfc_deallocate_with_status (se.expr, pstat, false, expr);
gfc_add_expr_to_block (&se.pre, tmp); gfc_add_expr_to_block (&se.pre, tmp);
tmp = fold_build2 (MODIFY_EXPR, void_type_node, tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node,
se.expr, build_int_cst (TREE_TYPE (se.expr), 0)); se.expr,
build_int_cst (TREE_TYPE (se.expr), 0));
} }
gfc_add_expr_to_block (&se.pre, tmp); gfc_add_expr_to_block (&se.pre, tmp);
...@@ -4631,7 +4682,8 @@ gfc_trans_deallocate (gfc_code *code) ...@@ -4631,7 +4682,8 @@ gfc_trans_deallocate (gfc_code *code)
of the last deallocation to the running total. */ of the last deallocation to the running total. */
if (code->expr1 || code->expr2) if (code->expr1 || code->expr2)
{ {
apstat = fold_build2 (PLUS_EXPR, TREE_TYPE (stat), astat, stat); apstat = fold_build2_loc (input_location, PLUS_EXPR,
TREE_TYPE (stat), astat, stat);
gfc_add_modify (&se.pre, astat, apstat); gfc_add_modify (&se.pre, astat, apstat);
} }
...@@ -4667,14 +4719,15 @@ gfc_trans_deallocate (gfc_code *code) ...@@ -4667,14 +4719,15 @@ gfc_trans_deallocate (gfc_code *code)
slen = build_int_cst (gfc_charlen_type_node, ((int) strlen (msg))); slen = build_int_cst (gfc_charlen_type_node, ((int) strlen (msg)));
dlen = gfc_get_expr_charlen (code->expr2); dlen = gfc_get_expr_charlen (code->expr2);
slen = fold_build2 (MIN_EXPR, TREE_TYPE (slen), dlen, slen); slen = fold_build2_loc (input_location, MIN_EXPR, TREE_TYPE (slen), dlen,
slen);
dlen = build_call_expr_loc (input_location, dlen = build_call_expr_loc (input_location,
built_in_decls[BUILT_IN_MEMCPY], 3, built_in_decls[BUILT_IN_MEMCPY], 3,
gfc_build_addr_expr (pvoid_type_node, se.expr), errmsg, slen); gfc_build_addr_expr (pvoid_type_node, se.expr), errmsg, slen);
tmp = fold_build2 (NE_EXPR, boolean_type_node, astat, tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, astat,
build_int_cst (TREE_TYPE (astat), 0)); build_int_cst (TREE_TYPE (astat), 0));
tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt (input_location)); tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt (input_location));
......
...@@ -1360,9 +1360,11 @@ gfc_get_dtype (tree type) ...@@ -1360,9 +1360,11 @@ gfc_get_dtype (tree type)
if (size && !INTEGER_CST_P (size)) if (size && !INTEGER_CST_P (size))
{ {
tmp = build_int_cst (gfc_array_index_type, GFC_DTYPE_SIZE_SHIFT); tmp = build_int_cst (gfc_array_index_type, GFC_DTYPE_SIZE_SHIFT);
tmp = fold_build2 (LSHIFT_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, LSHIFT_EXPR,
fold_convert (gfc_array_index_type, size), tmp); gfc_array_index_type,
dtype = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp, dtype); fold_convert (gfc_array_index_type, size), tmp);
dtype = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
tmp, dtype);
} }
/* If we don't know the size we leave it as zero. This should never happen /* If we don't know the size we leave it as zero. This should never happen
for anything that is actually used. */ for anything that is actually used. */
...@@ -1677,11 +1679,13 @@ gfc_get_array_type_bounds (tree etype, int dimen, int codimen, tree * lbound, ...@@ -1677,11 +1679,13 @@ gfc_get_array_type_bounds (tree etype, int dimen, int codimen, tree * lbound,
if (upper != NULL_TREE && lower != NULL_TREE && stride != NULL_TREE) if (upper != NULL_TREE && lower != NULL_TREE && stride != NULL_TREE)
{ {
tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, upper, lower); tmp = fold_build2_loc (input_location, MINUS_EXPR,
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp, gfc_array_index_type, upper, lower);
gfc_index_one_node); tmp = fold_build2_loc (input_location, PLUS_EXPR,
stride = gfc_array_index_type, tmp,
fold_build2 (MULT_EXPR, gfc_array_index_type, tmp, stride); gfc_index_one_node);
stride = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, tmp, stride);
/* Check the folding worked. */ /* Check the folding worked. */
gcc_assert (INTEGER_CST_P (stride)); gcc_assert (INTEGER_CST_P (stride));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment