Issue |
138808
|
Summary |
[Flang] No error checking when a variable with protected attribute is specified in io-control-spec (size) of read statement
|
Labels |
flang:frontend
|
Assignees |
|
Reporter |
ohno-fj
|
```
Version of flang : 21.0.0(842e5915778a820c63cf38b75bec932a6ea8c18b)/AArch64
```
The attached program is not correct.
`A variable (aa)` with `protected attribute` is specified in `io-control-spec (size)` of `read statement`.
This corresponds to `Fortran standard 2023: 8.5.15 PROTECTED attribute/C859, 19.6.7 Variable definition context/(3)`.
However, Flang does not detect this error. Other error has been detected.
Gfortran and ifx detect an error and result in compilation error.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
snen0501e_006_2.f90:
```fortran
module mod
integer,protected:: aa
end module mod
program main
use mod
character*3 cha
cha='no'
read (5,20,advance=cha,size=aa)
flush(10,iomsg=aa,err=99,iostat=N1)
20 format(i2)
end program main
```
```
$ flang snen0501e_006_2.f90
error: Semantic errors in snen0501e_006_2.f90
./snen0501e_006_2.f90:10:3: error: Label '99' was not found
flush(10,iomsg=aa,err=99,iostat=N1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
$
```
```
$ gfortran snen0501e_006_2.f90
snen0501e_006_2.f90:9:31:
9 | read (5,20,advance=cha,size=aa)
| 1
Error: Variable ‘aa’ is PROTECTED and cannot appear in a variable definition context (SIZE tag) at (1)
snen0501e_006_2.f90:10:17:
10 | flush(10,iomsg=aa,err=99,iostat=N1)
| 1
Error: IOMSG tag at (1) must be of type CHARACTER
$
```
```
$ ifx snen0501e_006_2.f90
snen0501e_006_2.f90(9): error #7990: A use associated object that has the PROTECTED attribute shall not appear as an IOSTAT=, SIZE=, IOMSG= specifier in an input/output statement. [AA]
read (5,20,advance=cha,size=aa)
-------------------------------^
snen0501e_006_2.f90(10): error #7990: A use associated object that has the PROTECTED attribute shall not appear as an IOSTAT=, SIZE=, IOMSG= specifier in an input/output statement. [AA]
flush(10,iomsg=aa,err=99,iostat=N1)
-----------------^
snen0501e_006_2.f90(10): error #7939: A scalar default-character variable is required in this context. [AA]
flush(10,iomsg=aa,err=99,iostat=N1)
-----------------^
snen0501e_006_2.f90(10): error #6323: This label is not defined in this scoping unit. [99]
flush(10,iomsg=aa,err=99,iostat=N1)
------------------------^
compilation aborted for snen0501e_006_2.f90 (code 1)
$
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs