GNOME Bugzilla – Bug 590641
parser: casts and unary & don't play nicely
Last modified: 2017-11-21 08:15:02 UTC
this code fails to parse: public static WeakReference setup (ref weak WeakReference? reference, GLib.Object owner) { ... object.add_weak_pointer ((void **) &reference); ... } simple.vala:129.42-129.42: error: syntax error, expected identifier object.add_weak_pointer ((void **) &reference); ^ Compilation failed: 1 error(s), 0 warning(s) but this is OK: object.add_weak_pointer ((void **) (&reference));
A simpler example: this code fails to parse void main() { int *p; uint i = (uint) *p; } test.vala:3.15-3.18: error: invalid left operand But this is OK: int *p; uint i = (uint) (*p); C does not require the extra parentheses in this situation. Neither does C# (at least with the Mono compiler).
Created attachment 192618 [details] [review] Fix : Bug 590641 - parser: casts and unary & don't play
Modified the test a bit to avoid uninitialized complaint of *p; void main() { int o = 10; int *p = &o; uint i = (uint) *p; }
Created attachment 337836 [details] [review] valaparser: Allow casts of pointer expressions without enclosing parens Based on patch by Geert Jordaens <geert.jordaens@telenet.be>
Review of attachment 337836 [details] [review]: Looks good to me.
Attachment 337836 [details] pushed as f1ddd5a - valaparser: Allow casts of pointer expressions without enclosing parens