Commit 70b26f01
70b26f01a31dMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
Merge pull request #340 from mame/pr/strip-nullable-int-cast
fix(codegen): strip nullable ? marker when casting int to obj pointer
Details
- Commit
- 70b26f01a31d
- Parent
- 6730228c053c
- Merge parent
- 6ddce222a647
spinel_codegen.rbmodifiedView file
@@ -27414,8 +27414,15 @@
2741427414
aexpr = compile_expr(arg_ids[k])2741527415
if at == "int"2741627416
if is_obj_type(pt) == 127417-
# Cast int to object pointer27418-
pcname = pt[4, pt.length - 4]27417+
# Cast int to object pointer. Strip the nullable `?`27418+
# marker before deriving the C class name — a param27419+
# type like `obj_BoundMethod?` would otherwise produce27420+
# `(sp_BoundMethod? *)0` and gcc chokes on the stray `?`.27421+
pt_base = pt27422+
if is_nullable_type(pt) == 127423+
pt_base = base_type(pt)27424+
end27425+
pcname = pt_base[4, pt_base.length - 4]2741927426
aexpr = "(sp_" + pcname + " *)" + aexpr2742027427
end2742127428
endtest/strip_nullable_int_cast.rbaddedView file
Loading diff…
test/strip_nullable_int_cast.rb.expectedaddedView file
Loading diff…