Closed blipvert closed 3 years ago
The bug is either in the array_cast_c_astp
grammar rule (or a rule reduced as a parameter to that rule) -- OR -- in the c_ast_add_array()
function. I haven't figured out which yet.
One difference is that when it's a stand-alone declaration (not a function argument), the array_decl_c_astp
rule has a non-NULL target_ast
; but in the array_cast_c_astp
case, target_ast
is NULL. Maybe that's it.
It turns out that the grammar rules pointer_cast_c_ast
, pointer_to_member_cast_c_ast
, and reference_cast_c_ast
were too cavalier about not copying target_ast
across to the result. Said rules are now *_astp
(AST pair) rules that copy the target_ast
across.
Anyway, I pushed a fix. Let me know.
By the way, I appreciate that you're finding these bugs, but how is it that you are trying out such complicated declarations? Do you have existing code that has such declarations? Or are you intentionally torture testing cdecl? Just curious.
I've not heard back and, AFAICT, it's fixed, so closing.
Consider the following:
So far, so good. Now as function parameter:
Also good; but when fed back to cdecl an error occurs: