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

Changeset 785

Show
Ignore:
Timestamp:
12/06/10 07:52:42 (14 years ago)
Author:
walter
Message:

bugzilla 4217 Function overloads are not distinguished when instantiating templates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/declaration.h

    r781 r785  
    565565    enum BUILTIN builtin;               // set if this is a known, builtin 
    566566                                        // function we can evaluate at compile 
    567567                                        // time 
    568568 
    569569    int tookAddressOf;                  // set if someone took the address of 
    570570                                        // this function 
    571571    Dsymbols closureVars;               // local variables in this function 
    572572                                        // which are referenced by nested 
    573573                                        // functions 
    574574#else 
    575575    int nestedFrameRef;                 // !=0 if nested variables referenced 
    576576#endif 
    577577 
    578578    FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageClass storage_class, Type *type); 
    579579    Dsymbol *syntaxCopy(Dsymbol *); 
    580580    void semantic(Scope *sc); 
    581581    void semantic2(Scope *sc); 
    582582    void semantic3(Scope *sc); 
    583583    // called from semantic3 
    584584    void varArgs(Scope *sc, TypeFunction*, VarDeclaration *&, VarDeclaration *&); 
     585    int equals(Object *o); 
    585586 
    586587    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    587588    void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    588589    int overrides(FuncDeclaration *fd); 
    589590    int findVtblIndex(Array *vtbl, int dim); 
    590591    int overloadInsert(Dsymbol *s); 
    591592    FuncDeclaration *overloadExactMatch(Type *t); 
    592593    FuncDeclaration *overloadResolve(Loc loc, Expression *ethis, Expressions *arguments, int flags = 0); 
    593594    MATCH leastAsSpecialized(FuncDeclaration *g); 
    594595    LabelDsymbol *searchLabel(Identifier *ident); 
    595596    AggregateDeclaration *isThis(); 
    596597    AggregateDeclaration *isMember2(); 
    597598    int getLevel(Loc loc, FuncDeclaration *fd); // lexical nesting level difference 
    598599    void appendExp(Expression *e); 
    599600    void appendState(Statement *s); 
    600601    char *mangle(); 
    601602    const char *toPrettyChars(); 
    602603    int isMain(); 
    603604    int isWinMain(); 
    604605    int isDllMain(); 
  • trunk/src/func.c

    r783 r785  
    15981598 
    15991599        sc2->callSuper = 0; 
    16001600        sc2->pop(); 
    16011601    } 
    16021602 
    16031603    if (global.gag && global.errors != nerrors) 
    16041604        semanticRun = PASSsemanticdone; // Ensure errors get reported again 
    16051605    else 
    16061606        semanticRun = PASSsemantic3done; 
    16071607} 
    16081608 
    16091609void FuncDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    16101610{ 
    16111611    //printf("FuncDeclaration::toCBuffer() '%s'\n", toChars()); 
    16121612 
    16131613    StorageClassDeclaration::stcToCBuffer(buf, storage_class); 
    16141614    type->toCBuffer(buf, ident, hgs); 
    16151615    bodyToCBuffer(buf, hgs); 
    16161616} 
    16171617 
     1618int FuncDeclaration::equals(Object *o) 
     1619{ 
     1620    if (this == o) 
     1621        return TRUE; 
     1622 
     1623    Dsymbol *s = isDsymbol(o); 
     1624    if (s) 
     1625    { 
     1626        FuncDeclaration *fd = s->isFuncDeclaration(); 
     1627        if (fd) 
     1628        { 
     1629            return toParent()->equals(fd->toParent()) && 
     1630                ident->equals(fd->ident) && type->equals(fd->type); 
     1631        } 
     1632    } 
     1633    return FALSE; 
     1634} 
    16181635 
    16191636void FuncDeclaration::bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    16201637{ 
    16211638    if (fbody && 
    16221639        (!hgs->hdrgen || hgs->tpltMember || canInline(1,1)) 
    16231640       ) 
    16241641    {   buf->writenl(); 
    16251642 
    16261643        // in{} 
    16271644        if (frequire) 
    16281645        {   buf->writestring("in"); 
    16291646            buf->writenl(); 
    16301647            frequire->toCBuffer(buf, hgs); 
    16311648        } 
    16321649 
    16331650        // out{} 
    16341651        if (fensure) 
    16351652        {   buf->writestring("out"); 
    16361653            if (outId) 
    16371654            {   buf->writebyte('(');