Skip to content

Commit

Permalink
Do not explicitly cast runes to int.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Oct 16, 2022
1 parent 53c1d05 commit 7c95ef6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion literals.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func (e *CLiteral) CType(types.Type) types.Type {
}
switch e.Kind {
case CLitChar:
return types.IntT(1)
return types.AsUntypedIntT(types.UintT(1))
case CLitWChar:
panic("TODO")
default:
Expand Down
14 changes: 14 additions & 0 deletions literals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ func foo() {
_ = a
a = libc.CString("abc")
}
`,
},
{
name: "rune -> int",
src: `
void foo() {
int a = 'a';
}
`,
exp: `
func foo() {
var a int32 = 'a'
_ = a
}
`,
},
{
Expand Down

0 comments on commit 7c95ef6

Please sign in to comment.