Skip to content

Commit

Permalink
Merge pull request #3900 from 9rnsr/fix11312
Browse files Browse the repository at this point in the history
Issue 11312 - Avoid auto-dereference for UFCS functions
  • Loading branch information
yebblies authored and 9rnsr committed Aug 26, 2014
1 parent 71af9f5 commit 8b6765c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/expression.c
Expand Up @@ -7407,12 +7407,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
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

0 comments on commit 8b6765c

Please sign in to comment.