================
@@ -17367,10 +17367,32 @@ 
SemaOpenMP::ActOnOpenMPFlattenDirective(ArrayRef<OMPClause *> Clauses,
   }
 
   CaptureVars CopyTransformer(SemaRef);
-  auto MakeNumIterations = [&CopyTransformer,
-                            &LoopHelpers](unsigned I) -> Expr * {
-    return AssertSuccess(
-        CopyTransformer.TransformExpr(LoopHelpers[I].NumIterations));
+  // Convert a non-integer trip count. Width matches buildNumIterations.
+  // Signedness follows an integer loop variable so a float count stays signed.
+  auto MakeNumIterations = [&CopyTransformer, &LoopHelpers, &Context,
+                            &SemaRef =
+                                this->SemaRef](unsigned I) -> ExprResult {
+    ExprResult N = CopyTransformer.TransformExpr(LoopHelpers[I].NumIterations);
+    if (!N.isUsable())
+      return ExprError();
+    QualType Type = N.get()->getType();
+    if (Type->isIntegerType())
+      return N;
+    const auto *Counter = cast<DeclRefExpr>(LoopHelpers[I].Counters.front());
----------------
loopacino wrote:

It seems that case cannot reach this cast (should be safe) because 
`LoopHelpers[I].Counters` comes from `buildCounterVar()`, which always produces 
a `DeclRefExpr`. For a normal variable, this is already a `DeclRefExpr`. Member 
expressions are either converted to a captured decl or rejected earlier 
(`obj.i` or `p->i`) as not in canonical form. I’m only using it here to read 
the loop var type for floating point trip counts.

https://github.com/llvm/llvm-project/pull/229458
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to