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) == 1
27417- # Cast int to object pointer
27418- pcname = pt[4, pt.length - 4]
27417+ # Cast int to object pointer. Strip the nullable `?`
27418+ # marker before deriving the C class name — a param
27419+ # type like `obj_BoundMethod?` would otherwise produce
27420+ # `(sp_BoundMethod? *)0` and gcc chokes on the stray `?`.
27421+ pt_base = pt
27422+ if is_nullable_type(pt) == 1
27423+ pt_base = base_type(pt)
27424+ end
27425+ pcname = pt_base[4, pt_base.length - 4]
2741927426 aexpr = "(sp_" + pcname + " *)" + aexpr
2742027427 end
2742127428 end