Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 783

Show
Ignore:
Timestamp:
12/06/10 05:18:33 (14 years ago)
Author:
walter
Message:

bugzilla 5230 Regression(2.041, 1.057) ICE(tocsym.c) overriding a method that has an out contract

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/func.c

    r782 r783  
    15821582 
    15831583/**************************************************** 
    15841584 * Merge into this function the 'out' contracts of all it overrides. 
    15851585 * 'out's are AND'd together, i.e. all of them need to pass. 
    15861586 */ 
    15871587 
    15881588Statement *FuncDeclaration::mergeFensure(Statement *sf) 
    15891589{ 
    15901590    /* Same comments as for mergeFrequire(), except that we take care 
    15911591     * of generating a consistent reference to the 'result' local by 
    15921592     * explicitly passing 'result' to the nested function as a reference 
    15931593     * argument. 
    15941594     * This won't work for the 'this' parameter as it would require changing 
    15951595     * the semantic code for the nested function so that it looks on the parameter 
    15961596     * list for the 'this' pointer, something that would need an unknown amount 
    15971597     * of tweaking of various parts of the compiler that I'd rather leave alone. 
    15981598     */ 
    15991599    for (int i = 0; i < foverrides.dim; i++) 
    16001600    { 
    16011601        FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i]; 
     1602 
     1603        /* The semantic pass on the contracts of the overridden functions must 
     1604         * be completed before code generation occurs (bug 3602 and 5230). 
     1605         */ 
     1606        if (fdv->fdensure && fdv->fdensure->semanticRun != PASSsemantic3done) 
     1607        { 
     1608            assert(fdv->scope); 
     1609            Scope *sc = fdv->scope->push(); 
     1610            sc->stc &= ~STCoverride; 
     1611            fdv->semantic3(sc); 
     1612            sc->pop(); 
     1613        } 
     1614 
    16021615        sf = fdv->mergeFensure(sf); 
    16031616        if (fdv->fdensure) 
    16041617        { 
    16051618            //printf("fdv->fensure: %s\n", fdv->fensure->toChars()); 
    16061619            // Make the call: __ensure(result) 
    16071620            Expression *eresult = NULL; 
    16081621            if (outId) 
    16091622                eresult = new IdentifierExp(loc, outId); 
    16101623            Expression *e = new CallExp(loc, new VarExp(loc, fdv->fdensure), eresult); 
    16111624            Statement *s2 = new ExpStatement(loc, e); 
    16121625 
    16131626            if (sf) 
    16141627            { 
    16151628                sf = new CompoundStatement(fensure->loc, s2, sf); 
    16161629            } 
    16171630            else 
    16181631                sf = s2; 
    16191632        } 
    16201633    } 
    16211634    return sf; 
  • trunk/src/func.c

    r782 r783  
    17251725 
    17261726/**************************************************** 
    17271727 * Merge into this function the 'out' contracts of all it overrides. 
    17281728 * 'out's are AND'd together, i.e. all of them need to pass. 
    17291729 */ 
    17301730 
    17311731Statement *FuncDeclaration::mergeFensure(Statement *sf) 
    17321732{ 
    17331733    /* Same comments as for mergeFrequire(), except that we take care 
    17341734     * of generating a consistent reference to the 'result' local by 
    17351735     * explicitly passing 'result' to the nested function as a reference 
    17361736     * argument. 
    17371737     * This won't work for the 'this' parameter as it would require changing 
    17381738     * the semantic code for the nested function so that it looks on the parameter 
    17391739     * list for the 'this' pointer, something that would need an unknown amount 
    17401740     * of tweaking of various parts of the compiler that I'd rather leave alone. 
    17411741     */ 
    17421742    for (int i = 0; i < foverrides.dim; i++) 
    17431743    { 
    17441744        FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i]; 
     1745 
     1746        /* The semantic pass on the contracts of the overridden functions must 
     1747         * be completed before code generation occurs (bug 3602 and 5230). 
     1748         */ 
     1749        if (fdv->fdensure && fdv->fdensure->semanticRun != PASSsemantic3done) 
     1750        { 
     1751            assert(fdv->scope); 
     1752            Scope *sc = fdv->scope->push(); 
     1753            sc->stc &= ~STCoverride; 
     1754            fdv->semantic3(sc); 
     1755            sc->pop(); 
     1756        } 
     1757 
    17451758        sf = fdv->mergeFensure(sf); 
    17461759        if (fdv->fdensure) 
    17471760        { 
    17481761            //printf("fdv->fensure: %s\n", fdv->fensure->toChars()); 
    17491762            // Make the call: __ensure(result) 
    17501763            Expression *eresult = NULL; 
    17511764            if (outId) 
    17521765                eresult = new IdentifierExp(loc, outId); 
    17531766            Expression *e = new CallExp(loc, new VarExp(loc, fdv->fdensure, 0), eresult); 
    17541767            Statement *s2 = new ExpStatement(loc, e); 
    17551768 
    17561769            if (sf) 
    17571770            { 
    17581771                sf = new CompoundStatement(fensure->loc, s2, sf); 
    17591772            } 
    17601773            else 
    17611774                sf = s2; 
    17621775        } 
    17631776    } 
    17641777    return sf;