Issue 109609
Summary [flang] cannot parse a program where write statement is incorrectly positioned in contains section
Labels flang
Assignees
Reporter k-arrows
    Consider the following invalid Fortran program.
```f90
write(*, *) 'OK'
contains
write(*, *) 'NG'
end
```
If you compile the above program with gfortran, the following error message is obtained. The message correctly points out an error in the program.
```console
$ gfortran test.f90
test.f90:3:16:

    3 | write(*, *) 'NG'
 |                1
Error: Unexpected WRITE statement in CONTAINS section at (1)
```
With flang-new, the following not-so-kind error message is obtained.
```console
$ flang-new test.f90
error: Could not parse test.f90
./test.f90:3:1: error: expected 'END'
  write(*, *) 'NG'
 ^
./test.f90:3:1: in the context: END PROGRAM statement
  write(*, *) 'NG'
  ^
./test.f90:1:1: in the context: main program
  write(*, *) 'OK'
  ^
./test.f90:3:1: error: expected 'END PROGRAM'
  write(*, *) 'NG'
  ^
./test.f90:3:1: in the context: END PROGRAM statement
 write(*, *) 'NG'
  ^
./test.f90:1:1: in the context: main program
 write(*, *) 'OK'
  ^
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to