[Flang][OpenMP] Flang does not accept assumed-length characters in declare reduction directives
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
## Summary
According to the OpenMP 6.0 specification, assumed length type parameters in declare reduction directives should be accepted, but Flang does not accept assumed-length characters.
* 7.6.14 `declare_reduction` Directive
> If a type with a deferred or assumed length type parameter is specified in a `declare_reduction` directive, the reduction identifier of that directive can be used in a reduction clause with any variable of the same type and the same kind parameter, regardless of the length type parameters with which the variable is declared.
### Reproducer
* test.f90
```fortran
!$omp declare reduction (a:character(*):omp_out=omp_in) initializer(omp_priv='0')
print *,'pass'
end
```
* commands
```console
$ flang --version
flang version 23.0.0git (https://github.com/llvm/llvm-project.git 58208a0cc165c23d2fad4ed46950b342156875ac)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/llvm/build/bin
Build config: +assertions
$ flang test.f90 -fopenmp && ./a.out
error: Semantic errors in test.f90
error: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, character named constant, or external function result
error: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, character named constant, or external function result
error: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, character named constant, or external function result
error: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, character named constant, or external function result
```
## Other Compilers
* GFortran
```console
$ gfortran --version
GNU Fortran (GCC) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gfortran test.f90 -fopenmp && ./a.out
pass
```
* Intel Fortran
```console
$ ifx --version
ifx (IFX) 2025.3.2 20260112
Copyright (C) 1985-2026 Intel Corporation. All rights reserved.
$ ifx -O0 test.f90 -qopenmp && ./a.out
pass
```
Contributor guide
Research direction
Start by compiling the provided test.f90 reproducer with Flang and -fopenmp, then trace the semantic diagnostics for the character(*) type in the declare reduction directive. Compare the behavior with the OpenMP 6.0 rule cited in the issue and the GFortran and Intel Fortran results. Done means Flang accepts the reproducer and it runs successfully, with regression coverage for the accepted directive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fortran
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100