[flang-commits] [flang] [Flang] Revise the fix in PR #81807 to get specific procedure from a potential generic name. (PR #81544)

via flang-commits flang-commits at lists.llvm.org
Wed Feb 14 00:59:25 PST 2024


jeanPerier wrote:

As mentioned in the previous comment, maybe there is a way to still update the interface symbol as you did in #81087 and #80738 and deal with the module file renaming issue. It seems module files may use a custom variable format to deal with this case with function calls.
```
module generic_iface
    interface somefunc
      module procedure  somefunc
    end interface
contains
  pure integer function somefunc()
    somefunc = 4
  end function
end module
module m
contains
  function foo()
    use generic_iface, only: renamed=>somefunc
    character(renamed()) :: foo
    bug = "hello"
  end function
end module
```
```
 use m
  print *, foo()
end
```

The module file m looks like:
```
!mod$ v1 sum:b9a6a09789c9dad6
module m              
contains                        
function foo()    
use generic_iface,only:generic_iface$generic_iface$somefunc=>somefunc
character(generic_iface$generic_iface$somefunc(),1)::foo
end              
end
```

This currently trigger a bogus error "Invalid specification expression: reference to impure function 'somefunc'" when the program is compiled in its own file, so this may require some more work, but at least the renaming is not an issue in this case.

@klausler, how is the `renamed()` generic call rewritten to `generic_iface$generic_iface$somefunc()` in the module file? Would it be possible to do the same with a `procedure(renamed)` statement where the host associated symbol has been replaced by the specific symbol from the module?

https://github.com/llvm/llvm-project/pull/81544


More information about the flang-commits mailing list