| Issue |
109983
|
| Summary |
[flang] Inconsistent compilation results for programs with almost the same error
|
| Labels |
flang
|
| Assignees |
|
| Reporter |
k-arrows
|
Consider the following three programs. These are all invalid.
test1.f90
```f90
character(len=5) :: s
s = "flang"
print*, "s:", s(-1111111111111111111:4)
end
```
test2.f90
```f90
character(len=5) :: s
s = "flang"
print*, "s:", s(-11111111111111111111:4)
end
```
test3.f90
```f90
character(len=5) :: s
s = "flang"
print*, "s:", s(-111111111111111111111:4)
end
```
Gfortran rejects the above three programs with the same message.
```console
$ gfortran test1.f90
test1.f90:3:16:
3 | print*, "s:", s(-1111111111111111111:4)
| 1
Error: Syntax error in PRINT statement at (1)
$ gfortran test2.f90
test2.f90:3:16:
3 | print*, "s:", s(-11111111111111111111:4)
| 1
Error: Syntax error in PRINT statement at (1)
$ gfortran test3.f90
test3.f90:3:16:
3 | print*, "s:", s(-111111111111111111111:4)
| 1
Error: Syntax error in PRINT statement at (1)
```
With flang-new, I got the following results.
```console
$ flang-new test1.f90
error: Semantic errors in test1.f90
./test1.f90:3:15: error: Substring must begin at 1 or later, not -1111111111111111111
print*, "s:", s(-1111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^
$ flang-new test2.f90
./test2.f90:3:15: warning: INTEGER(16) to INTEGER(8) conversion overflowed
print*, "s:", s(-11111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^
$ ./a.out
s:
$ flang-new test3.f90
error: Semantic errors in test3.f90
./test3.f90:3:15: warning: INTEGER(16) to INTEGER(8) conversion overflowed
print*, "s:", s(-111111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
./test3.f90:3:15: error: Substring must begin at 1 or later, not -430646668853801415
print*, "s:", s(-111111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
./test3.f90:3:15: warning: INTEGER(16) to INTEGER(8) conversion overflowed
print*, "s:", s(-111111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
./test3.f90:3:15: error: Substring must begin at 1 or later, not -430646668853801415
print*, "s:", s(-111111111111111111111:4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
It seems more consistent for `test2.f90` and `test3.f90` to be rejected with the same error message as `test1.f90`. Also, the error message for `test3.f90` is incorrect because the number `-430646668853801415` does not exist in `test3.f90`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs