From 45343ea5acd7d4b663b116e553e24bbd15755473 Mon Sep 17 00:00:00 2001 From: Chris Lattner <sabre@nondot.org> Date: Mon, 12 May 2003 15:39:31 +0000 Subject: [PATCH] Fix bug: CWriter/2003-05-12-IntegerSizeWarning.c git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6128 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CBackend/CBackend.cpp | 8 +++++++- lib/Target/CBackend/Writer.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 2c4f6c2f9f1..3ab03e988e6 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -380,8 +380,14 @@ void CWriter::printConstant(Constant *CPV) { Out << (CPV == ConstantBool::False ? "0" : "1"); break; case Type::SByteTyID: case Type::ShortTyID: - case Type::IntTyID: Out << cast<ConstantSInt>(CPV)->getValue(); break; + case Type::IntTyID: + if ((int)cast<ConstantSInt>(CPV)->getValue() == (int)0x80000000) + Out << "((int)0x80000000)"; // Handle MININT specially to avoid warning + else + Out << cast<ConstantSInt>(CPV)->getValue(); + break; + case Type::LongTyID: Out << cast<ConstantSInt>(CPV)->getValue() << "ll"; break; diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 2c4f6c2f9f1..3ab03e988e6 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -380,8 +380,14 @@ void CWriter::printConstant(Constant *CPV) { Out << (CPV == ConstantBool::False ? "0" : "1"); break; case Type::SByteTyID: case Type::ShortTyID: - case Type::IntTyID: Out << cast<ConstantSInt>(CPV)->getValue(); break; + case Type::IntTyID: + if ((int)cast<ConstantSInt>(CPV)->getValue() == (int)0x80000000) + Out << "((int)0x80000000)"; // Handle MININT specially to avoid warning + else + Out << cast<ConstantSInt>(CPV)->getValue(); + break; + case Type::LongTyID: Out << cast<ConstantSInt>(CPV)->getValue() << "ll"; break;