<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112512>112512</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][OpenMP] compiler crash on declare reduction
</td>
</tr>
<tr>
<th>Labels</th>
<td>
crash,
flang:openmp
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tblah
</td>
</tr>
</table>
<pre>
This results in a compiler crash. We should have a "not yet implemented" message until declare reduction is fully supported
```
subroutine test_decl
integer :: my_add_red
!$omp declare reduction(my_add_red : integer : my_add_red(omp_out, omp_in)) &
!$omp& initializer(omp_priv=0)
end subroutine
```
```
fatal internal error: CHECK(context.location().has_value()) failed at /home/tomecl01/llvm-project/flang/lib/Semantics/expression.cpp(4852)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /path/bin/flang -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -fopenmp -resource-dir /home/tomecl01/build/release-assertions/lib/clang/20 -mframe-pointer=non-leaf -o /tmp/declare_reduction-9e6423.o -x f95-cpp-input /tmp/declare_reduction.f90
#0 0x0000adcd77e14c40 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/tomecl01/build/release-assertions/bin/flang+0x2f54c40)
#1 0x0000adcd77e12abc llvm::sys::RunSignalHandlers() (path/bin/flang+0x2f52abc)
#2 0x0000adcd77e154ac SignalHandler(int) Signals.cpp:0:0
#3 0x0000e1b075b3f8f8 (linux-vdso.so.1+0x8f8)
#4 0x0000e1b0754c7628 (/lib/aarch64-linux-gnu/libc.so.6+0x87628)
#5 0x0000e1b07547cb3c raise (/lib/aarch64-linux-gnu/libc.so.6+0x3cb3c)
#6 0x0000e1b075467e00 abort (/lib/aarch64-linux-gnu/libc.so.6+0x27e00)
#7 0x0000adcd798012b4 (path/bin/flang+0x49412b4)
#8 0x0000adcd789decac (path/bin/flang+0x3b1ecac)
#9 0x0000adcd78a82350 Fortran::semantics::ScopeHandler::MakeNumericType(Fortran::common::TypeCategory, std::optional<Fortran::parser::KindSelector> const&) (path/bin/flang+0x3bc2350)
#10 0x0000adcd78acf65c std::enable_if<WrapperTrait<Fortran::parser::IntegerTypeSpec>, void>::type Fortran::parser::Walk<Fortran::parser::IntegerTypeSpec, Fortran::semantics::ResolveNamesVisitor>(Fortran::parser::IntegerTypeSpec const&, Fortran::semantics::ResolveNamesVisitor&) (path/bin/flang+0x3c0f65c)
#11 0x0000adcd78acd438 void Fortran::common::log2visit::Log2VisitHelper
[...]
#15 0x0000adcd78aa5834 Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::SpecificationPart const&) (/home/tomecl01/build/release-assertions/bin/flang+0x3be5834)
#16 0x0000adcd78aa87f8 Fortran::semantics::ResolveNamesVisitor::ResolveSpecificationParts(Fortran::semantics::ProgramTree&) (path/bin/flang+0x3be87f8)
#17 0x0000adcd78aa85e0 Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&) (path/bin/flang+0x3be85e0)
[...]
flang-20: error: unable to execute command: Aborted (core dumped)
flang-20: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 20.0.0git (git@github.com:llvm/llvm-project.git 7ec32094933bbf0201ea0670209c090a00bf8d83)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: path/bin
Build config: +assertions
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
flang-20: note: diagnostic msg:
```
Reproduce with `flang -fopenmp file.f90`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykWFtzozoS_jXySxeUEGDDgx9yGdecOpedmmR3HlNCNFhnhERJwpPsr98SYMc4Ge9mtioXkLq_vkvdcOdkqxG3JL8l-f2KD35v7NZXiu9Xlalfto976cCiG5R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