Skip to content
Merged
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
17 changes: 16 additions & 1 deletion flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,22 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar(
}
}
},
[&](const parser::Name &) {}, // common block
[&](const parser::Name &name) {
if (!name.symbol) {
return;
}
if (auto *cb{name.symbol->detailsIf<CommonBlockDetails>()}) {
for (const auto &obj : cb->objects()) {
if (FindEquivalenceSet(*obj)) {
context_.Say(name.source,
"A variable in a %s directive cannot appear in an EQUIVALENCE statement"
" (variable '%s' from common block '/%s/')"_err_en_US,
ContextDirectiveAsFortran(), obj->name(),
name.symbol->name());
}
}
}
},
},
ompObject.u);
}
Expand Down
6 changes: 6 additions & 0 deletions flang/test/Semantics/OpenMP/threadprivate02.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ program threadprivate02
integer :: arr1(10)
common /blk1/ a1
real, save :: eq_a, eq_b, eq_c, eq_d
integer :: eq_e, eq_f
equivalence(eq_e, eq_f)
common /blk2/ eq_e

!$omp threadprivate(arr1)

Expand All @@ -25,6 +28,9 @@ program threadprivate02
!$omp threadprivate(eq_c)
equivalence(eq_c, eq_d)

!ERROR: A variable in a THREADPRIVATE directive cannot appear in an EQUIVALENCE statement (variable 'eq_e' from common block '/blk2/')
!$omp threadprivate(/blk2/)

contains
subroutine func()
integer :: arr2(10)
Expand Down
Loading