From 40e7c35a2f368b6eb578eb55b62a7d831d4e2cef Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 30 Nov 2004 21:33:58 +0000 Subject: [PATCH] Do not let GCC emit a warning for INT64_MIN git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18398 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CBackend/CBackend.cpp | 7 +++++-- lib/Target/CBackend/Writer.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 7f6cadca49c..ab7a35aad72 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -536,13 +536,16 @@ void CWriter::printConstant(Constant *CPV) { Out << cast(CPV)->getValue(); break; case Type::IntTyID: if ((int)cast(CPV)->getValue() == (int)0x80000000) - Out << "((int)0x80000000)"; // Handle MININT specially to avoid warning + Out << "((int)0x80000000U)"; // Handle MININT specially to avoid warning else Out << cast(CPV)->getValue(); break; case Type::LongTyID: - Out << cast(CPV)->getValue() << "ll"; break; + if (cast(CPV)->isMinValue()) + Out << "(/*INT64_MIN*/(-9223372036854775807LL)-1)"; + else + Out << cast(CPV)->getValue() << "ll"; break; case Type::UByteTyID: case Type::UShortTyID: diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 7f6cadca49c..ab7a35aad72 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -536,13 +536,16 @@ void CWriter::printConstant(Constant *CPV) { Out << cast(CPV)->getValue(); break; case Type::IntTyID: if ((int)cast(CPV)->getValue() == (int)0x80000000) - Out << "((int)0x80000000)"; // Handle MININT specially to avoid warning + Out << "((int)0x80000000U)"; // Handle MININT specially to avoid warning else Out << cast(CPV)->getValue(); break; case Type::LongTyID: - Out << cast(CPV)->getValue() << "ll"; break; + if (cast(CPV)->isMinValue()) + Out << "(/*INT64_MIN*/(-9223372036854775807LL)-1)"; + else + Out << cast(CPV)->getValue() << "ll"; break; case Type::UByteTyID: case Type::UShortTyID: -- 2.34.1