[flang-commits] [flang] [flang][OpenMP] Implement `CheckReductionObjects` for all reduction c… (PR #118689)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Fri Dec 6 06:17:51 PST 2024
================
@@ -2963,6 +3000,69 @@ bool OmpStructureChecker::CheckIntrinsicOperator(
return false;
}
+/// Check restrictions on objects that are common to all reduction clauses.
+void OmpStructureChecker::CheckReductionObjects(
+ const parser::OmpObjectList &objects, llvm::omp::Clause clauseId) {
+ unsigned version{context_.langOptions().OpenMPVersion};
+ SymbolSourceMap symbols;
+ GetSymbolsInObjectList(objects, symbols);
+
+ // Array sections must be a contiguous storage, have non-zero length.
+ for (const parser::OmpObject &object : objects.v) {
+ CheckIfContiguous(object);
+ }
+ CheckReductionArraySection(objects);
+ // An object must be definable.
+ CheckDefinableObjects(symbols, clauseId);
+ // Procedure pointers are not allowed.
+ CheckProcedurePointer(symbols, clauseId);
+ // Pointers must not have INTENT(IN).
+ CheckIntentInPointer(symbols, clauseId);
+
+ // Disallow common blocks.
+ // Iterate on objects because `GetSymbolsInObjectList` expands common block
+ // names into the lists of their members.
+ for (const parser::OmpObject &object : objects.v) {
+ auto *symbol{GetObjectSymbol(object)};
+ assert(symbol && "Expecting a symbol for object");
+ if (IsCommonBlock(*symbol)) {
+ auto source{GetObjectSource(object)};
+ context_.Say(source ? *source : GetContext().clauseSource,
+ "Common block names are not allowed in %s clause"_err_en_US,
+ parser::ToUpperCaseLetters(getClauseName(clauseId).str()));
+ }
+ }
+
+ if (version >= 50) {
+ // Object cannot be a part of another object (except array elements)
+ CheckStructureComponent(objects, clauseId);
+ // If object is an array section or element, the base expression must be
+ // a language identifier.
+ for (const parser::OmpObject &object : objects.v) {
+ if (auto *elem{GetArrayElementFromObj(object)}) {
+ const parser::DataRef &base = elem->base;
+ if (!std::holds_alternative<parser::Name>(base.u)) {
+ auto source{GetObjectSource(object)};
+ context_.Say(source ? *source : GetContext().clauseSource,
+ "The base expression of an array element in %s clause must be an identifier"_err_en_US,
----------------
kparzysz wrote:
Adding a testcase for type parameter inquiry as well.
https://github.com/llvm/llvm-project/pull/118689
More information about the flang-commits
mailing list