Changeset 209

Show
Ignore:
Timestamp:
10/13/09 22:11:20 (2 years ago)
Author:
walter
Message:

bugzilla 2423

Files:

Legend:

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

    r202 r209  
    148148} 
    149149 
     150// Return TRUE if statement has no code in it 
     151int Statement::isEmpty() 
     152{ 
     153    //printf("Statement::isEmpty()\n"); 
     154    return FALSE; 
     155} 
     156 
    150157/**************************************** 
    151158 * If this statement has code that needs to run in a finally clause 
     
    254261    } 
    255262    return result; 
     263} 
     264 
     265int ExpStatement::isEmpty() 
     266{ 
     267    return exp == NULL; 
    256268} 
    257269 
     
    575587        if (!(result & BEfallthru) && !s->comeFrom()) 
    576588        { 
    577         if (s->blockExit() != BEhalt
     589        if (s->blockExit() != BEhalt && !s->isEmpty()
    578590            s->warning("statement is not reachable"); 
    579591        } 
    580  
    581         result &= ~BEfallthru; 
    582         result |= s->blockExit(); 
     592        else 
     593        { 
     594        result &= ~BEfallthru; 
     595        result |= s->blockExit(); 
     596        } 
    583597    } 
    584598    } 
     
    599613    } 
    600614    return comefrom; 
     615} 
     616 
     617int CompoundStatement::isEmpty() 
     618{ 
     619    for (int i = 0; i < statements->dim; i++) 
     620    {   Statement *s = (Statement *) statements->data[i]; 
     621    if (s && !s->isEmpty()) 
     622        return FALSE; 
     623    } 
     624    return TRUE; 
    601625} 
    602626 
     
    869893} 
    870894 
     895 
    871896int ScopeStatement::comeFrom() 
    872897{ 
    873898    //printf("ScopeStatement::comeFrom()\n"); 
    874899    return statement ? statement->comeFrom() : FALSE; 
     900} 
     901 
     902int ScopeStatement::isEmpty() 
     903{ 
     904    //printf("ScopeStatement::isEmpty() %d\n", statement ? statement->isEmpty() : TRUE); 
     905    return statement ? statement->isEmpty() : TRUE; 
    875906} 
    876907 
     
    38373868    } 
    38383869    } 
     3870 
     3871    if (!body || body->isEmpty()) 
     3872    { 
     3873    return NULL; 
     3874    } 
    38393875    return this; 
    38403876} 
  • branches/dmd-1.x/src/statement.h

    r202 r209  
    105105    virtual int blockExit(); 
    106106    virtual int comeFrom(); 
     107    virtual int isEmpty(); 
    107108    virtual void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); 
    108109    virtual Statements *flatten(Scope *sc); 
     
    141142    Expression *interpret(InterState *istate); 
    142143    int blockExit(); 
     144    int isEmpty(); 
    143145 
    144146    int inlineCost(InlineCostState *ics); 
     
    186188    int blockExit(); 
    187189    int comeFrom(); 
     190    int isEmpty(); 
    188191    Statements *flatten(Scope *sc); 
    189192    ReturnStatement *isReturnStatement(); 
     
    245248    int blockExit(); 
    246249    int comeFrom(); 
     250    int isEmpty(); 
    247251    Expression *interpret(InterState *istate); 
    248252 
  • trunk/src/statement.c

    r202 r209  
    261261    } 
    262262    return result; 
     263} 
     264 
     265int ExpStatement::isEmpty() 
     266{ 
     267    return exp == NULL; 
    263268} 
    264269 
     
    606611        if (!(result & BEfallthru) && !s->comeFrom()) 
    607612        { 
    608         if (s->blockExit() != BEhalt
     613        if (s->blockExit() != BEhalt && !s->isEmpty()
    609614            s->warning("statement is not reachable"); 
    610615        } 
    611  
    612         result &= ~BEfallthru; 
    613         result |= s->blockExit(); 
     616        else 
     617        { 
     618        result &= ~BEfallthru; 
     619        result |= s->blockExit(); 
     620        } 
    614621    } 
    615622    } 
     
    10861093    result = BEfallthru; 
    10871094    if (result & BEfallthru) 
    1088     {   if (condition->canThrow()) 
     1095    { 
     1096    if (condition->canThrow()) 
    10891097        result |= BEthrow; 
    10901098    if (!(result & BEbreak) && condition->isBool(TRUE)) 
  • trunk/src/statement.h

    r202 r209  
    142142    Expression *interpret(InterState *istate); 
    143143    int blockExit(); 
     144    int isEmpty(); 
    144145 
    145146    int inlineCost(InlineCostState *ics);