https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99036

--- Comment #5 from G. Steinmetz <gs...@t-online.de> ---

Another try with a case that is probably/hopefully related.
The following example with a module and submodule in different files
is valid for e.g. -std=f2008, but invalid for -std=f2003 or -std=f95 :


$ cat z2.f90
module m
   interface
      module logical function f(x)
         character(*), intent(in) :: x
      end
   end interface
end


$ cat z3.f90
submodule(m) m2
contains
   module procedure f
      inquire (file=x, exist=f)
   end procedure
end


$ gfortran-12-20211107 -c z2.f90 z3.f90
$
$ gfortran-12-20211107 -c z2.f90 z3.f90 -std=f2003
z2.f90:3:14:

    3 |       module logical function f(x)
      |              1
Error: Fortran 2008: MODULE prefix at (1)
z2.f90:4:38:

    4 |          character(*), intent(in) :: x
      |                                      1
Error: Unexpected data declaration statement in INTERFACE block at (1)
z2.f90:5:9:

    5 |       end
      |         1
Error: END INTERFACE statement expected at (1)
z3.f90:1:10:

    1 | submodule(m) m2
      |          1
Error: Fortran 2008: SUBMODULE declaration at (1)
f951: internal compiler error: in gfc_current_interface_head, at
fortran/interface.c:4842
0x7e9464 gfc_current_interface_head()
        ../../gcc/fortran/interface.c:4842
0x7c4385 gfc_match_modproc()
        ../../gcc/fortran/decl.c:9978
0x82d421 match_word
        ../../gcc/fortran/parse.c:67
0x832630 decode_statement
        ../../gcc/fortran/parse.c:524
0x83317a next_free
        ../../gcc/fortran/parse.c:1388
0x83317a next_statement
        ../../gcc/fortran/parse.c:1620
0x837f6c parse_contained
        ../../gcc/fortran/parse.c:6017
0x837e96 parse_progunit
        ../../gcc/fortran/parse.c:6242
0x838c4c gfc_parse_file()
        ../../gcc/fortran/parse.c:6763
0x886d7f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:216

Reply via email to