diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index 2a6523f579f27..66d3a9da36505 100644 --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -2241,7 +2241,9 @@ void ResolveOmpTopLevelParts( if (!std::holds_alternative>( unit.u) && !std::holds_alternative>( - unit.u)) { + unit.u) && + !std::holds_alternative< + common::Indirection>(unit.u)) { Symbol *symbol{common::visit( [&context](auto &x) { Scope *scope = GetScope(context, x.value()); diff --git a/flang/test/Semantics/OpenMP/compiler-directive.f90 b/flang/test/Semantics/OpenMP/compiler-directive.f90 new file mode 100644 index 0000000000000..5d3e9bae27fd8 --- /dev/null +++ b/flang/test/Semantics/OpenMP/compiler-directive.f90 @@ -0,0 +1,8 @@ +! RUN: %python %S/../test_errors.py %s %flang -fopenmp +! CompilerDirective with openmp tests + +!ERROR: !DIR$ IGNORE_TKR directive must appear in a subroutine or function +!dir$ ignore_tkr + +program main +end program main