From 9b80037f561a495e9a0c0bcfb136e149a84680f8 Mon Sep 17 00:00:00 2001 From: kai Date: Tue, 9 Oct 2012 06:43:20 +0200 Subject: [PATCH] fix Issue 8675 - Nothrow can't throw Errors - fixed by checking whether the thrown exception is derived from Error before complaining about uncaught throws --- dmd2/statement.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dmd2/statement.c b/dmd2/statement.c index 6d94abee..a408f762 100644 --- a/dmd2/statement.c +++ b/dmd2/statement.c @@ -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; }