https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125016
Bug ID: 125016
Summary: Complex designator syntax error in OpenMP construct
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: ivan.pribec at gmail dot com
Target Milestone: ---
This is a bit of a corner case,
!
! OpenMP 5.2, Sec. 5.1.1, page 96, L27-28
! "A type parameter inquiry or complex part designator that is referenced
! in a construct is treated as if its designator is referenced"
!
program test_omp_simd_03
implicit none
integer, parameter :: n = 100, wp = kind(1.0e0)
type_inquiry: block
real(kind=wp) :: a(n)
integer :: i
! We assume the kind matches the number of bytes.
! The NAG Fortran compiler uses a different convention, but
! can be forced to match this with flag -kind=byte
!$omp simd simdlen(64/kind(a))
do i = 1, n
a(i) = i
end do
if (any(a /= [(i,i=1,n)])) error stop 1
!$omp simd simdlen(64/a%kind)
do i = 1, n
a(i) = n - i
end do
if (any(a /= [(n - i,i=1,n)])) error stop 2
end block type_inquiry
complex_designator: block
complex(kind=wp) :: r(n), t
integer :: i
r = 1
t = 0
!$omp simd reduction(+: t%re)
do i = 1, n
t = t + r(i)
end do
associate(s => sum(r))
if (t%re /= s%re) error stop 3
if (t%im /= s%im) error stop 4
end associate
end block complex_designator
end program
The compiler exits with the following error:
$ gfortran -fopenmp test_omp_simd_03.f90 && ./a.out
test_omp_simd_03.f90:39:30:
39 | !$omp simd reduction(+: t%re)
| 1
Error: Syntax error in OpenMP variable list at (1)
I haven't checked if there are any other rules that explicitly prohibit this.
It's also not clear what the result of t%im is if only t%re and r(i)%re were
referenced in the loop (garbage presumably?).
flang v22 accepts this. ifx rejects it with
error #9154: A list item in a REDUCTION, IN_REDUCTION or TASK_REDUCTION clause
must not be a structure component or a complex part designator. [T]
!$omp simd reduction(+: t%re)
----------------------------^