Skip to content

Commit

Permalink
Merge pull request #1093 from donc/ctfe8474classref
Browse files Browse the repository at this point in the history
8484 [CTFE] ICE(interpret.c) calling member of class passed by ref
  • Loading branch information
WalterBright committed Sep 11, 2012
2 parents 4245097 + fde72f5 commit 09b3f63
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/interpret.c
Expand Up @@ -5316,6 +5316,9 @@ Expression *CallExp::interpret(InterState *istate, CtfeGoal goal)
if (pthis->op == TOKvar)
{ assert(((VarExp*)thisval)->var->isVarDeclaration());
thisval = ((VarExp*)thisval)->var->isVarDeclaration()->getValue();
// If it is a reference, resolve it
if (thisval->op != TOKnull && thisval->op != TOKclassreference)
thisval = pthis->interpret(istate);
}
// Get the function from the vtable of the original class
ClassDeclaration *cd;
Expand Down
24 changes: 24 additions & 0 deletions test/compilable/interpret3.d
Expand Up @@ -4206,6 +4206,30 @@ bool test7158() {
}
static assert(test7158());

/**************************************************
8484
**************************************************/

class C8484 {
int n;
int b() { return n + 3; }
}

struct S {
C8484 c;
}

int t8484( ref C8484 c ){
return c.b();
}

int test8484() {
auto s = S(new C8484);
s.c.n = 4;
return t8484(s.c);
}
static assert(test8484() == 7);

/**************************************************
7419
**************************************************/
Expand Down

0 comments on commit 09b3f63

Please sign in to comment.