Issue 171949
Summary [Flang] Missing error detection for dummy procedure interface violation
Labels flang
Assignees
Reporter boo-aboutme
    ``` 
Version of flang : 22.0.0git (f42e58f61680e325555f382cab5115c54df6f6df)
```

In the sample program below, the dummy argument `rr` of subroutine `sub` is declared 
as a pointer to a function that returns a result of type `real`, while the corresponding 
actual argument `ip` is declared as a procedure pointer to either a subroutine or a function. 
This situation violates the constraint in Fortran 2023 standard 15.5.2.10.
Therefore, a compiler should report this as an error. Gfortran correctly detects this violation,
but Flang does not.


``` fortran
print *,"pass"
end

subroutine test01()
  implicit none
  procedure(), pointer :: ip
  call sub(ip)
  contains
  subroutine sub(rr)
    procedure(real), pointer :: rr
  end subroutine
end subroutine

real function ip()
  ip=1
end function ip
```

### Flang

``` text
$ flang sample.f90 && ./a.out
 pass
```

### Gfortran

``` text
$ gfortran --version
GNU Fortran (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gfortran sample.f90 && ./a.out
sample.f90:7:9:

    7 | call sub(ip)
      |         1
Error: Interface mismatch in dummy procedure ‘rr’ at (1): 'ip' is not a function
$
```

### Intel

``` text
$ which ifx
/opt/intel/oneapi/compiler/2024.2/bin/ifx
$ ifx sample.f90 && ./a.out
 pass
$
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to