Skip to content

Commit c75c543

Browse files
[LLVM-Flang][OpenMP] Add a semantic check for Worshare construct
1 parent 66b2820 commit c75c543

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,20 @@ 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 (symbol.attrs().test(Attr::IMPURE)) {
77+
attrs = " IMPURE" + attrs;
78+
}
79+
if (attrs != "") {
80+
context_.Say(expr.source,
81+
"User defined%s function '%s' is not allowed in a "
82+
"WORKSHARE construct"_err_en_US,
83+
attrs, root.name());
84+
}
7685
}
7786
}
7887
}

0 commit comments

Comments
 (0)