Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions flang/include/flang/Semantics/openmp-modifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ template <typename SpecificTy> const OmpModifierDescriptor &OmpGetDescriptor();
#define DECLARE_DESCRIPTOR(name) \
template <> const OmpModifierDescriptor &OmpGetDescriptor<name>()

DECLARE_DESCRIPTOR(parser::OmpAccessGroup);
DECLARE_DESCRIPTOR(parser::OmpAlignment);
DECLARE_DESCRIPTOR(parser::OmpAlignModifier);
DECLARE_DESCRIPTOR(parser::OmpAllocatorComplexModifier);
Expand All @@ -82,6 +83,7 @@ DECLARE_DESCRIPTOR(parser::OmpDependenceType);
DECLARE_DESCRIPTOR(parser::OmpDeviceModifier);
DECLARE_DESCRIPTOR(parser::OmpDirectiveNameModifier);
DECLARE_DESCRIPTOR(parser::OmpExpectation);
DECLARE_DESCRIPTOR(parser::OmpFallbackModifier);
DECLARE_DESCRIPTOR(parser::OmpInteropPreference);
DECLARE_DESCRIPTOR(parser::OmpInteropType);
DECLARE_DESCRIPTOR(parser::OmpIterator);
Expand Down
34 changes: 33 additions & 1 deletion flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,13 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Hint &x) {
}
}

void OmpStructureChecker::Enter(const parser::OmpClause::DynGroupprivate &x) {
CheckAllowedClause(llvm::omp::Clause::OMPC_dyn_groupprivate);
parser::CharBlock source{GetContext().clauseSource};

OmpVerifyModifiers(x.v, llvm::omp::OMPC_dyn_groupprivate, source, context_);
}

void OmpStructureChecker::Enter(const parser::OmpDirectiveSpecification &x) {
// OmpDirectiveSpecification exists on its own only in METADIRECTIVE.
// In other cases it's a part of other constructs that handle directive
Expand Down Expand Up @@ -3316,6 +3323,32 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) {
}
}

// Default access-group for DYN_GROUPPRIVATE is "cgroup". On a given
// construct there can be at most one DYN_GROUPPRIVATE with a given
// access-group.
const parser::OmpClause
*accGrpClause[parser::OmpAccessGroup::Value_enumSize] = {nullptr};
for (auto [_, clause] :
FindClauses(llvm::omp::Clause::OMPC_dyn_groupprivate)) {
auto &wrapper{std::get<parser::OmpClause::DynGroupprivate>(clause->u)};
auto &modifiers{OmpGetModifiers(wrapper.v)};
auto accGrp{parser::OmpAccessGroup::Value::Cgroup};
if (auto *ag{OmpGetUniqueModifier<parser::OmpAccessGroup>(modifiers)}) {
accGrp = ag->v;
}
auto &firstClause{accGrpClause[llvm::to_underlying(accGrp)]};
if (firstClause) {
context_
.Say(clause->source,
"The access-group modifier can only occur on a single clause in a construct"_err_en_US)
.Attach(firstClause->source,
"Previous clause with access-group modifier"_en_US);
break;
} else {
firstClause = clause;
}
}

CheckRequireAtLeastOneOf();
}

Expand Down Expand Up @@ -5472,7 +5505,6 @@ CHECK_SIMPLE_CLAUSE(Default, OMPC_default)
CHECK_SIMPLE_CLAUSE(Depobj, OMPC_depobj)
CHECK_SIMPLE_CLAUSE(DeviceType, OMPC_device_type)
CHECK_SIMPLE_CLAUSE(DistSchedule, OMPC_dist_schedule)
CHECK_SIMPLE_CLAUSE(DynGroupprivate, OMPC_dyn_groupprivate)
CHECK_SIMPLE_CLAUSE(Exclusive, OMPC_exclusive)
CHECK_SIMPLE_CLAUSE(Fail, OMPC_fail)
CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
Expand Down
32 changes: 32 additions & 0 deletions flang/lib/Semantics/openmp-modifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ unsigned OmpModifierDescriptor::since(llvm::omp::Clause id) const {
// Note: The intent for these functions is to have them be automatically-
// generated in the future.

template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpAccessGroup>() {
static const OmpModifierDescriptor desc{
/*name=*/"access-group",
/*props=*/
{
{61, {OmpProperty::Unique}},
},
/*clauses=*/
{
{61, {Clause::OMPC_dyn_groupprivate}},
},
};
return desc;
}

template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpAlignment>() {
static const OmpModifierDescriptor desc{
Expand Down Expand Up @@ -321,6 +337,22 @@ const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpExpectation>() {
return desc;
}

template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpFallbackModifier>() {
static const OmpModifierDescriptor desc{
/*name=*/"fallback-modifier",
/*props=*/
{
{61, {OmpProperty::Unique}},
},
/*clauses=*/
{
{61, {Clause::OMPC_dyn_groupprivate}},
},
};
return desc;
}

template <>
const OmpModifierDescriptor &OmpGetDescriptor<parser::OmpInteropPreference>() {
static const OmpModifierDescriptor desc{
Expand Down
8 changes: 8 additions & 0 deletions flang/test/Semantics/OpenMP/dyn-groupprivate.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=61

subroutine f00(x)
integer :: x
!ERROR: The access-group modifier can only occur on a single clause in a construct
!$omp target dyn_groupprivate(cgroup: x), dyn_groupprivate(10)
!$omp end target
end
Loading