Skip to content

Commit c2acb8d

Browse files
[LLVM-Flang][OpenMP] Add a semantic check for Worshare construct
1 parent ced15cd commit c2acb8d

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,23 @@ class OmpWorkshareBlockChecker {
6868
if (const auto *e{GetExpr(context_, expr)}) {
6969
for (const Symbol &symbol : evaluate::CollectSymbols(*e)) {
7070
const Symbol &root{GetAssociationRoot(symbol)};
71-
if (IsFunction(root) && !IsElementalProcedure(root)) {
72-
context_.Say(expr.source,
73-
"User defined non-ELEMENTAL function "
74-
"'%s' is not allowed in a WORKSHARE construct"_err_en_US,
75-
root.name());
71+
if (IsFunction(root)) {
72+
std::string attrs{""};
73+
if (!IsElementalProcedure(root)) {
74+
attrs = " non-ELEMENTAL";
75+
}
76+
if (root.attrs().test(Attr::IMPURE)) {
77+
if (attrs != "") {
78+
attrs = "," + attrs;
79+
}
80+
attrs = " IMPURE" + attrs;
81+
}
82+
if (attrs != "") {
83+
context_.Say(expr.source,
84+
"User defined%s function '%s' is not allowed in a "
85+
"WORKSHARE construct"_err_en_US,
86+
attrs, root.name());
87+
}
7688
}
7789
}
7890
}

0 commit comments

Comments
 (0)