<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/67332>67332</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang][OpenMP][omp2012] Type confusion in reduction clause and fortran intrinsic
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            openmp,
            flang:ir,
            crash
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            NimishMishra
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          NimishMishra
      </td>
    </tr>
</table>

<pre>
    A type confusion in reduction clause and intrinsic causes a symbol type error.

```
program sample
integer :: x,y,z
!$omp parallel do default(private) REDUCTION(MIN:z)
   do i = 1, 10
       x = x + MIN(y,x)
   enddo
!$omp end parallel do
end program sample
```

causes a crash with

```
error: loc("/home/nimish/sample.f90":4:46): symbol must have a type
LLVM ERROR: aborting
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: flang-new -fc1 -fopenmp -emit-fir sample.f90 -o -
#0 0x00007f3cb03f2990 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nimish/community/llvm-project/install/bin/../lib/libLLVMSupport.so.18git+0x1d5990)
#1 0x00007f3cb03efd9f llvm::sys::RunSignalHandlers() (/home/nimish/community/llvm-project/install/bin/../lib/libLLVMSupport.so.18git+0x1d2d9f)
#2 0x00007f3cb03efef5 SignalHandler(int) Signals.cpp:0:0
#3 0x00007f3cafdfd520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f3cafe51a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007f3cafe51a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007f3cafe51a7c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007f3cafdfd476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007f3cafde37f3 abort ./stdlib/abort.c:81:7
#9 0x00007f3cb0270d74 llvm::GlobPattern::create(llvm::StringRef, std::optional<unsigned long>) (.cold) GlobPattern.cpp:0:0
#10 0x00007f3cb030de4e (/home/nimish/community/llvm-project/install/bin/../lib/libLLVMSupport.so.18git+0xf0e4e)
#11 0x00007f3cace50491 fir::emitFatalError(mlir::Location, llvm::Twine const&, bool) (/home/nimish/community/llvm-project/install/bin/../lib/../lib/libFortranLower.so.18git+0x13f491)
#12 0x00007f3cad1a3a77 (anonymous namespace)::TypeBuilderImpl::genSymbolType(Fortran::semantics::Symbol const&, bool, bool) ConvertType.cpp:0:0
#13 0x00007f3cad1a4899 Fortran::lower::translateSymbolToFIRType(Fortran::lower::AbstractConverter&, Fortran::common::Reference<Fortran::semantics::Symbol const>) (/home/nimish/community/llvm-project/install/bin/../lib/../lib/libFortranLower.so.18git+0x493899)
#14 0x00007f3cacea8837 (anonymous namespace)::FirConverter::createHostAssociateVarClone(Fortran::semantics::Symbol const&) Bridge.cpp:0:0
#15 0x00007f3cad24ab5b DataSharingProcessor::cloneSymbol(Fortran::semantics::Symbol const*) (/home/nimish/community/llvm-project/install/bin/../lib/../lib/libFortranLower.so.18git+0x539b5b)
#16 0x00007f3cad24d6e0 DataSharingProcessor::defaultPrivatize() (/home/nimish/community/llvm-project/install/bin/../lib/../lib/libFortranLower.so.18git+0x53c6e0)
#17 0x00007f3cad25d3a0 DataSharingProcessor::processStep1() (/home/nimish/community/llvm-project/install/bin/../lib/../lib/libFortranLower.so.18git+0x54c3a0)
#18 0x00007f3cad260b73 genOMP(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Evaluation&, Fortran::parser::OpenMPLoopConstruct const&) OpenMP.cpp:0:0
#19 0x00007f3cad24cb52 Fortran::lower::genOpenMPConstruct(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Evaluation&, Fortran::parser::OpenMPConstruct const&) (/home/nimish/community/llvm-project/install/bin/../lib/../lib/libFortranLower.so.18git+0x53bb52)
```

</pre>
<img width="1px" height="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