Skip to content

Commit 42438c5

Browse files
committed
Restrict to only the threadprivate directive
1 parent 0800f12 commit 42438c5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,9 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar(
15161516
"A variable in a %s directive cannot appear in an "
15171517
"EQUIVALENCE statement"_err_en_US,
15181518
ContextDirectiveAsFortran());
1519-
} else if (name->symbol->test(Symbol::Flag::InNamelist)) {
1519+
} else if (name->symbol->test(Symbol::Flag::InNamelist) &&
1520+
GetContext().directive ==
1521+
llvm::omp::Directive::OMPD_threadprivate) {
15201522
context_.Say(name->source,
15211523
"A variable in a %s directive cannot appear in a NAMELIST"_err_en_US,
15221524
ContextDirectiveAsFortran());
@@ -1575,7 +1577,9 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar(
15751577
ContextDirectiveAsFortran(), obj->name(),
15761578
name.symbol->name());
15771579
}
1578-
if (obj->test(Symbol::Flag::InNamelist)) {
1580+
if (obj->test(Symbol::Flag::InNamelist) &&
1581+
GetContext().directive ==
1582+
llvm::omp::OMPD_threadprivate) {
15791583
context_.Say(name.source,
15801584
"A variable in a %s directive cannot appear in a NAMELIST"_err_en_US,
15811585
ContextDirectiveAsFortran());

0 commit comments

Comments
 (0)