diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -1507,8 +1507,8 @@ } } } else if (ompFlag == Symbol::Flag::OmpCriticalLock) { - const auto pair{ - GetContext().scope.try_emplace(name.source, Attrs{}, UnknownDetails{})}; + const auto pair{GetContext().scope.try_emplace( + name.source, Attrs{}, MiscDetails::Kind::ConstructName)}; CHECK(pair.second); name.symbol = &pair.first->second.get(); } diff --git a/flang/test/Semantics/critical05.f90 b/flang/test/Semantics/critical05.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Semantics/critical05.f90 @@ -0,0 +1,18 @@ +! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! XFAIL: * +! Checking for name collision of a critical construct with other elements of a program + +!DEF: /check_symbols MainProgram +program check_symbols + !DEF: /check_symbols/i ObjectEntity INTEGER(4) + integer i, bar + !REF: /check_symbols/i + foo: do i = 1, 10 + end do foo + + !$omp critical(foo) + !$omp end critical(foo) + + !$omp critical (bar) + !$omp end critical (bar) +end program check_symbols