From: Chris Lattner Date: Mon, 12 May 2003 15:39:31 +0000 (+0000) Subject: Fix bug: CWriter/2003-05-12-IntegerSizeWarning.c X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45343ea5acd7d4b663b116e553e24bbd15755473;p=llvm 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 --- 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(CPV)->getValue(); break; + case Type::IntTyID: + if ((int)cast(CPV)->getValue() == (int)0x80000000) + Out << "((int)0x80000000)"; // Handle MININT specially to avoid warning + else + Out << cast(CPV)->getValue(); + break; + case Type::LongTyID: Out << cast(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(CPV)->getValue(); break; + case Type::IntTyID: + if ((int)cast(CPV)->getValue() == (int)0x80000000) + Out << "((int)0x80000000)"; // Handle MININT specially to avoid warning + else + Out << cast(CPV)->getValue(); + break; + case Type::LongTyID: Out << cast(CPV)->getValue() << "ll"; break;