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

Changeset 590

Show
Ignore:
Timestamp:
07/30/10 05:16:35 (14 years ago)
Author:
walter
Message:

bugzilla 4514 Regression: Cannot cast from X* to X

Files:

Legend:

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

    r587 r590  
    60356035 
    60366036DelegateExp::DelegateExp(Loc loc, Expression *e, FuncDeclaration *f) 
    60376037        : UnaExp(loc, TOKdelegate, sizeof(DelegateExp), e) 
    60386038{ 
    60396039    this->func = f; 
    60406040} 
    60416041 
    60426042Expression *DelegateExp::semantic(Scope *sc) 
    60436043{ 
    60446044#if LOGSEMANTIC 
    60456045    printf("DelegateExp::semantic('%s')\n", toChars()); 
    60466046#endif 
    60476047    if (!type) 
    60486048    { 
    60496049        e1 = e1->semantic(sc); 
    60506050        type = new TypeDelegate(func->type); 
    60516051        type = type->semantic(loc, sc); 
    60526052        AggregateDeclaration *ad = func->toParent()->isAggregateDeclaration(); 
    60536053        if (func->needThis()) 
    60546054            e1 = getRightThis(loc, sc, ad, e1, func); 
    6055         if (ad && ad->type != e1->type) 
     6055        if (ad && ad->isClassDeclaration() && ad->type != e1->type) 
    60566056        {   // A downcast is required for interfaces, see Bugzilla 3706 
    60576057            e1 = new CastExp(loc, e1, ad->type); 
    60586058            e1 = e1->semantic(sc); 
    60596059        } 
    60606060    } 
    60616061    return this; 
    60626062} 
    60636063 
    60646064void DelegateExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    60656065{ 
    60666066    buf->writeByte('&'); 
    60676067    if (!func->isNested()) 
    60686068    { 
    60696069        expToCBuffer(buf, hgs, e1, PREC_primary); 
    60706070        buf->writeByte('.'); 
    60716071    } 
    60726072    buf->writestring(func->toChars()); 
    60736073} 
    60746074 
    60756075/************************************************************/ 
  • branches/dmd-1.x/src/libelf.c

    r428 r590  
    144144        h->object_name[len] = '/'; 
    145145        assert(len < OBJECT_NAME_SIZE); 
    146146        memset(h->object_name + len + 1, ' ', OBJECT_NAME_SIZE - (len + 1)); 
    147147    } 
    148148    else 
    149149    { 
    150150        len = sprintf(h->object_name, "/%d", om->name_offset); 
    151151        h->object_name[len] = ' '; 
    152152    } 
    153153 
    154154    /* In the following sprintf's, don't worry if the trailing 0 
    155155     * that sprintf writes goes off the end of the field. It will 
    156156     * write into the next field, which we will promptly overwrite 
    157157     * anyway. (So make sure to write the fields in ascending order.) 
    158158     */ 
    159159 
    160160    len = sprintf(h->file_time, "%lu", om->file_time); 
    161161    assert(len <= 12); 
    162162    memset(h->file_time + len, ' ', 12 - len); 
    163163 
     164    if (om->user_id > 999999) 
     165        om->user_id = 0; 
    164166    len = sprintf(h->user_id, "%u", om->user_id); 
    165167    assert(len <= 6); 
    166168    memset(h->user_id + len, ' ', 6 - len); 
    167169 
    168170    len = sprintf(h->group_id, "%u", om->group_id); 
    169171    assert(len <= 6); 
    170172    memset(h->group_id + len, ' ', 6 - len); 
    171173 
    172174    len = sprintf(h->file_mode, "%o", om->file_mode); 
    173175    assert(len <= 8); 
    174176    memset(h->file_mode + len, ' ', 8 - len); 
    175177 
    176178    len = sprintf(h->file_size, "%u", om->length); 
    177179    assert(len <= 10); 
    178180    memset(h->file_size + len, ' ', 10 - len); 
    179181 
    180182    h->trailer[0] = '`'; 
    181183    h->trailer[1] = '\n'; 
    182184} 
    183185 
  • trunk/src/expression.c

    r587 r590  
    63706370DelegateExp::DelegateExp(Loc loc, Expression *e, FuncDeclaration *f, int hasOverloads) 
    63716371        : UnaExp(loc, TOKdelegate, sizeof(DelegateExp), e) 
    63726372{ 
    63736373    this->func = f; 
    63746374    this->hasOverloads = hasOverloads; 
    63756375} 
    63766376 
    63776377Expression *DelegateExp::semantic(Scope *sc) 
    63786378{ 
    63796379#if LOGSEMANTIC 
    63806380    printf("DelegateExp::semantic('%s')\n", toChars()); 
    63816381#endif 
    63826382    if (!type) 
    63836383    { 
    63846384        e1 = e1->semantic(sc); 
    63856385        type = new TypeDelegate(func->type); 
    63866386        type = type->semantic(loc, sc); 
    63876387        AggregateDeclaration *ad = func->toParent()->isAggregateDeclaration(); 
    63886388        if (func->needThis()) 
    63896389            e1 = getRightThis(loc, sc, ad, e1, func); 
    6390         if (ad && ad->type != e1->type) 
     6390        if (ad && ad->isClassDeclaration() && ad->type != e1->type) 
    63916391        {   // A downcast is required for interfaces, see Bugzilla 3706 
    63926392            e1 = new CastExp(loc, e1, ad->type); 
    63936393            e1 = e1->semantic(sc); 
    63946394        } 
    63956395    } 
    63966396    return this; 
    63976397} 
    63986398 
    63996399void DelegateExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    64006400{ 
    64016401    buf->writeByte('&'); 
    64026402    if (!func->isNested()) 
    64036403    { 
    64046404        expToCBuffer(buf, hgs, e1, PREC_primary); 
    64056405        buf->writeByte('.'); 
    64066406    } 
    64076407    buf->writestring(func->toChars()); 
    64086408} 
    64096409 
    64106410/************************************************************/ 
  • trunk/src/libelf.c

    r428 r590  
    144144        h->object_name[len] = '/'; 
    145145        assert(len < OBJECT_NAME_SIZE); 
    146146        memset(h->object_name + len + 1, ' ', OBJECT_NAME_SIZE - (len + 1)); 
    147147    } 
    148148    else 
    149149    { 
    150150        len = sprintf(h->object_name, "/%d", om->name_offset); 
    151151        h->object_name[len] = ' '; 
    152152    } 
    153153 
    154154    /* In the following sprintf's, don't worry if the trailing 0 
    155155     * that sprintf writes goes off the end of the field. It will 
    156156     * write into the next field, which we will promptly overwrite 
    157157     * anyway. (So make sure to write the fields in ascending order.) 
    158158     */ 
    159159 
    160160    len = sprintf(h->file_time, "%lu", om->file_time); 
    161161    assert(len <= 12); 
    162162    memset(h->file_time + len, ' ', 12 - len); 
    163163 
     164    if (om->user_id > 999999) 
     165        om->user_id = 0; 
    164166    len = sprintf(h->user_id, "%u", om->user_id); 
    165167    assert(len <= 6); 
    166168    memset(h->user_id + len, ' ', 6 - len); 
    167169 
    168170    len = sprintf(h->group_id, "%u", om->group_id); 
    169171    assert(len <= 6); 
    170172    memset(h->group_id + len, ' ', 6 - len); 
    171173 
    172174    len = sprintf(h->file_mode, "%o", om->file_mode); 
    173175    assert(len <= 8); 
    174176    memset(h->file_mode + len, ' ', 8 - len); 
    175177 
    176178    len = sprintf(h->file_size, "%u", om->length); 
    177179    assert(len <= 10); 
    178180    memset(h->file_size + len, ' ', 10 - len); 
    179181 
    180182    h->trailer[0] = '`'; 
    181183    h->trailer[1] = '\n'; 
    182184} 
    183185