Issue 87214
Summary [Flang][OpenMP] Compilation error when end single construct has a copyprivate clause
Labels openmp, flang
Assignees
Reporter ohno-fj
    ```
Version of flang-new : 19.0.0(cbcdf126ccc774c063b5d5140c1393ff5305dded)/AArch64
```

Compilation error occurs when `end single` construct has a `copyprivate` clause.

Compilation terminates normally in the following cases:
- Delete the `COPYPRIVATE` clause, or (omp30_example_a_37_01_222.f90)
- Add the following before the assignments A and B, or   (omp30_example_a_37_01_223.f90)
```
  !$OMP THREADPRIVATE(A,B)
```
- Add `PARALLEL` construct (omp30_example_a_37_01_224.f90)


The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.

omp30_example_a_37_01_22.f90:
```fortran
program main
  REAL A, B
  A=1.0
  B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE COPYPRIVATE (A,B)
  print *,'pass'
end program main
```

```
$ flang-new -fopenmp omp30_example_a_37_01_22.f90
error: Semantic errors in omp30_example_a_37_01_22.f90
./omp30_example_a_37_01_22.f90:7:31: error: COPYPRIVATE variable 'a' is not PRIVATE or THREADPRIVATE in outer context
 !$OMP END SINGLE COPYPRIVATE (A,B)
 ^
./omp30_example_a_37_01_22.f90:7:33: error: COPYPRIVATE variable 'b' is not PRIVATE or THREADPRIVATE in outer context
  !$OMP END SINGLE COPYPRIVATE (A,B)
 ^
$
```

```
$ export OMP_NUM_THREADS=1; gfortran -fopenmp omp30_example_a_37_01_22.f90; ./a.out
 pass
$
```

```
$ export OMP_NUM_THREADS=1; ifort -qopenmp -diag-disable=10448 omp30_example_a_37_01_22.f90; ./a.out
 pass
$
```

omp30_example_a_37_01_222.f90:
```fortran
program main
  REAL A, B
  A=1.0
  B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE  ! COPYPRIVATE(A,B)
  print *,'pass'
end program main
```

omp30_example_a_37_01_223.f90:
```fortran
program main
  REAL A, B
!$OMP THREADPRIVATE(A,B)
  A=1.0
 B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE COPYPRIVATE(A,B)
  print *,'pass'
end program main
```

omp30_example_a_37_01_224.f90:
```fortran
program main
  REAL A, B
!$OMP PARALLEL
  A=1.0
  B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE  COPYPRIVATE(A,B)
!$OMP END PARALLEL
  print *,'pass'
end program main
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to