https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99256
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P4 Last reconfirmed| |2021-02-25 CC| |kargl at gcc dot gnu.org Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #1 from kargl at gcc dot gnu.org --- An interesting bug. This catches the invalid alternate return, but there is no locus available to actually point at the offending line of code. e is null, so e->where does not work. gfc_current_locus seems to point at the line 'program p'. In check_variable(), looking at gfc_current_intrinsic_arg[n]->actual, there is locus information. However, there is gfc_current_intrinsic_arg[n]->actual->label->where but this points to the line '1 stop'. IOW, it points to where the labeled statement is not the where the alternate return is used. So, the offending line of code isn't printed. diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 82db8e4e1b2..63138cfa9bc 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -1009,6 +1009,14 @@ kind_value_check (gfc_expr *e, int n, int k) static bool variable_check (gfc_expr *e, int n, bool allow_proc) { + /* Expecting a variable, not an alternate return. */ + if (!e) + { + gfc_error ("%qs argument of %qs intrinsic must be a variable", + gfc_current_intrinsic_arg[n]->name, gfc_current_intrinsic); + return false; + } + if (e->expr_type == EXPR_VARIABLE && e->symtree->n.sym->attr.intent == INTENT_IN && (gfc_current_intrinsic_arg[n]->intent == INTENT_OUT