Commit 90f9c86c

90f9c86cb2c7Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified

Description

fix: parenthesize PtrArray cast so member access binds correctly

Previously queue[i].freq on a ptr_array emitted (sp_Node *)sp_PtrArray_get(...)->freq, which C parses as (sp_Node *)(sp_PtrArray_get(...)->freq) because -> binds tighter than a cast. The generated C failed to compile as soon as a member was accessed on the element.

Wrap the cast in parentheses so ->member applies to the cast result.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
90f9c86cb2c7
Parent
cc98e27c4cf5

spinel_codegen.rbmodifiedView file

@@ -13899,7 +13899,7 @@
1389913899 return "sp_PtrArray_length(" + rc + ")"
1390013900 end
1390113901 if mname == "[]"
13902- return "(" + ct + ")sp_PtrArray_get(" + rc + ", " + compile_arg0(nid) + ")"
13902+ return "((" + ct + ")sp_PtrArray_get(" + rc + ", " + compile_arg0(nid) + "))"
1390313903 end
1390413904 if mname == "push"
1390513905 return "(sp_PtrArray_push(" + rc + ", " + compile_arg0(nid) + "), 0)"