You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Flang][OpenMP] Add Semantic Checks for Atomic Capture Construct (#108516)
This PR adds semantic checks to ensure the atomic capture construct
conforms to one of the valid forms:
[capture-stmt, update-stmt], [capture-stmt, write-stmt] or [update-stmt,
capture-stmt].
Functions checkForSymbolMatch and checkForSingleVariableOnRHS are moved
from flang/lib/Lower/DirectivesCommon.h to flang/Semantics/tools.h for
reuse.
---------
Co-authored-by: Kiran Chandramohan <[email protected]>
// ATOMIC CAPTURE construct is of the form [update-stmt, capture-stmt]
2016
+
CheckAtomicUpdateStmt(stmt1);
2017
+
CheckAtomicCaptureStmt(stmt2);
2018
+
// Variable updated in stmt1 should be captured in stmt2
2019
+
auto *v{stmt1Var.typedExpr.get()};
2020
+
auto *e{stmt2Expr.typedExpr.get()};
2021
+
if (v && e && !(v->v == e->v)) {
2022
+
context_.Say(stmt1Var.GetSource(),
2023
+
"Updated variable/array element/derived-type component %s expected to be captured in the second statement of ATOMIC CAPTURE construct"_err_en_US,
2024
+
stmt1Var.GetSource());
2025
+
}
2026
+
} else {
2027
+
context_.Say(stmt1Expr.source,
2028
+
"Invalid ATOMIC CAPTURE construct statements. Expected one of [update-stmt, capture-stmt], [capture-stmt, update-stmt], or [capture-stmt, write-stmt]"_err_en_US);
0 commit comments