<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/130312>130312</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Flang OpenMP default(none) clause is ignored when there is a single construct inside a parallel construct
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
scamp-nvidia
</td>
</tr>
</table>
<pre>
The compiler should give a compilation error with the attached test program because we have specified "default(none)" but have not specified the data-sharing for variable "x". This incorrect behavior only occurs when there is a single construct inside the parallel construct.
The relevant text from the OpenMP 6.0 specification is as follows
> 223:3 7.5.1 default Clause
> 224:11 * If data-sharing-attribute is none, each variable that is referenced in the construct and does
> 224:12 not have a predetermined data-sharing attribute must have an explicitly determined
> 224:13 data-sharing attribute.
Instead, we get an incorrect successful compilation with flang - whereas we get correct failures with nvfortran and gfortran.
Our sample code:
test.F90
```
Program main
implicit none
integer :: x
x = 1
!$omp parallel default(none)
!$omp single
print *, "x=", x
!$omp end single
!$omp end parallel
End Program main
```
Compiling with Flang versus other compilers:
```
scamp@dev-sky5:~$ flang --version
flang version 21.0.0git (https://github.com/llvm/llvm-project db5e4016c0332e7e5c0950414bb0b252975663ed)
Target: x86_64-unknown-linux-gnu
....
scamp@dev-sky5:~$ flang test.F90 -o test -fopenmp
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
scamp@dev-sky5:~$ ./test
x= 1
scamp@dev-sky5:~$ gfortran test.F90 -o test -fopenmp
test.F90:16:18:
16 | print *, "x=", x
| ^
Error: ‘x’ not specified in enclosing ‘parallel’
test.F90:14:30:
14 | !$omp parallel default(none)
| ^
note: enclosing ‘parallel’
scamp@dev-sky5:~$ nvfortran test.F90 -o test -mp
NVFORTRAN-S-0155-x must appear in a SHARED or PRIVATE clause (test.F90: 16)
0 inform, 0 warnings, 1 severes, 0 fatal for main
```
</pre>
<img width="1" height="1" alt="" src="http://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