mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-14 15:16:07 +03:00
fix Issue 8675 - Nothrow can't throw Errors
- fixed by checking whether the thrown exception is derived from Error before complaining about uncaught throws
This commit is contained in:
parent
0777102e9d
commit
9b80037f56
1 changed files with 11 additions and 2 deletions
|
@ -5112,8 +5112,17 @@ Statement *ThrowStatement::semantic(Scope *sc)
|
||||||
int ThrowStatement::blockExit(bool mustNotThrow)
|
int ThrowStatement::blockExit(bool mustNotThrow)
|
||||||
{
|
{
|
||||||
if (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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue