summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2015-06-14 16:42:03 +0100
committerSergei Trofimovich <siarheit@google.com>2015-06-14 16:42:53 +0100
commita5084557b0b30faf3f89386ee6ee5a308dae51b1 (patch)
treebee0c708d008f0d3c65984b7a3fd162b2f1f36cb /compiler
parent6e542a62e070b113f95908315c81d01c300d8803 (diff)
downloadhaskell-a5084557b0b30faf3f89386ee6ee5a308dae51b1.tar.gz
UNREG: fix pprHexVal to emit zeros (#10518)
jakzale on #ghc reported a build failure when ported GHC on a new target. The code 'pprHexVal (2^32) W32' emits '0xU' which is invalid C. I've introduced bug in 43f1b2ecd1960fa7377cf55a2b97c66059a701ef when added literal truncation. That truncation is a new source of zeros. Signed-off-by: Sergei Trofimovich <siarheit@google.com> Test Plan: added test and tested on UNREG ghc Reviewers: austin Reviewed By: austin Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D987 GHC Trac Issues: #10518
Diffstat (limited to 'compiler')
-rw-r--r--compiler/cmm/PprC.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs
index 92c818242d..538dfcd416 100644
--- a/compiler/cmm/PprC.hs
+++ b/compiler/cmm/PprC.hs
@@ -1214,7 +1214,6 @@ commafy xs = hsep $ punctuate comma xs
-- Print in C hex format: 0x13fa
pprHexVal :: Integer -> Width -> SDoc
-pprHexVal 0 _ = ptext (sLit "0x0")
pprHexVal w rep
| w < 0 = parens (char '-' <>
ptext (sLit "0x") <> intToDoc (-w) <> repsuffix rep)
@@ -1234,7 +1233,9 @@ pprHexVal w rep
repsuffix _ = char 'U'
intToDoc :: Integer -> SDoc
- intToDoc i = go (truncInt i)
+ intToDoc i = case truncInt i of
+ 0 -> char '0'
+ v -> go v
-- We need to truncate value as Cmm backend does not drop
-- redundant bits to ease handling of negative values.