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

Changeset 824

Show
Ignore:
Timestamp:
12/28/10 01:59:22 (14 years ago)
Author:
walter
Message:

mitigation of bugzilla 4860

Files:

Legend:

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

    r768 r824  
    31233123            directcall = 1; 
    31243124 
    31253125        if (!func->isThis()) 
    31263126            error("delegates are only for non-static functions"); 
    31273127 
    31283128        if (!func->isVirtual() || 
    31293129            directcall || 
    31303130            func->isFinal()) 
    31313131        { 
    31323132            ep = el_ptr(sfunc); 
    31333133        } 
    31343134        else 
    31353135        { 
    31363136            // Get pointer to function out of virtual table 
    31373137            unsigned vindex; 
    31383138 
    31393139            assert(ethis); 
    31403140            ep = el_same(&ethis); 
    31413141            ep = el_una(OPind, TYnptr, ep); 
    31423142            vindex = func->vtblIndex; 
     3143 
     3144            if ((int)vindex < 0) 
     3145                error("Internal compiler error: malformed delegate. See Bugzilla 4860"); 
    31433146 
    31443147            // Build *(ep + vindex * 4) 
    31453148            ep = el_bin(OPadd,TYnptr,ep,el_long(TYsize_t, vindex * PTRSIZE)); 
    31463149            ep = el_una(OPind,TYnptr,ep); 
    31473150        } 
    31483151 
    31493152//      if (func->tintro) 
    31503153//          func->error(loc, "cannot form delegate due to covariant return type"); 
    31513154    } 
    31523155    if (ethis->Eoper == OPcomma) 
    31533156    { 
    31543157        ethis->E2 = el_pair(TYdarray, ethis->E2, ep); 
    31553158        ethis->Ety = TYdarray; 
    31563159        e = ethis; 
    31573160    } 
    31583161    else 
    31593162        e = el_pair(TYdarray, ethis, ep); 
    31603163    el_setLoc(e,loc); 
    31613164    return e; 
    31623165} 
  • trunk/src/e2ir.c

    r812 r824  
    33273327            directcall = 1; 
    33283328 
    33293329        if (!func->isThis()) 
    33303330            error("delegates are only for non-static functions"); 
    33313331 
    33323332        if (!func->isVirtual() || 
    33333333            directcall || 
    33343334            func->isFinal()) 
    33353335        { 
    33363336            ep = el_ptr(sfunc); 
    33373337        } 
    33383338        else 
    33393339        { 
    33403340            // Get pointer to function out of virtual table 
    33413341            unsigned vindex; 
    33423342 
    33433343            assert(ethis); 
    33443344            ep = el_same(&ethis); 
    33453345            ep = el_una(OPind, TYnptr, ep); 
    33463346            vindex = func->vtblIndex; 
     3347 
     3348            if ((int)vindex < 0) 
     3349                error("Internal compiler error: malformed delegate. See Bugzilla 4860"); 
    33473350 
    33483351            // Build *(ep + vindex * 4) 
    33493352            ep = el_bin(OPadd,TYnptr,ep,el_long(TYsize_t, vindex * PTRSIZE)); 
    33503353            ep = el_una(OPind,TYnptr,ep); 
    33513354        } 
    33523355 
    33533356//      if (func->tintro) 
    33543357//          func->error(loc, "cannot form delegate due to covariant return type"); 
    33553358    } 
    33563359    if (ethis->Eoper == OPcomma) 
    33573360    { 
    33583361        ethis->E2 = el_pair(TYdelegate, ethis->E2, ep); 
    33593362        ethis->Ety = TYdelegate; 
    33603363        e = ethis; 
    33613364    } 
    33623365    else 
    33633366        e = el_pair(TYdelegate, ethis, ep); 
    33643367    el_setLoc(e,loc); 
    33653368    return e; 
    33663369}