Skip to content

Commit a4bd873

Browse files
authored
Merge pull request #205 from riantkb/fix-202
fix(cxx): Always add int64 suffix to int64 literals
2 parents 838de02 + c85d23e commit a4bd873

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/Jikka/CPlusPlus/Format.hs

+1-3
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ formatType = \case
196196
formatLiteral :: Literal -> Code
197197
formatLiteral = \case
198198
LitInt32 n -> show n
199-
LitInt64 n
200-
| - (2 ^ 31) <= n && n < 2 ^ 31 -> show n
201-
| otherwise -> show n ++ "ll"
199+
LitInt64 n -> show n ++ "ll"
202200
LitBool p -> if p then "true" else "false"
203201
LitChar c -> show c
204202
LitString s -> show s

test/Jikka/CPlusPlus/FormatSpec.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ spec = do
3535
]
3636
let formatted =
3737
[ "int64_t solve(int32_t n) {",
38-
" int64_t x = 0;",
38+
" int64_t x = 0ll;",
3939
" for (int32_t i = 0; i < n; ++ i) {",
4040
" x += int64_t(i);",
4141
" }",
@@ -65,7 +65,7 @@ spec = do
6565
]
6666
let formatted =
6767
[ "int64_t solve(int32_t n, std::vector<int64_t> h) {",
68-
" int64_t x = 0;",
68+
" int64_t x = 0ll;",
6969
" for (int32_t i = 2; i < n; ++ i) {",
7070
" x += h[i - 2];",
7171
" }",

0 commit comments

Comments
 (0)