aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Semantics/check-omp-structure.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Semantics/check-omp-structure.cpp')
-rw-r--r--flang/lib/Semantics/check-omp-structure.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index ea6fe43..be10669 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -1535,6 +1535,7 @@ void OmpStructureChecker::Enter(const parser::OpenMPRequiresConstruct &x) {
[&](auto &&s) {
using TypeS = llvm::remove_cvref_t<decltype(s)>;
if constexpr ( //
+ std::is_same_v<TypeS, parser::OmpClause::DeviceSafesync> ||
std::is_same_v<TypeS, parser::OmpClause::DynamicAllocators> ||
std::is_same_v<TypeS, parser::OmpClause::ReverseOffload> ||
std::is_same_v<TypeS, parser::OmpClause::SelfMaps> ||
@@ -1561,20 +1562,11 @@ void OmpStructureChecker::Leave(const parser::OpenMPRequiresConstruct &) {
dirContext_.pop_back();
}
-void OmpStructureChecker::CheckAlignValue(const parser::OmpClause &clause) {
- if (auto *align{std::get_if<parser::OmpClause::Align>(&clause.u)}) {
- if (const auto &v{GetIntValue(align->v)}; v && *v <= 0) {
- context_.Say(clause.source, "The alignment should be positive"_err_en_US);
- }
- }
-}
-
void OmpStructureChecker::Enter(const parser::OpenMPDeclarativeAllocate &x) {
isPredefinedAllocator = true;
const auto &dir{std::get<parser::Verbatim>(x.t)};
const auto &objectList{std::get<parser::OmpObjectList>(x.t)};
PushContextAndClauseSets(dir.source, llvm::omp::Directive::OMPD_allocate);
- const auto &clauseList{std::get<parser::OmpClauseList>(x.t)};
SymbolSourceMap currSymbols;
GetSymbolsInObjectList(objectList, currSymbols);
for (auto &[symbol, source] : currSymbols) {
@@ -1597,9 +1589,6 @@ void OmpStructureChecker::Enter(const parser::OpenMPDeclarativeAllocate &x) {
source.ToString());
}
}
- for (const auto &clause : clauseList.v) {
- CheckAlignValue(clause);
- }
CheckVarIsNotPartOfAnotherVar(dir.source, objectList);
}
@@ -2006,9 +1995,6 @@ void OmpStructureChecker::Enter(const parser::OpenMPExecutableAllocate &x) {
isPredefinedAllocator = true;
const auto &objectList{std::get<std::optional<parser::OmpObjectList>>(x.t)};
- for (const auto &clause : clauseList.v) {
- CheckAlignValue(clause);
- }
if (objectList) {
CheckVarIsNotPartOfAnotherVar(dir.source, *objectList);
}
@@ -2616,7 +2602,7 @@ void OmpStructureChecker::Enter(const parser::OpenMPCriticalConstruct &x) {
auto getNameFromArg{[](const parser::OmpArgument &arg) {
if (auto *object{parser::Unwrap<parser::OmpObject>(arg.u)}) {
if (auto *designator{omp::GetDesignatorFromObj(*object)}) {
- return getDesignatorNameIfDataRef(*designator);
+ return parser::GetDesignatorNameIfDataRef(*designator);
}
}
return static_cast<const parser::Name *>(nullptr);
@@ -3233,7 +3219,6 @@ CHECK_SIMPLE_CLAUSE(AdjustArgs, OMPC_adjust_args)
CHECK_SIMPLE_CLAUSE(AppendArgs, OMPC_append_args)
CHECK_SIMPLE_CLAUSE(MemoryOrder, OMPC_memory_order)
CHECK_SIMPLE_CLAUSE(Bind, OMPC_bind)
-CHECK_SIMPLE_CLAUSE(Align, OMPC_align)
CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)
CHECK_SIMPLE_CLAUSE(OmpxAttribute, OMPC_ompx_attribute)
CHECK_SIMPLE_CLAUSE(Weak, OMPC_weak)
@@ -3897,6 +3882,19 @@ void OmpStructureChecker::CheckIsLoopIvPartOfClause(
}
}
+void OmpStructureChecker::Enter(const parser::OmpClause::Align &x) {
+ CheckAllowedClause(llvm::omp::Clause::OMPC_align);
+ if (const auto &v{GetIntValue(x.v.v)}) {
+ if (*v <= 0) {
+ context_.Say(GetContext().clauseSource,
+ "The alignment should be positive"_err_en_US);
+ } else if (!llvm::isPowerOf2_64(*v)) {
+ context_.Say(GetContext().clauseSource,
+ "The alignment should be a power of 2"_err_en_US);
+ }
+ }
+}
+
// Restrictions specific to each clause are implemented apart from the
// generalized restrictions.
void OmpStructureChecker::Enter(const parser::OmpClause::Aligned &x) {
@@ -5194,6 +5192,10 @@ void OmpStructureChecker::Enter(
CheckAllowedRequiresClause(llvm::omp::Clause::OMPC_atomic_default_mem_order);
}
+void OmpStructureChecker::Enter(const parser::OmpClause::DeviceSafesync &x) {
+ CheckAllowedRequiresClause(llvm::omp::Clause::OMPC_device_safesync);
+}
+
void OmpStructureChecker::Enter(const parser::OmpClause::DynamicAllocators &x) {
CheckAllowedRequiresClause(llvm::omp::Clause::OMPC_dynamic_allocators);
}