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

Changeset 230

Show
Ignore:
Timestamp:
11/01/09 04:09:34 (15 years ago)
Author:
walter
Message:

bugzilla 3422 and 3426

Files:

Legend:

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

    r215 r230  
    10901090                ei->exp = new CallExp(loc, eCall, ei->exp); 
    10911091            } 
    10921092            } 
    10931093        } 
    10941094        ei->exp = new AssignExp(loc, e1, ei->exp); 
    10951095        ei->exp->op = TOKconstruct; 
    10961096        canassign++; 
    10971097        ei->exp = ei->exp->semantic(sc); 
    10981098        canassign--; 
    10991099        ei->exp->optimize(WANTvalue); 
    11001100        } 
    11011101        else 
    11021102        { 
    11031103        init = init->semantic(sc, type); 
    11041104        if (fd && isConst() && !isStatic()) 
    11051105        {   // Make it static 
    11061106            storage_class |= STCstatic; 
    11071107        } 
    11081108        } 
    11091109    } 
    1110     else if (isConst() || isFinal()) 
     1110    else if (isConst() || isFinal() || 
     1111         parent->isAggregateDeclaration()) 
    11111112    { 
    11121113        /* Because we may need the results of a const declaration in a 
    11131114         * subsequent type, such as an array dimension, before semantic2() 
    11141115         * gets ordinarily run, try to run semantic2() now. 
    11151116         * Ignore failure. 
    11161117         */ 
    11171118 
    11181119        if (!global.errors && !inferred) 
    11191120        { 
    11201121        unsigned errors = global.errors; 
    11211122        global.gag++; 
    11221123        //printf("+gag\n"); 
    11231124        Expression *e; 
    11241125        Initializer *i2 = init; 
    11251126        inuse++; 
    11261127        if (ei) 
    11271128        { 
    11281129            e = ei->exp->syntaxCopy(); 
    11291130            e = e->semantic(sc); 
    11301131            e = e->implicitCastTo(sc, type); 
  • branches/dmd-1.x/src/expression.c

    r220 r230  
    31363136 
    31373137    elements->data[i] = (void *)e; 
    31383138    } 
    31393139 
    31403140    /* Fill out remainder of elements[] with default initializers for fields[] 
    31413141     */ 
    31423142    for (size_t i = elements->dim; i < sd->fields.dim; i++) 
    31433143    {   Dsymbol *s = (Dsymbol *)sd->fields.data[i]; 
    31443144    VarDeclaration *v = s->isVarDeclaration(); 
    31453145    assert(v); 
    31463146 
    31473147    if (v->offset < offset) 
    31483148    {   e = NULL; 
    31493149        sd->hasUnions = 1; 
    31503150    } 
    31513151    else 
    31523152    { 
    31533153        if (v->init) 
    31543154        {   e = v->init->toExpression(); 
    31553155        if (!e) 
    3156             error("cannot make expression out of initializer for %s", v->toChars()); 
     3156        {   error("cannot make expression out of initializer for %s", v->toChars()); 
     3157            e = new ErrorExp(); 
     3158        } 
     3159        else if (v->scope) 
     3160        {   // Do deferred semantic anaylsis 
     3161            Initializer *i2 = v->init->syntaxCopy(); 
     3162            i2 = i2->semantic(v->scope, v->type); 
     3163            e = i2->toExpression(); 
     3164            v->scope = NULL; 
     3165        } 
    31573166        } 
    31583167        else 
    31593168        {   e = v->type->defaultInit(); 
    31603169        e->loc = loc; 
    31613170        } 
    31623171        offset = v->offset + v->type->size(); 
    31633172    } 
    31643173    elements->push(e); 
    31653174    } 
    31663175 
    31673176    type = sd->type; 
    31683177    return this; 
    31693178} 
    31703179 
    31713180/************************************** 
    31723181 * Gets expression at offset of type. 
    31733182 * Returns NULL if not found. 
    31743183 */ 
    31753184 
    31763185Expression *StructLiteralExp::getField(Type *type, unsigned offset) 
  • trunk/src/declaration.c

    r225 r230  
    10971097                !(ti->ty == Tstruct && t->toDsymbol(sc) == ti->toDsymbol(sc))) 
    10981098            {   // Rewrite as e1.call(arguments) 
    10991099                Expression * eCall = new DotIdExp(loc, e1, Id::call); 
    11001100                ei->exp = new CallExp(loc, eCall, ei->exp); 
    11011101            } 
    11021102            } 
    11031103        } 
    11041104        ei->exp = new AssignExp(loc, e1, ei->exp); 
    11051105        ei->exp->op = op; 
    11061106        canassign++; 
    11071107        ei->exp = ei->exp->semantic(sc); 
    11081108        canassign--; 
    11091109        ei->exp->optimize(WANTvalue); 
    11101110        } 
    11111111        else 
    11121112        { 
    11131113        init = init->semantic(sc, type); 
    11141114        } 
    11151115    } 
    11161116    else if (storage_class & (STCconst | STCimmutable | STCmanifest) || 
    1117          type->isConst() || type->isInvariant()) 
     1117         type->isConst() || type->isInvariant() || 
     1118         parent->isAggregateDeclaration()) 
    11181119    { 
    11191120        /* Because we may need the results of a const declaration in a 
    11201121         * subsequent type, such as an array dimension, before semantic2() 
    11211122         * gets ordinarily run, try to run semantic2() now. 
    11221123         * Ignore failure. 
    11231124         */ 
    11241125 
    11251126        if (!global.errors && !inferred) 
    11261127        { 
    11271128        unsigned errors = global.errors; 
    11281129        global.gag++; 
    11291130        //printf("+gag\n"); 
    11301131        Expression *e; 
    11311132        Initializer *i2 = init; 
    11321133        inuse++; 
    11331134        if (ei) 
    11341135        { 
    11351136            e = ei->exp->syntaxCopy(); 
    11361137            e = e->semantic(sc); 
    11371138            e = e->implicitCastTo(sc, type); 
  • trunk/src/expression.c

    r223 r230  
    32583258    elements->data[i] = (void *)e; 
    32593259    } 
    32603260 
    32613261    /* Fill out remainder of elements[] with default initializers for fields[] 
    32623262     */ 
    32633263    for (size_t i = elements->dim; i < nfields; i++) 
    32643264    {   Dsymbol *s = (Dsymbol *)sd->fields.data[i]; 
    32653265    VarDeclaration *v = s->isVarDeclaration(); 
    32663266    assert(v); 
    32673267    assert(!v->isThisDeclaration()); 
    32683268 
    32693269    if (v->offset < offset) 
    32703270    {   e = NULL; 
    32713271        sd->hasUnions = 1; 
    32723272    } 
    32733273    else 
    32743274    { 
    32753275        if (v->init) 
    32763276        {   e = v->init->toExpression(); 
    32773277        if (!e) 
    3278             error("cannot make expression out of initializer for %s", v->toChars()); 
     3278        {   error("cannot make expression out of initializer for %s", v->toChars()); 
     3279            e = new ErrorExp(); 
     3280        } 
     3281        else if (v->scope) 
     3282        {   // Do deferred semantic anaylsis 
     3283            Initializer *i2 = v->init->syntaxCopy(); 
     3284            i2 = i2->semantic(v->scope, v->type); 
     3285            e = i2->toExpression(); 
     3286            v->scope = NULL; 
     3287        } 
    32793288        } 
    32803289        else 
    32813290        {   e = v->type->defaultInit(); 
    32823291        e->loc = loc; 
    32833292        } 
    32843293        offset = v->offset + v->type->size(); 
    32853294    } 
    32863295    elements->push(e); 
    32873296    } 
    32883297 
    32893298    type = sd->type; 
    32903299    return this; 
    32913300} 
    32923301 
    32933302/************************************** 
    32943303 * Gets expression at offset of type. 
    32953304 * Returns NULL if not found. 
    32963305 */ 
    32973306 
    32983307Expression *StructLiteralExp::getField(Type *type, unsigned offset) 
  • trunk/src/mars.c

    r214 r230  
    151151{ 
    152152    if (!global.gag) 
    153153    { 
    154154    char *p = loc.toChars(); 
    155155 
    156156    if (*p) 
    157157        fprintf(stdmsg, "%s: ", p); 
    158158    mem.free(p); 
    159159 
    160160    fprintf(stdmsg, "Error: "); 
    161161#if _MSC_VER 
    162162    // MS doesn't recognize %zu format 
    163163    OutBuffer tmp; 
    164164    tmp.vprintf(format, ap); 
    165165    fprintf(stdmsg, "%s", tmp.toChars()); 
    166166#else 
    167167    vfprintf(stdmsg, format, ap); 
    168168#endif 
    169169    fprintf(stdmsg, "\n"); 
    170170    fflush(stdmsg); 
    171 //halt(); 
     171halt(); 
    172172    } 
    173173    global.errors++; 
    174174} 
    175175 
    176176/*************************************** 
    177177 * Call this after printing out fatal error messages to clean up and exit 
    178178 * the compiler. 
    179179 */ 
    180180 
    181181void fatal() 
    182182{ 
    183183#if 0 
    184184    halt(); 
    185185#endif 
    186186    exit(EXIT_FAILURE); 
    187187} 
    188188 
    189189/************************************** 
    190190 * Try to stop forgetting to remove the breakpoints from 
    191191 * release builds.