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

Changeset 822

Show
Ignore:
Timestamp:
12/27/10 22:17:08 (14 years ago)
Author:
walter
Message:

bugzilla 5025 ICE(cast.c) shared struct literal

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/cast.c

    r818 r822  
    409409    return Expression::implicitConvTo(t); 
    410410} 
    411411 
    412412#if DMDV2 
    413413MATCH StructLiteralExp::implicitConvTo(Type *t) 
    414414{ 
    415415#if 0 
    416416    printf("StructLiteralExp::implicitConvTo(this=%s, type=%s, t=%s)\n", 
    417417        toChars(), type->toChars(), t->toChars()); 
    418418#endif 
    419419    MATCH m = Expression::implicitConvTo(t); 
    420420    if (m != MATCHnomatch) 
    421421        return m; 
    422422    if (type->ty == t->ty && type->ty == Tstruct && 
    423423        ((TypeStruct *)type)->sym == ((TypeStruct *)t)->sym) 
    424424    { 
    425425        m = MATCHconst; 
    426426        for (int i = 0; i < elements->dim; i++) 
    427427        {   Expression *e = (Expression *)elements->data[i]; 
    428428            Type *te = e->type; 
    429             if (t->mod == 0) 
    430                 te = te->mutableOf(); 
    431             else 
    432             {   assert(t->mod == MODimmutable); 
    433                 te = te->invariantOf(); 
    434             } 
     429            te = te->castMod(t->mod); 
    435430            MATCH m2 = e->implicitConvTo(te); 
    436431            //printf("\t%s => %s, match = %d\n", e->toChars(), te->toChars(), m2); 
    437432            if (m2 < m) 
    438433                m = m2; 
    439434        } 
    440435    } 
    441436    return m; 
    442437} 
    443438#endif 
    444439 
    445440MATCH StringExp::implicitConvTo(Type *t) 
    446441{   MATCH m; 
    447442 
    448443#if 0 
    449444    printf("StringExp::implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n", 
    450445        toChars(), committed, type->toChars(), t->toChars()); 
    451446#endif 
    452447    if (!committed && t->ty == Tpointer && t->nextOf()->ty == Tvoid) 
    453448    { 
    454449        return MATCHnomatch;