diff options
-rw-r--r-- | compiler/cmm/PprC.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_compile/T10518.cmm | 5 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_compile/all.T | 1 |
3 files changed, 9 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. diff --git a/testsuite/tests/codeGen/should_compile/T10518.cmm b/testsuite/tests/codeGen/should_compile/T10518.cmm new file mode 100644 index 0000000000..966cd4ab53 --- /dev/null +++ b/testsuite/tests/codeGen/should_compile/T10518.cmm @@ -0,0 +1,5 @@ +foo() { + bits64 a; + a = 0x10000000000000000; // overflows 64 bits + return (a); +} diff --git a/testsuite/tests/codeGen/should_compile/all.T b/testsuite/tests/codeGen/should_compile/all.T index e06cead7c3..c78f9ac21a 100644 --- a/testsuite/tests/codeGen/should_compile/all.T +++ b/testsuite/tests/codeGen/should_compile/all.T @@ -30,3 +30,4 @@ test('debug', extra_clean(['debug.cmm']), run_command, ['$MAKE -s --no-print-directory debug']) test('T9964', normal, compile, ['-O']) +test('T10518', [cmm_src], compile, ['']) |