Merge pull request #190 from redstar/issue8675

Fix Issue 8675 - Nothrow can't throw Errors
This commit is contained in:
Kai Nacke
2012-10-13 04:12:24 -07:00

View File

@@ -5112,8 +5112,17 @@ Statement *ThrowStatement::semantic(Scope *sc)
int ThrowStatement::blockExit(bool mustNotThrow)
{
if (mustNotThrow)
error("%s is thrown but not caught", exp->type->toChars());
return BEthrow; // obviously
{
ClassDeclaration *cd = exp->type->toBasetype()->isClassHandle();
assert(cd);
// Bugzilla 8675
// Throwing Errors is allowed even if mustNotThrow
if (cd != ClassDeclaration::errorException &&
!ClassDeclaration::errorException->isBaseOf(cd, NULL))
error("%s is thrown but not caught", exp->type->toChars());
}
return BEthrow;
}