After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 590641 - parser: casts and unary & don't play nicely
parser: casts and unary & don't play nicely
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Parser
unspecified
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-08-03 15:38 UTC by Allison Karlitskaya (desrt)
Modified: 2017-11-21 08:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix : Bug 590641 - parser: casts and unary & don't play (1011 bytes, patch)
2011-07-25 14:57 UTC, geert jordaens
none Details | Review
valaparser: Allow casts of pointer expressions without enclosing parens (2.40 KB, patch)
2016-10-17 12:03 UTC, Rico Tzschichholz
committed Details | Review

Description Allison Karlitskaya (desrt) 2009-08-03 15:38:54 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));
Comment 1 Adam Dingle 2011-03-18 16:12:55 UTC
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).
Comment 2 geert jordaens 2011-07-25 14:57:39 UTC
Created attachment 192618 [details] [review]
Fix : Bug 590641 - parser: casts and unary & don't play
Comment 3 geert jordaens 2011-07-25 14:58:37 UTC
Modified the test a bit to avoid uninitialized complaint of *p;

void main() {
    int o = 10;
    int *p = &o;    
    uint i = (uint) *p;
}
Comment 4 Rico Tzschichholz 2016-10-17 12:03:28 UTC
Created attachment 337836 [details] [review]
valaparser: Allow casts of pointer expressions without enclosing parens

Based on patch by Geert Jordaens <geert.jordaens@telenet.be>
Comment 5 Luca Bruno 2016-10-17 20:02:06 UTC
Review of attachment 337836 [details] [review]:

Looks good to me.
Comment 6 Rico Tzschichholz 2016-10-17 20:11:19 UTC
Attachment 337836 [details] pushed as f1ddd5a - valaparser: Allow casts of pointer expressions without enclosing parens