[Flang][OpenMP] No error checking of a continuation line that does not have a line to be continued in Fixed Source Form Conditional Compilation Sentinel
Version of flang : 21.0.0(c8b40867d144395ad3c306a3cf87f970e0f97f07)/AArch64
The attached program is incorrect.
In Fixed Source Form Conditional Compilation Sentinel, flang does not output an error message during compilation for a continuation line that does not have a line to be continued.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
err_sngg081g_2.f:
c$ ! 0 !
print *,'pass'
end
$ export OMP_NUM_THREADS=2; flang -fopenmp err_sngg081g_2.f; ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
pass
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp err_sngg081g_2.f; ./a.out
pass
$
$ ifx -qopenmp err_sngg081g_2.f
err_sngg081g_2.f(1): error #5118: First statement in file must not be continued
c$ ! 0 !
-----^
err_sngg081g_2.f(1): error #5082: Syntax error, found INTEGER_CONSTANT '0' when expecting one of: <LABEL> <END-OF-STATEMENT>
; <IDENTIFIER> TYPE MODULE ELEMENTAL IMPURE NON_RECURSIVE ...
c$ ! 0 !
---------^
err_sngg081g_2.f(1): error #6905: A label cannot be zero; it must be an integer in the range 1 through 99999. [0]
c$ ! 0 !
---------^
err_sngg081g_2.f(1): error #6321: An unterminated block exists.
c$ ! 0 !
^
err_sngg081g_2.f(1): error #6323: This label is not defined in this scoping unit. [0]
c$ ! 0 !
---------^
compilation aborted for err_sngg081g_2.f (code 1)
$
@llvm/issue-subscribers-flang-frontend
Author: None (ohno-fj)
The attached program is incorrect.
In Fixed Source Form Conditional Compilation Sentinel, flang does not output an error message during compilation for a continuation line that does not have a line to be continued.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
err_sngg081g_2.f:
c$ ! 0 !
print *,'pass'
end
$ export OMP_NUM_THREADS=2; flang -fopenmp err_sngg081g_2.f; ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
pass
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp err_sngg081g_2.f; ./a.out
pass
$
$ ifx -qopenmp err_sngg081g_2.f
err_sngg081g_2.f(1): error #<!-- -->5118: First statement in file must not be continued
c$ ! 0 !
-----^
err_sngg081g_2.f(1): error #<!-- -->5082: Syntax error, found INTEGER_CONSTANT '0' when expecting one of: <LABEL> <END-OF-STATEMENT>
; <IDENTIFIER> TYPE MODULE ELEMENTAL IMPURE NON_RECURSIVE ...
c$ ! 0 !
---------^
err_sngg081g_2.f(1): error #<!-- -->6905: A label cannot be zero; it must be an integer in the range 1 through 99999. [0]
c$ ! 0 !
---------^
err_sngg081g_2.f(1): error #<!-- -->6321: An unterminated block exists.
c$ ! 0 !
^
err_sngg081g_2.f(1): error #<!-- -->6323: This label is not defined in this scoping unit. [0]
c$ ! 0 !
---------^
compilation aborted for err_sngg081g_2.f (code 1)
$
@ohno-fj this seems to be fixed. Could you please check and close?
@ceseo thank you for your comment.
I confirmed with flang built on June 9 that the program was not error checked.
The log is attached below.
$ flang --version
flang version 21.0.0git (https://github.com/llvm/llvm-project.git 414590bae8cdd2a59979e5ae4cb297f6a1967ec5)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work/groups/ssoft/compiler/llvm/aarch64/main-20250609-414590bae8cd/bin
Build config: +assertions
$
$ export OMP_NUM_THREADS=2; flang -fopenmp err_sngg081g_2.f; ./a.out
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
pass
$
@ohno-fj I get:
error: Could not parse test.f90
./test.f90:1:18: error: expected '('
c$ ! 0 !
^
./test.f90:1:1: in the context: statement function definition
c$ ! 0 !
^
@ceseo , @ohno-fj , it would be helpful, if you could post git commit ID information from flang --version. For example:
flang version 21.0.0git (https://github.com/eugeneepshteyn/llvm-project.git 0d7e64f5d2b45e2150a89390cfdc69b19b1493d9)
Target: x86_64-unknown-linux-gnu
Then we could check, which revision works and which revision doesn't.
@ohno-fj tested with .f suffix and @ceseo tested with .f90 suffix. It's the difference.
$ flang --version
flang version 21.0.0git (https://github.com/llvm/llvm-project.git b822a32659c3fd5afd75c8f028aaa142fbd68e20)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work/groups/ssoft/compiler/llvm/aarch64/main-20250630-b822a32659c3/bin
Build config: +assertions
$ cp test.f test.f90
$ flang -fopenmp test.f
$ flang -fopenmp test.f90
error: Could not parse test.f90
./test.f90:1:18: error: expected '('
c$ ! 0 !
^
./test.f90:1:1: in the context: statement function definition
c$ ! 0 !
^
Thank you for your comment, @kawashima-fj . I got the same result as you. It seems that this issue has not been fixed yet.
Sorry. @kawashima-fj is correct. I saved the test file with the wrong extension.
I have noticed that using gfortran on Linux (or Compiler Explorer) results in a different output:
$ gfortran -fopenmp test.f
test.f:1:11:
1 | c$ ! 0 !
| 1
Error: Invalid character in name at (1)
If 0 is replaced by print *,'foo', the program is compiled correctly, with no warning, and foo is displayed when executing it.
On macOS, however, I see the same output reported by @ohno-fj.
In the linked PR, I have implemented the error checking as a warning, to be consistent with the current behavior of flang with regular statements, and also to avoid breaking code that doesn't expect it to be a hard error.