[flang] Fix flang GCC Buildbot broken by D130731
authorMarkus Böck <markus.boeck02@gmail.com>
Mon, 1 Aug 2022 20:15:36 +0000 (22:15 +0200)
committerMarkus Böck <markus.boeck02@gmail.com>
Mon, 1 Aug 2022 20:15:45 +0000 (22:15 +0200)
GCC and that specific build bot issued warnings turned errors, due to a narrowing conversion from `unsigned` to `int32_t`. Silence these via a static_cast.

flang/lib/Optimizer/CodeGen/CodeGen.cpp

index 94ced07..ed4b71b 100644 (file)
@@ -143,7 +143,9 @@ protected:
                               unsigned boxValue) const {
     auto pty = mlir::LLVM::LLVMPointerType::get(resultTy);
     auto p = rewriter.create<mlir::LLVM::GEPOp>(
-        loc, pty, box, llvm::ArrayRef<mlir::LLVM::GEPArg>{0, boxValue});
+        loc, pty, box,
+        llvm::ArrayRef<mlir::LLVM::GEPArg>{
+            0, static_cast<std::int32_t>(boxValue)});
     return rewriter.create<mlir::LLVM::LoadOp>(loc, resultTy, p);
   }
 
@@ -185,7 +187,8 @@ protected:
   loadBaseAddrFromBox(mlir::Location loc, mlir::Type ty, mlir::Value box,
                       mlir::ConversionPatternRewriter &rewriter) const {
     auto pty = mlir::LLVM::LLVMPointerType::get(ty);
-    mlir::LLVM::GEPOp p = genGEP(loc, pty, rewriter, box, 0, kAddrPosInBox);
+    mlir::LLVM::GEPOp p = genGEP(loc, pty, rewriter, box, 0,
+                                 static_cast<std::int32_t>(kAddrPosInBox));
     return rewriter.create<mlir::LLVM::LoadOp>(loc, ty, p);
   }
 
@@ -193,7 +196,8 @@ protected:
   loadElementSizeFromBox(mlir::Location loc, mlir::Type ty, mlir::Value box,
                          mlir::ConversionPatternRewriter &rewriter) const {
     auto pty = mlir::LLVM::LLVMPointerType::get(ty);
-    mlir::LLVM::GEPOp p = genGEP(loc, pty, rewriter, box, 0, kElemLenPosInBox);
+    mlir::LLVM::GEPOp p = genGEP(loc, pty, rewriter, box, 0,
+                                 static_cast<std::int32_t>(kElemLenPosInBox));
     return rewriter.create<mlir::LLVM::LoadOp>(loc, ty, p);
   }