aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2019-12-07 11:07:07 +0000
committerTobias Burnus <burnus@gcc.gnu.org>2019-12-07 12:07:07 +0100
commit9c81750c5bedd7883182ee2684a012c6210ebe1d (patch)
treea3355f687262d05caae19a9ab28b2fba2c9745ac /gcc/fortran/trans.c
parentb01d215df18ba753746a170125b883befe100d67 (diff)
downloadgcc-9c81750c5bedd7883182ee2684a012c6210ebe1d.zip
gcc-9c81750c5bedd7883182ee2684a012c6210ebe1d.tar.gz
gcc-9c81750c5bedd7883182ee2684a012c6210ebe1d.tar.bz2
Fortran] PR 92793 - fix column used for error diagnostic
PR fortran/92793 * trans.c (gfc_get_location): Declare. * trans.c (gfc_get_location): Define; returns column-corrected location. (trans_runtime_error_vararg, gfc_trans_runtime_check, gfc_generate_module_code): Use new function. * trans-array.c (gfc_trans_auto_array_allocation): Likewise. * trans-common.c (build_field, get_init_field, create_common): Likewise. * trans-decl.c (gfc_build_label_decl, gfc_get_symbol_decl): Likewise. * trans-openmp.c (gfc_trans_omp_reduction_list, gfc_trans_omp_clauses): Likewise. * trans-stmt.c (gfc_trans_if_1): Likewise. From-SVN: r279075
Diffstat (limited to 'gcc/fortran/trans.c')
-rw-r--r--gcc/fortran/trans.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index d9b2781..70c7e2d 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -48,6 +48,18 @@ const char gfc_msg_fault[] = N_("Array reference out of bounds");
const char gfc_msg_wrong_return[] = N_("Incorrect function return value");
+/* Return a location_t suitable for 'tree' for a gfortran locus. The way the
+ parser works in gfortran, loc->lb->location contains only the line number
+ and LOCATION_COLUMN is 0; hence, the column has to be added when generating
+ locations for 'tree'. Cf. error.c's gfc_format_decoder. */
+
+location_t
+gfc_get_location (locus *loc)
+{
+ return linemap_position_for_loc_and_offset (line_table, loc->lb->location,
+ loc->nextc - loc->lb->line);
+}
+
/* Advance along TREE_CHAIN n times. */
tree
@@ -503,7 +515,7 @@ trans_runtime_error_vararg (tree errorfunc, locus* where, const char* msgid,
irectly. */
fntype = TREE_TYPE (errorfunc);
- loc = where ? where->lb->location : input_location;
+ loc = where ? gfc_get_location (where) : input_location;
tmp = fold_build_call_array_loc (loc, TREE_TYPE (fntype),
fold_build1_loc (loc, ADDR_EXPR,
build_pointer_type (fntype),
@@ -582,14 +594,14 @@ gfc_trans_runtime_check (bool error, bool once, tree cond, stmtblock_t * pblock,
else
{
if (once)
- cond = fold_build2_loc (where->lb->location, TRUTH_AND_EXPR,
+ cond = fold_build2_loc (gfc_get_location (where), TRUTH_AND_EXPR,
long_integer_type_node, tmpvar, cond);
else
cond = fold_convert (long_integer_type_node, cond);
- tmp = fold_build3_loc (where->lb->location, COND_EXPR, void_type_node,
+ tmp = fold_build3_loc (gfc_get_location (where), COND_EXPR, void_type_node,
cond, body,
- build_empty_stmt (where->lb->location));
+ build_empty_stmt (gfc_get_location (where)));
gfc_add_expr_to_block (pblock, tmp);
}
}
@@ -2214,7 +2226,7 @@ gfc_generate_module_code (gfc_namespace * ns)
gcc_assert (ns->proc_name->backend_decl == NULL);
ns->proc_name->backend_decl
- = build_decl (ns->proc_name->declared_at.lb->location,
+ = build_decl (gfc_get_location (&ns->proc_name->declared_at),
NAMESPACE_DECL, get_identifier (ns->proc_name->name),
void_type_node);
entry = gfc_find_module (ns->proc_name->name);