aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/trans.c')
-rw-r--r--gcc/fortran/trans.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index 3eec75c..d4856fd 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -46,6 +46,10 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
static gfc_file *gfc_current_backend_file;
+char gfc_msg_bounds[] = N_("Array bound mismatch");
+char gfc_msg_fault[] = N_("Array reference out of bounds");
+char gfc_msg_wrong_return[] = N_("Incorrect function return value");
+
/* Advance along TREE_CHAIN n times. */
@@ -302,12 +306,15 @@ gfc_build_array_ref (tree base, tree offset)
/* Generate a runtime error if COND is true. */
void
-gfc_trans_runtime_check (tree cond, tree msg, stmtblock_t * pblock)
+gfc_trans_runtime_check (tree cond, const char * msgid, stmtblock_t * pblock,
+ locus * where)
{
stmtblock_t block;
tree body;
tree tmp;
tree args;
+ char * message;
+ int line;
if (integer_zerop (cond))
return;
@@ -315,19 +322,24 @@ gfc_trans_runtime_check (tree cond, tree msg, stmtblock_t * pblock)
/* The code to generate the error. */
gfc_start_block (&block);
- gcc_assert (TREE_CODE (msg) == STRING_CST);
-
- TREE_USED (msg) = 1;
+ if (where)
+ {
+#ifdef USE_MAPPED_LOCATION
+ line = LOCATION_LINE (where->lb->location);
+#else
+ line = where->lb->linenum;
+#endif
+ asprintf (&message, "%s (in file '%s', at line %d)", _(msgid),
+ where->lb->file->filename, line);
+ }
+ else
+ asprintf (&message, "%s (in file '%s', around line %d)", _(msgid),
+ gfc_source_file, input_line + 1);
- tmp = gfc_build_addr_expr (pchar_type_node, msg);
+ tmp = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const(message));
+ gfc_free(message);
args = gfc_chainon_list (NULL_TREE, tmp);
- tmp = gfc_build_addr_expr (pchar_type_node, gfc_strconst_current_filename);
- args = gfc_chainon_list (args, tmp);
-
- tmp = build_int_cst (NULL_TREE, input_line);
- args = gfc_chainon_list (args, tmp);
-
tmp = build_function_call_expr (gfor_fndecl_runtime_error, args);
gfc_add_expr_to_block (&block, tmp);