Probably a commit within the last 2-3 days introduced a regression in gfc_format_decoder: n gfc_format_decoder, at fortran/error.c:970 I will provide the exact reproducer soon.
Next step, full error message: ibtool: compile: gfortran -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../rng -I../physics -I../fastjet -I../qft -I../types -I../particles -I../../circe1/src -I../../circe2/src -I../pdf_builtin -I../lhapdf -I../qed_pdf -I../variables -I../expr_base -I../parsing -g -O2 -c sf_lhapdf.f90 -fPIC -o .libs/sf_lhapdf.o in gfc_format_decoder, at fortran/error.c:970 0x5f46ce gfc_format_decoder ../../gcc/fortran/error.c:970 0x18b722c pp_format(pretty_printer*, text_info*) ../../gcc/pretty-print.c:1475 0x189c41e diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) ../../gcc/diagnostic.c:1159 0x807a05 gfc_report_diagnostic ../../gcc/fortran/error.c:782 0x807a05 gfc_warning ../../gcc/fortran/error.c:815 0x808016 gfc_warning(int, char const*, ...) ../../gcc/fortran/error.c:846 0x9572bf check_against_globals ../../gcc/fortran/frontend-passes.c:5528 0x8a8b02 do_traverse_symtree ../../gcc/fortran/symbol.c:4170 0x95f5d1 gfc_check_externals(gfc_namespace*) ../../gcc/fortran/frontend-passes.c:5563 0x86e554 gfc_parse_file() ../../gcc/fortran/parse.c:6499 0x8bf9bf gfc_be_parse_file ../../gcc/fortran/f95-lang.c:212 Please submit a full bug report, Code will follow in a minute.
Ok, this is triggered by a stupid thing in our own code, but I think the compiler should not stumble over it. The error appears when there is a routine that is defined as external, but there is also an explicit interface for it: module m implicit none private interface subroutine GetXminM (set, xmin) integer, intent(in) :: set real, intent(out) :: xmin end subroutine GetXminM end interface contains subroutine s () real :: xmin integer :: set external :: GetXminM call GetXminM (set, xmin) end subroutine s end module m
From the backtrace, that was very probably me with https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=cc9a9229285a26ac12bc8de53237ce9c4d42f867 .
(In reply to Thomas Koenig from comment #3) > From the backtrace, that was very probably me with > https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git; > h=cc9a9229285a26ac12bc8de53237ce9c4d42f867 . Yes, it started with this revision.
I see nothing in the standard which prohibits this, so ice-on-valid.
What we have here is, in gfc_check_externals0, (gdb) call debug(def_sym->formal) || symbol: '_formal_0' type spec : (INTEGER 4) attributes: (VARIABLE ARTIFICIAL DUMMY) || symbol: '_formal_1' type spec : (REAL 4) attributes: (VARIABLE ARTIFICIAL DUMMY) (gdb) call debug(sym->formal) || symbol: 'set' type spec : (INTEGER 4) attributes: (VARIABLE DUMMY(IN)) || symbol: 'xmin' type spec : (REAL 4) attributes: (VARIABLE DUMMY(OUT)) so the inferred argument list from the call does not match the interface. And, since the location is not set, we get an ICE on top of it. I think resolution should have found the interface in addition to the EXTERNAL statement.
Two things: We should not warn about INTENT mismatches when we artificially generate the prototypes, and we should set a valid gfc_locus. Both done with the attached patch. diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 69f9ca64c97..7768fdc25ca 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -5441,6 +5441,7 @@ check_externals_procedure (gfc_symbol *sym, locus *loc, gfc_current_ns = gsym->ns; gfc_get_formal_from_actual_arglist (new_sym, actual); + new_sym->declared_at = *loc; gfc_current_ns = save_ns; return 0; diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 0cc504f4e04..e51820918b8 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1343,7 +1343,8 @@ gfc_check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2, } /* Check INTENT. */ - if (s1->attr.intent != s2->attr.intent) + if (s1->attr.intent != s2->attr.intent && !s1->attr.artificial + && !s2->attr.artificial) { snprintf (errmsg, err_len, "INTENT mismatch in argument '%s'", s1->name);
The master branch has been updated by Thomas Kथà¤nig <tkoenig@gcc.gnu.org>: https://gcc.gnu.org/g:90efb2512d40f0a59b063aa0416a6d28849ee424 commit r11-2036-g90efb2512d40f0a59b063aa0416a6d28849ee424 Author: Thomas Koenig <tkoenig@gcc.gnu.org> Date: Sat Jul 11 19:16:16 2020 +0200 Fix ICE on warning with new interface check. In the test case, there was a warning about INTENT where an EXTERNAL masked an interface in an outer scope, when the location of the symbol was not set, leading to an ICE. Two problems, two-part solution: It makes no sense to warn about INTENT for artificially generated formal argument lists, and the location should be set. gcc/fortran/ChangeLog: PR fortran/96073 * frontend-passes.c (check_externals_procedure): Add locus information for new_sym. * interface.c (gfc_check_dummy_characteristics): Do not warn about INTENT for artificially generated variables. gcc/testsuite/ChangeLog: PR fortran/96073 * gfortran.dg/interface_48.f90: New test.
Fixed on master, closing.
... and thanks for the timely bug report!