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

Changeset 379

Show
Ignore:
Timestamp:
02/12/10 06:55:03 (15 years ago)
Author:
walter
Message:

bugzilla 3775 Segfault(cast.c): casting no-parameter template function using property syntax

Files:

Legend:

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

    r370 r379  
    73337333        // Rewrite as to.call(e1) 
    73347334        e = new TypeExp(loc, to); 
    73357335        e = new DotIdExp(loc, e, Id::call); 
    73367336        e = new CallExp(loc, e, e1); 
    73377337        e = e->semantic(sc); 
    73387338        return e; 
    73397339    } 
    73407340 
    73417341    // Struct casts are possible only when the sizes match 
    73427342    if (tob->ty == Tstruct || t1b->ty == Tstruct) 
    73437343    { 
    73447344        size_t fromsize = t1b->size(loc); 
    73457345        size_t tosize = tob->size(loc); 
    73467346        if (fromsize != tosize) 
    73477347        { 
    73487348        error("cannot cast from %s to %s", e1->type->toChars(), to->toChars()); 
    73497349        return new ErrorExp(); 
    73507350        } 
    73517351    } 
    73527352    } 
     7353 
     7354    if (!e1->type) 
     7355    {   error("cannot cast %s", e1->toChars()); 
     7356    return new ErrorExp(); 
     7357    } 
     7358 
    73537359    e = e1->castTo(sc, to); 
    73547360    return e; 
    73557361} 
    73567362 
    73577363int CastExp::checkSideEffect(int flag) 
    73587364{ 
    73597365    /* if not: 
    73607366     *  cast(void) 
    73617367     *  cast(classtype)func() 
    73627368     */ 
    73637369    if (!to->equals(Type::tvoid) && 
    73647370    !(to->ty == Tclass && e1->op == TOKcall && e1->type->ty == Tclass)) 
    73657371    return Expression::checkSideEffect(flag); 
    73667372    return 1; 
    73677373} 
    73687374 
    73697375void CastExp::checkEscape() 
    73707376{   Type *tb = type->toBasetype(); 
    73717377    if (tb->ty == Tarray && e1->op == TOKvar && 
    73727378    e1->type->toBasetype()->ty == Tsarray)