aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/dmd/dinterpret.d
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/d/dmd/dinterpret.d')
-rw-r--r--gcc/d/dmd/dinterpret.d31
1 files changed, 27 insertions, 4 deletions
diff --git a/gcc/d/dmd/dinterpret.d b/gcc/d/dmd/dinterpret.d
index fb8ed9b..b55b981 100644
--- a/gcc/d/dmd/dinterpret.d
+++ b/gcc/d/dmd/dinterpret.d
@@ -99,7 +99,15 @@ public Expression ctfeInterpret(Expression e)
Expression result = interpret(e, null);
- result = copyRegionExp(result);
+ // Report an error if the expression contained a `ThrowException` and
+ // hence generated an uncaught exception
+ if (auto tee = result.isThrownExceptionExp())
+ {
+ tee.generateUncaughtError();
+ result = CTFEExp.cantexp;
+ }
+ else
+ result = copyRegionExp(result);
if (!CTFEExp.isCantExp(result))
result = scrubReturnValue(e.loc, result);
@@ -1601,14 +1609,20 @@ public:
istate.start = null;
}
- incUsageCtfe(istate, s.loc);
+ interpretThrow(s.exp, s.loc);
+ }
+
+ /// Interpret `throw <exp>` found at the specified location `loc`
+ private void interpretThrow(Expression exp, const ref Loc loc)
+ {
+ incUsageCtfe(istate, loc);
- Expression e = interpretRegion(s.exp, istate);
+ Expression e = interpretRegion(exp, istate);
if (exceptionOrCant(e))
return;
assert(e.op == EXP.classReference);
- result = ctfeEmplaceExp!ThrownExceptionExp(s.loc, e.isClassReferenceExp());
+ result = ctfeEmplaceExp!ThrownExceptionExp(loc, e.isClassReferenceExp());
}
override void visit(ScopeGuardStatement s)
@@ -6149,6 +6163,15 @@ public:
return;
}
+ override void visit(ThrowExp te)
+ {
+ debug (LOG)
+ {
+ printf("%s ThrowExpression::interpret()\n", e.loc.toChars());
+ }
+ interpretThrow(te.e1, te.loc);
+ }
+
override void visit(PtrExp e)
{
debug (LOG)