summaryrefslogtreecommitdiff
path: root/flang/lib/Lower/ConvertExprToHLFIR.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Lower/ConvertExprToHLFIR.cpp')
-rw-r--r--flang/lib/Lower/ConvertExprToHLFIR.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/flang/lib/Lower/ConvertExprToHLFIR.cpp b/flang/lib/Lower/ConvertExprToHLFIR.cpp
index 2298e836e4cb..22425cc441b9 100644
--- a/flang/lib/Lower/ConvertExprToHLFIR.cpp
+++ b/flang/lib/Lower/ConvertExprToHLFIR.cpp
@@ -1558,7 +1558,13 @@ private:
hlfir::EntityWithAttributes
gen(const Fortran::evaluate::ImpliedDoIndex &var) {
mlir::Value value = symMap.lookupImpliedDo(toStringRef(var.name));
- assert(value && "impled do was not mapped");
+ if (!value)
+ fir::emitFatalError(getLoc(), "ac-do-variable has no binding");
+ // The index value generated by the implied-do has Index type,
+ // while computations based on it inside the loop body are using
+ // the original data type. So we need to cast it appropriately.
+ mlir::Type varTy = getConverter().genType(toEvExpr(var));
+ value = getBuilder().createConvert(getLoc(), varTy, value);
return hlfir::EntityWithAttributes{value};
}