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

Changeset 791

Show
Ignore:
Timestamp:
12/07/10 23:19:16 (14 years ago)
Author:
walter
Message:

bugzilla 5238 PATCH: fix return of uninitialised var in interpret.c

Files:

Legend:

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

    r790 r791  
    13161316    return getVarExp(loc, istate, var); 
    13171317} 
    13181318 
    13191319Expression *DeclarationExp::interpret(InterState *istate) 
    13201320{ 
    13211321#if LOG 
    13221322    printf("DeclarationExp::interpret() %s\n", toChars()); 
    13231323#endif 
    13241324    Expression *e; 
    13251325    VarDeclaration *v = declaration->isVarDeclaration(); 
    13261326    if (v) 
    13271327    { 
    13281328        Dsymbol *s = v->toAlias(); 
    13291329        if (s == v && !v->isStatic() && v->init) 
    13301330        { 
    13311331            ExpInitializer *ie = v->init->isExpInitializer(); 
    13321332            if (ie) 
    13331333                e = ie->exp->interpret(istate); 
    13341334            else if (v->init->isVoidInitializer()) 
    13351335                e = NULL; 
     1336            else 
     1337            { 
     1338                error("Declaration %s is not yet implemented in CTFE", toChars()); 
     1339                e = EXP_CANT_INTERPRET; 
     1340            } 
    13361341        } 
    13371342#if DMDV2 
    13381343        else if (s == v && (v->isConst() || v->isImmutable()) && v->init) 
    13391344#else 
    13401345        else if (s == v && v->isConst() && v->init) 
    13411346#endif 
    13421347        {   e = v->init->toExpression(); 
    13431348            if (!e) 
    13441349                e = EXP_CANT_INTERPRET; 
    13451350            else if (!e->type) 
    13461351                e->type = v->type; 
    13471352        } 
    1348 #if 0 // currently fails test interpret3.d 
     1353        else if (s->isTupleDeclaration() && !v->init) 
     1354            e = NULL; 
    13491355        else 
    13501356        { 
    1351             error("%s cannot be interpreted at compile time"); 
     1357            error("Declaration %s is not yet implemented in CTFE", toChars()); 
    13521358            e = EXP_CANT_INTERPRET; 
    13531359        } 
    1354 #endif 
    13551360    } 
    13561361    else if (declaration->isAttribDeclaration() || 
    13571362             declaration->isTemplateMixin() || 
    13581363             declaration->isTupleDeclaration()) 
    13591364    {   // These can be made to work, too lazy now 
    1360     error("Declaration %s is not yet implemented in CTFE", toChars()); 
    1361  
     1365        error("Declaration %s is not yet implemented in CTFE", toChars()); 
    13621366        e = EXP_CANT_INTERPRET; 
    13631367    } 
    13641368    else 
    13651369    {   // Others should not contain executable code, so are trivial to evaluate 
    13661370        e = NULL; 
    13671371    } 
    13681372#if LOG 
    13691373    printf("-DeclarationExp::interpret(%s): %p\n", toChars(), e); 
    13701374#endif 
    13711375    return e; 
    13721376} 
    13731377 
    13741378Expression *TupleExp::interpret(InterState *istate) 
    13751379{ 
    13761380#if LOG 
    13771381    printf("TupleExp::interpret() %s\n", toChars()); 
    13781382#endif 
    13791383    Expressions *expsx = NULL; 
    13801384 
    13811385    for (size_t i = 0; i < exps->dim; i++) 
  • trunk/src/interpret.c

    r790 r791  
    13161316    return getVarExp(loc, istate, var); 
    13171317} 
    13181318 
    13191319Expression *DeclarationExp::interpret(InterState *istate) 
    13201320{ 
    13211321#if LOG 
    13221322    printf("DeclarationExp::interpret() %s\n", toChars()); 
    13231323#endif 
    13241324    Expression *e; 
    13251325    VarDeclaration *v = declaration->isVarDeclaration(); 
    13261326    if (v) 
    13271327    { 
    13281328        Dsymbol *s = v->toAlias(); 
    13291329        if (s == v && !v->isStatic() && v->init) 
    13301330        { 
    13311331            ExpInitializer *ie = v->init->isExpInitializer(); 
    13321332            if (ie) 
    13331333                e = ie->exp->interpret(istate); 
    13341334            else if (v->init->isVoidInitializer()) 
    13351335                e = NULL; 
     1336            else 
     1337            { 
     1338                error("Declaration %s is not yet implemented in CTFE", toChars()); 
     1339                e = EXP_CANT_INTERPRET; 
     1340            } 
    13361341        } 
    13371342#if DMDV2 
    13381343        else if (s == v && (v->isConst() || v->isImmutable()) && v->init) 
    13391344#else 
    13401345        else if (s == v && v->isConst() && v->init) 
    13411346#endif 
    13421347        {   e = v->init->toExpression(); 
    13431348            if (!e) 
    13441349                e = EXP_CANT_INTERPRET; 
    13451350            else if (!e->type) 
    13461351                e->type = v->type; 
    13471352        } 
    1348 #if 0 // currently fails test interpret3.d 
     1353        else if (s->isTupleDeclaration() && !v->init) 
     1354            e = NULL; 
    13491355        else 
    13501356        { 
    1351             error("%s cannot be interpreted at compile time"); 
     1357            error("Declaration %s is not yet implemented in CTFE", toChars()); 
    13521358            e = EXP_CANT_INTERPRET; 
    13531359        } 
    1354 #endif 
    13551360    } 
    13561361    else if (declaration->isAttribDeclaration() || 
    13571362             declaration->isTemplateMixin() || 
    13581363             declaration->isTupleDeclaration()) 
    13591364    {   // These can be made to work, too lazy now 
    1360     error("Declaration %s is not yet implemented in CTFE", toChars()); 
    1361  
     1365        error("Declaration %s is not yet implemented in CTFE", toChars()); 
    13621366        e = EXP_CANT_INTERPRET; 
    13631367    } 
    13641368    else 
    13651369    {   // Others should not contain executable code, so are trivial to evaluate 
    13661370        e = NULL; 
    13671371    } 
    13681372#if LOG 
    13691373    printf("-DeclarationExp::interpret(%s): %p\n", toChars(), e); 
    13701374#endif 
    13711375    return e; 
    13721376} 
    13731377 
    13741378Expression *TupleExp::interpret(InterState *istate) 
    13751379{ 
    13761380#if LOG 
    13771381    printf("TupleExp::interpret() %s\n", toChars()); 
    13781382#endif 
    13791383    Expressions *expsx = NULL; 
    13801384 
    13811385    for (size_t i = 0; i < exps->dim; i++)