The following gives an ICE:

  type foo
    integer :: i
  end type foo

  interface fun_interface
    type(foo) function fun()
    end function fun
  end interface

contains

  type(foo) function fun()
  end function ieee_class_r4

end

If the return type of the function, type(foo), is replaced by integer, gfortran
issues the following error message:

 In file ice.f90:12

  integer function fun()
                     1
 In file ice.f90:6

    integer function fun()
                       2
Error: Procedure 'fun' at (1) has an explicit interface and must not have
attributes declared at (2)
 In file ice.f90:12

  integer function fun()
                 1
Error: Syntax error in data declaration at (1)
 In file ice.f90:13

  end function ieee_class_r4
    1
Error: Expecting END PROGRAM statement at (1)



The backtrace of the ICE is:

 where
#0  0x0000000000412859 in variable_decl (elem=Variable "elem" is not available.
)
    at ../../trunk/gcc/fortran/decl.c:1201
#1  0x00000000004130dc in gfc_match_data_decl ()
    at ../../trunk/gcc/fortran/decl.c:2356
#2  0x000000000043d713 in match_word (str=Variable "str" is not available.
)
    at ../../trunk/gcc/fortran/parse.c:65
#3  0x000000000043dcb8 in decode_statement ()
    at ../../trunk/gcc/fortran/parse.c:134
#4  0x000000000043e6ab in next_statement ()
    at ../../trunk/gcc/fortran/parse.c:493
#5  0x0000000000440b04 in parse_contained (module=0)
    at ../../trunk/gcc/fortran/parse.c:2767
#6  0x0000000000440a8c in parse_progunit (st=Variable "st" is not available.
)
    at ../../trunk/gcc/fortran/parse.c:2931

The problem arises because gfc_current_ns->proc_name == NULL.


-- 
           Summary: ICE in variable_decl, for function returning a derived
                    type
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org
 BugsThisDependsOn: 29539


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29634

Reply via email to