Issue 184932
Summary [Flang][OpenMP] Referencing a DECLARE REDUCTION identifier via use association causes a compilation error.
Labels flang
Assignees
Reporter 3776-u2
    ```
flang version 23.0.0git (https://github.com/llvm/llvm-project.git d9ca61b6e7b9aa94d244b831a3cb6274d3839d1c)
```

In LLVM Flang, referencing an OpenMP DECLARE REDUCTION identifier that is accessible via use association results in the compilation error "Invalid reduction operator in REDUCTION clause."

According to OpenMP 6.0, section 7.6.1, a user-defined operator is permitted as a reduction identifier, and a DECLARE REDUCTION can be referenced via use association.

sample.f90
```fortran
module mod
type ty
 integer :: ii
end type
interface operator(.x.)
  function h(a,b)
 import
    type(ty),intent(in)::a,b
  end
end interface
!$omp declare reduction(.x.:ty:omp_out=ty(1))  initializer(omp_priv=ty(0))
end

use mod
type(ty)::v

v=ty(0)
!$omp parallel reduction (.x.:v)
!$omp end parallel
if (v%ii/=1) print *,102,v%ii
print *,'pass'
end
```

```
$ flang sample.f90 -fopenmp
error: Semantic errors in sample.f90
./sample.f90:18:27: error: Invalid reduction operator in REDUCTION clause.
  !$omp parallel reduction (.x.:v)
 ^^^

```

```
$ gfortran sample.f90 -fopenmp
$ ./a.out
 pass
$
```

```
$ ifx sample.f90 -fopenmp
$ ./a.out
 pass
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to