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

    <tr>
        <th>Summary</th>
        <td>
            !dir$ Sentinels in the wrong position in the fixed format will fatal internal error
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    
look likes this code have fatal internal error, commit is 8593c0bc025bc6d0a413e9ee7702c9c2d365d5fb

fail.f:
```
!dir$ ignore_tkr

      program main
      end program main
```

```
# Crash reproducer for clang version 18.0.0
# Driver args: "-fopenmp" "fail.f"
# Original command: "/path/to/bin/flang-new" "-fc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-fopenmp" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "x86-64" "-o" "/tmp/fail-045d43.o" "-x" "f95-cpp-input" "fail.f"
 "/path/to/bin/flang-new" "-fc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-fopenmp" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "x86-64" "-x" "f95-cpp-input" "fail-d4424c"
```

```
fatal internal error: SemanticsContext::FindScope(): invalid source location for 'dir$ ignore_tkr'
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /path/to/flang-new -fc1 -triple x86_64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -o /tmp/fail-045d43.o -x f95-cpp-input fail.f
 #0 0x000055e032bfe157 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/path/to/flang-new+0x241a157)
 #1 0x000055e032bfbf7e llvm::sys::RunSignalHandlers() (/path/to/flang-new+0x2417f7e)
 #2 0x000055e032bfeaca SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fce6c6412a0 __restore_rt (/path/to/lib/libc.so.6+0x3d2a0)
 #4 0x00007fce6c68afec __pthread_kill_implementation (/path/to/lib/libc.so.6+0x86fec)
 #5 0x00007fce6c641202 gsignal (/path/to/lib/libc.so.6+0x3d202)
 #6 0x00007fce6c62c45b abort (/path/to/lib/libc.so.6+0x2845b)
 #7 0x000055e033fde2c6 (/path/to/flang-new+0x37fa2c6)
 #8 0x000055e033423583 (/path/to/flang-new+0x2c3f583)
 #9 0x000055e03366e6c3 _ZNSt8__detail9__variant17__gen_vtable_implINS0_12_Multi_arrayIPFNS0_21__deduce_visit_resultIPN7Fortran9semantics6SymbolEEEOZZNS5_23ResolveOmpTopLevelPartsERNS5_16SemanticsContextERKNS4_6parser7ProgramEENK4$_13clIZNS5_23ResolveOmpTopLevelPartsESA_SE_E4$_14EEDaT_EUlRSI_E_RKSt7variantIJNS4_6common11IndirectionINSB_11MainProgramELb0EEENSO_INSB_18FunctionSubprogramELb0EEENSO_INSB_20SubroutineSubprogramELb0EEENSO_INSB_6ModuleELb0EEENSO_INSB_9SubmoduleELb0EEENSO_INSB_9BlockDataELb0EEENSO_INSB_17CompilerDirectiveELb0EEEEEEJEEESt16integer_sequenceImJLm6EEEE14__visit_invokeESL_S15_ resolve-directives.cpp:0:0
#10 0x000055e0336696cd Fortran::semantics::ResolveOmpTopLevelParts(Fortran::semantics::SemanticsContext&, Fortran::parser::Program const&) (/path/to/flang-new+0x2e856cd)
#11 0x000055e03340c38a std::enable_if<WrapperTrait<Fortran::parser::Program>, void>::type Fortran::parser::Walk<Fortran::parser::Program, Fortran::semantics::ResolveNamesVisitor>(Fortran::parser::Program const&, Fortran::semantics::ResolveNamesVisitor&) (/path/to/flang-new+0x2c2838a)
#12 0x000055e0333de04e Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&, Fortran::parser::Program const&, Fortran::semantics::Scope&) (/path/to/flang-new+0x2bfa04e)
#13 0x000055e033424a3b Fortran::semantics::Semantics::Perform() (/path/to/flang-new+0x2c40a3b)
#14 0x000055e032c2effa Fortran::frontend::FrontendAction::runSemanticChecks() (/path/to/flang-new+0x244affa)
#15 0x000055e032e413c1 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/path/to/flang-new+0x265d3c1)
#16 0x000055e032c2e386 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/path/to/flang-new+0x244a386)
#17 0x000055e032c1e7ef Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/path/to/flang-new+0x243a7ef)
#18 0x000055e032c3259d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/path/to/flang-new+0x244e59d)
#19 0x000055e031a62697 fc1_main(llvm::ArrayRef<char const*>, char const*) (/path/to/flang-new+0x127e697)
#20 0x000055e031a61115 main (/path/to/flang-new+0x127d115)
#21 0x00007fce6c62d1f7 __libc_start_call_main (/path/to/lib/libc.so.6+0x291f7)
#22 0x00007fce6c62d2ac __libc_start_main@GLIBC_2.2.5 (/path/to/lib/libc.so.6+0x292ac)
#23 0x000055e031a60bf1 _start (/path/to/flang-new+0x127cbf1)
flang-new: error: unable to execute command: Aborted (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 18.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to
flang-new: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-new: note: diagnostic msg: /tmp/fail-d4424c
flang-new: note: diagnostic msg: /tmp/fail-d4424c.sh
flang-new: note: diagnostic msg: 

********************
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWUtz2zgS_jX0BSUVCb4PPig2ldGMx3aZnp2qXFgg0JQwhgAuAC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