Le 19/07/2022 à 21:09, Harald Anlauf via Fortran a écrit :
Hi Mikael,

Am 19.07.22 um 11:03 schrieb Mikael Morin:
Hello,

the principle looks good, but...

Le 18/07/2022 à 22:43, Harald Anlauf via Fortran a écrit :

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 2ebf076f730..dacd33561d0 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -5004,7 +5004,11 @@ find_array_spec (gfc_expr *e)
       {
       case REF_ARRAY:
     if (as == NULL)
-      gfc_internal_error ("find_array_spec(): Missing spec");
+      {
+        gfc_error ("Symbol %qs at %L has not been declared as an array",
+               e->symtree->n.sym->name, &e->where);

... the error here only makes sense if the array reference follows a variable reference.  If it follows a derived type component reference, a slightly different error message would be more appropriate.

how detailed or tailored should the error message be, or can
we just have a more generic message, like "Name at %L ...",
or "Invalid subscript reference at %L"?  We seem to not hit
that internal error very often...

It could be anything better than the (unhelpfull) internal error it is replacing. I suggest for example "Invalid array reference of a non-array entity at %L". Cray’s words, or Intel’s, or your other propositions work as well.


gfortran's behavior during error handling is difficult to understand.
While the proposed new error message is emitted for associate_54.f90,
it never makes it far enough for the testcase of the present PR
(associate_59.f90).

Indeed. We try to match several types of statement one after the other, and each failed match can possibly register an error. But it is emitted only if all have failed (see gfc_error_check). There is no choice of the best error; the last one registered wins.

This buffering behavior is controlled by calls to gfc_buffer_error(...). Error handling during resolution doesn’t need to delay error reporting as far as I know, and the calls to gfc_buffer_error (false) seem to correctly disable buffering at the end of every call to next_statement. I don’t know why it remains active in this case.

Reply via email to