Mercurial > projects > ldc
comparison dmd/expression.c @ 639:8aebdf56c455
Move check for access of context for nested class from backend into frontend.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Thu, 02 Oct 2008 23:12:19 +0200 |
parents | 4435f57956e7 |
children | eef8ac26c66c |
comparison
equal
deleted
inserted
replaced
638:94b01f15814f | 639:8aebdf56c455 |
---|---|
3368 { /* We need a 'this' pointer for the nested class. | 3368 { /* We need a 'this' pointer for the nested class. |
3369 * Ensure we have the right one. | 3369 * Ensure we have the right one. |
3370 */ | 3370 */ |
3371 Dsymbol *s = cd->toParent2(); | 3371 Dsymbol *s = cd->toParent2(); |
3372 ClassDeclaration *cdn = s->isClassDeclaration(); | 3372 ClassDeclaration *cdn = s->isClassDeclaration(); |
3373 FuncDeclaration *fdn = s->isFuncDeclaration(); | |
3373 | 3374 |
3374 //printf("cd isNested, cdn = %s\n", cdn ? cdn->toChars() : "null"); | 3375 //printf("cd isNested, cdn = %s\n", cdn ? cdn->toChars() : "null"); |
3375 if (cdn) | 3376 if (cdn) |
3376 { | 3377 { |
3377 if (!cdthis) | 3378 if (!cdthis) |
3419 } | 3420 } |
3420 #endif | 3421 #endif |
3421 } | 3422 } |
3422 else if (thisexp) | 3423 else if (thisexp) |
3423 error("e.new is only for allocating nested classes"); | 3424 error("e.new is only for allocating nested classes"); |
3425 else if (fdn) | |
3426 { | |
3427 // make sure the parent context fdn of cd is reachable from sc | |
3428 for (Dsymbol *sp = sc->parent; 1; sp = sp->parent) | |
3429 { | |
3430 if (fdn == sp) | |
3431 break; | |
3432 FuncDeclaration *fsp = sp ? sp->isFuncDeclaration() : NULL; | |
3433 if (!sp || (fsp && fsp->isStatic())) | |
3434 { | |
3435 error("outer function context of %s is needed to 'new' nested class %s", fdn->toPrettyChars(), cd->toPrettyChars()); | |
3436 break; | |
3437 } | |
3438 } | |
3439 | |
3440 } | |
3424 } | 3441 } |
3425 else if (thisexp) | 3442 else if (thisexp) |
3426 error("e.new is only for allocating nested classes"); | 3443 error("e.new is only for allocating nested classes"); |
3427 | 3444 |
3428 FuncDeclaration *f = cd->ctor; | 3445 FuncDeclaration *f = cd->ctor; |