Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 11312 - Avoid auto-dereference for UFCS functions #3900

Merged
merged 1 commit into from
Aug 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -7303,12 +7303,21 @@ Expression *DotIdExp::semanticY(Scope *sc, int flag)
ident != Id::init && ident != Id::__sizeof &&
ident != Id::__xalignof && ident != Id::offsetof &&
ident != Id::mangleof && ident != Id::stringof)
{ /* Rewrite:
{
Type *t1bn = t1b->nextOf();
if (flag)
{
AggregateDeclaration *ad = isAggregate(t1bn);
if (ad && !ad->members) // Bugzilla 11312
return NULL;
}

/* Rewrite:
* p.ident
* as:
* (*p).ident
*/
if (flag && t1b->nextOf()->ty == Tvoid)
if (flag && t1bn->ty == Tvoid)
return NULL;
e = new PtrExp(loc, e1);
e = e->semantic(sc);
Expand Down
16 changes: 16 additions & 0 deletions test/runnable/ufcs.d
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,21 @@ void test10609()
static assert(__traits(compiles, x.foo10609 ));
}

/*******************************************/
// 11312

struct S11312;

S11312* getS11312() { return null; }
int getValue(S11312*) { return 10; }

void test11312()
{
S11312* op = getS11312();
int x = op.getValue();
assert(x == 10);
}

/*******************************************/

int main()
Expand Down Expand Up @@ -823,6 +838,7 @@ int main()
test10041();
test10047();
test10526();
test11312();

printf("Success\n");
return 0;
Expand Down