[Patch, Fortran] PR 45186 - Improve location of expressions for debugging
Mikael Morin
mikael.morin@sfr.fr
Fri Oct 15 12:47:00 GMT 2010
On Friday 15 October 2010 13:33:57 Tobias Burnus wrote:
> On 10/13/2010 01:27 PM, Mikael Morin wrote:
> > On Wednesday 13 October 2010 10:28:57 Tobias Burnus wrote:
> >> PR 45186 is "[4.6 Regression] Gfortran 4.5.0 emits wrong
> >> linenumbers".
> >>
> >> While most of it was fixed, I found two cases where the location was
> >> wrong or at least surprising. That's fixes with the following patch. I
> >> am sure there are more cases, but I intent to close the PR after those
> >> fixes are in.
> >
> > locus' gfc_linebuf has a source_location field, and location_t is
> > typedef-ed from source_location in input.h.
>
> I have now updated the patch - and tests with some DO / DO WHILE and IF
> examples in gdb work as one would expect :-)
>
> Build and regtested on x86-64-linux.
> OK for the trunk?
>
> Tobias
> debug-lines2.diff
> 2010-10-15 Tobias Burnus <burnus@net-b.de>
>
> PR fortran/45186
> * trans.h (gfc_add_modify_loc, gfc_evaluate_now_loc): New prototypes.
> (gfc_trans_runtime_error_vararg): Remove prototype.
> * trans.c (gfc_add_modify_loc, gfc_evaluate_now_loc): New functions.
> (gfc_add_modify, gfc_evaluate_now): Use them.
> (trans_runtime_error_vararg): Renamed from
> gfc_trans_runtime_error_vararg, made static and use locus.
> (gfc_trans_runtime_error): Use it.
> (gfc_trans_runtime_check): Ditto and make use of locus.
> * trans-stmt.c (gfc_trans_if_1, gfc_trans_simple_do,
> gfc_trans_do, gfc_trans_do_while): Improve line number
> associated with generated expressions.
>
> diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
> index 70ddd51..296b054 100644
> --- a/gcc/fortran/trans-stmt.c
> +++ b/gcc/fortran/trans-stmt.c
> @@ -1360,14 +1364,15 @@ gfc_trans_do_while (gfc_code * code)
> gfc_init_se (&cond, NULL);
> gfc_conv_expr_val (&cond, code->expr1);
> gfc_add_block_to_block (&block, &cond.pre);
> - cond.expr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
> - boolean_type_node, cond.expr);
> + cond.expr = fold_build1_loc (code->expr1->where.lb->location,
> + TRUTH_NOT_EXPR, boolean_type_node, cond.expr);
>
> /* Build "IF (! cond) GOTO exit_label". */
> tmp = build1_v (GOTO_EXPR, exit_label);
> TREE_USED (exit_label) = 1;
> - tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
> - cond.expr, tmp, build_empty_stmt (input_location));
> + tmp = fold_build3_loc (code->expr1->where.lb->location, COND_EXPR,
> + void_type_node, cond.expr, tmp,
> + build_empty_stmt (code->expr1->where.lb->location));
The code->expr1->where.lb->location uses could be factorised to get proper indent.
> gfc_add_expr_to_block (&block, tmp);
>
> /* The main body of the loop. */
> @@ -1386,7 +1391,8 @@ gfc_trans_do_while (gfc_code * code)
>
> gfc_init_block (&block);
> /* Build the loop. */
> - tmp = build1_v (LOOP_EXPR, tmp);
> + tmp = fold_build1_loc (code->expr1->where.lb->location, LOOP_EXPR,
> + void_type_node, tmp);
> gfc_add_expr_to_block (&block, tmp);
>
> /* Add the exit label. */
> diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
> index b3c6032..58ab78d 100644
> --- a/gcc/fortran/trans.h
> +++ b/gcc/fortran/trans.h
> @@ -504,9 +506,10 @@ bool get_array_ctor_strlen (stmtblock_t *, gfc_constructor_base,
tree *);
>
> /* Generate a runtime error call. */
> tree gfc_trans_runtime_error (bool, locus*, const char*, ...);
> -tree gfc_trans_runtime_error_vararg (bool, locus*, const char*, va_list);
>
> /* Generate a runtime warning/error check. */
> +void gfc_trans_runtime_check_loc (location_t, bool, bool, tree, stmtblock_t *,
> + locus *, const char *, ...);
This one is probably left from your previous patch and could be removed.
Ok with the changes above.
Thanks for the patch!
Mikael
More information about the Fortran
mailing list