compilation error in Fortran: “forward reference to function”

It seems that there is a buggus in the pgfortran (using LLVM) compiler.

The following example module named test.f90:

MODULE CT
    IMPLICIT NONE

    type CMT
    CONTAINS
      procedure, nopass :: find_line_condi 
    endtype CMT

 CONTAINS
    function find_line_condi()
       integer(SELECTED_INT_KIND(4)) find_line_condi
       find_line_condi=0
    end function find_line_condi

END MODULE CT

compiled with the command

 pgfortran -c test.f90

returns the following error message:

/opt/pgi/linux86-64-llvm/19.10/share/llvm/bin/llc: error: /opt/pgi/linux86-64-llvm/19.10/share/llvm/bin/llc: /tmp/pgfortranr2qeZBujkwvA.ll:23:77: error: invalid forward reference to function 'ct_find_line_condi_' with wrong type: expected 'i32 (i64*, i64*, i64*, i64)*' but was 'i16 (i64*, i64*, i64*, i64)*'
@ct$cmt$td$vft = global [1 x i8*] [i8* bitcast(i16 (i64*, i64*, i64*, i64)* @ct_find_line_condi_ to i8*)]

Thanks rono for the report! I was able to reproduce the issue here and have filed a problem report (TPR#27943). The compilation does work with our non-LLVM back-end so as a workaround, please either set your PATH to use the “$PGI/linux86-64-nollvm” directory or add the flag “-Mnollvm”.

Best Regards,
Mat