[flang-commits] [flang] [flang][Semantics][OpenMP] Check type of reduction variables (PR #94596)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Fri Jun 7 04:23:13 PDT 2024


================
@@ -2378,6 +2378,89 @@ bool OmpStructureChecker::CheckIntrinsicOperator(
   return false;
 }
 
+static bool isReductionAllowedForType(
+    const parser::OmpClause::Reduction &x, const DeclTypeSpec *type) {
+  assert(type && "no type for reduction symbol");
+  const auto &definedOp{std::get<parser::OmpReductionOperator>(x.v.t)};
+  // TODO: user defined reduction operators. Just allow everything for now.
+  bool ok{true};
+
+  auto isLogical = [](const DeclTypeSpec *type) -> bool {
+    return type->category() == DeclTypeSpec::Logical;
+  };
+  auto isCharacter = [](const DeclTypeSpec *type) -> bool {
+    return type->category() == DeclTypeSpec::Character;
+  };
+
+  common::visit(
----------------
kiranchandramohan wrote:

For builtin reductions it might be OK. At the parser level, it might not work for renames (https://github.com/llvm/llvm-project/issues/68654). In OpenMP is also user-defined declare reductions and reductions on user-defined operators.

https://github.com/llvm/llvm-project/pull/94596


More information about the flang-commits mailing list