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

Changeset 261

Show
Ignore:
Timestamp:
11/22/09 08:48:37 (15 years ago)
Author:
walter
Message:

bugzilla 3388

Files:

Legend:

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

    r253 r261  
    42954295 
    42964296ThrowStatement::ThrowStatement(Loc loc, Expression *exp) 
    42974297    : Statement(loc) 
    42984298{ 
    42994299    this->exp = exp; 
    43004300} 
    43014301 
    43024302Statement *ThrowStatement::syntaxCopy() 
    43034303{ 
    43044304    ThrowStatement *s = new ThrowStatement(loc, exp->syntaxCopy()); 
    43054305    return s; 
    43064306} 
    43074307 
    43084308Statement *ThrowStatement::semantic(Scope *sc) 
    43094309{ 
    43104310    //printf("ThrowStatement::semantic()\n"); 
    43114311 
    43124312    FuncDeclaration *fd = sc->parent->isFuncDeclaration(); 
    43134313    fd->hasReturnExp |= 2; 
    43144314 
     4315#if DMDV1 
     4316    // See bugzilla 3388. Should this be or not? 
    43154317    if (sc->incontract) 
    43164318    error("Throw statements cannot be in contracts"); 
     4319#endif 
    43174320    exp = exp->semantic(sc); 
    43184321    exp = resolveProperties(sc, exp); 
    43194322    if (!exp->type->toBasetype()->isClassHandle()) 
    43204323    error("can only throw class objects, not type %s", exp->type->toChars()); 
    43214324    return this; 
    43224325} 
    43234326 
    43244327int ThrowStatement::blockExit() 
    43254328{ 
    43264329    return BEthrow;  // obviously 
    43274330} 
    43284331 
    43294332 
    43304333void ThrowStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    43314334{ 
    43324335    buf->printf("throw "); 
    43334336    exp->toCBuffer(buf, hgs); 
    43344337    buf->writeByte(';'); 
    43354338    buf->writenl(); 
    43364339}