Skip to content

Commit

Permalink
Check declaration initializer expressions for nested refs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain Buclaw committed Apr 6, 2013
1 parent a48b62f commit 8bef703
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/delegatize.c
Expand Up @@ -19,6 +19,7 @@
#include "declaration.h"
#include "aggregate.h"
#include "scope.h"
#include "init.h"

/********************************************
* Convert from expression to delegate that returns the expression,
Expand Down Expand Up @@ -136,6 +137,30 @@ int lambdaCheckForNestedRef(Expression *e, void *param)
break;
}

case TOKdeclaration:
{ DeclarationExp *de = (DeclarationExp *)e;
VarDeclaration *v = de->declaration->isVarDeclaration();
if (v)
{
v->checkNestedReference(sc, 0);

/* Some expressions cause the frontend to create a temporary.
* For example, structs with cpctors replace the original
* expression e with:
* __cpcttmp = __cpcttmp.cpctor(e);
*
* In this instance, we need to ensure that the original
* expression e does not have any nested references by
* checking the declaration initializer too.
*/
if (v->init && v->init->isExpInitializer())
{ Expression *ie = v->init->toExpression();
ie->apply (&lambdaCheckForNestedRef, param);
}
}
break;
}

default:
break;
}
Expand Down

0 comments on commit 8bef703

Please sign in to comment.