Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,10 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar(
"A variable in a %s directive cannot appear in an "
"EQUIVALENCE statement"_err_en_US,
ContextDirectiveAsFortran());
} else if (name->symbol->test(Symbol::Flag::InNamelist)) {
context_.Say(name->source,
"A variable in a %s directive cannot appear in a NAMELIST"_err_en_US,
ContextDirectiveAsFortran());
} else if (name->symbol->test(Symbol::Flag::OmpThreadprivate) &&
GetContext().directive ==
llvm::omp::Directive::OMPD_declare_target) {
Expand Down Expand Up @@ -1571,6 +1575,11 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar(
ContextDirectiveAsFortran(), obj->name(),
name.symbol->name());
}
if (obj->test(Symbol::Flag::InNamelist)) {
context_.Say(name.source,
"A variable in a %s directive cannot appear in a NAMELIST"_err_en_US,
ContextDirectiveAsFortran());
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions flang/test/Semantics/OpenMP/threadprivate09.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags

! Check that namelist variables cannot be used with threadprivate

module m
integer :: nam1
common /com1/nam1
namelist /nam/nam1

!ERROR: A variable in a THREADPRIVATE directive cannot appear in a NAMELIST
!$omp threadprivate(/com1/)
end
Loading