Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions compiler/passes/errorHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class ErrorHandlingVisitor final : public AstVisitorTraverse {
AList errorCond(VarSymbol* errorVar,
BlockStmt* thenBlock,
BlockStmt* elseBlock = NULL);
CallExpr* haltExpr(VarSymbol* error, bool tryBang);
void haltExpr(VarSymbol* error, bool tryBang, BlockStmt* body, Symbol* parent);
void setupForThrowingLoop(Stmt* node,
LabelSymbol* handlerLabel,
BlockStmt* body);
Expand Down Expand Up @@ -356,7 +356,7 @@ void ErrorHandlingVisitor::lowerCatches(const TryInfo& info) {

if (!hasCatchAll) {
if (tryStmt->tryBang()) {
currHandler->insertAtTail(haltExpr(errorVar, true));
haltExpr(errorVar, true, currHandler, tryStmt->parentSymbol);
} else if (!tryStack.empty()) {
currHandler->insertAtTail(setOuterErrorAndGotoHandler(errorVar, tryStmt->parentSymbol));
} else if (outError != NULL) {
Expand Down Expand Up @@ -410,9 +410,12 @@ bool ErrorHandlingVisitor::enterCallExpr(CallExpr* node) {
errorVar = info.errorVar;

// (a) an enclosing try/try!
errorPolicy->insertAtTail(
new CallExpr(PRIM_MOVE, errorVar,
new CallExpr(gChplErrorPropagateStackInfo, new SymExpr(errorVar))));
if (!node->parentSymbol ||
!node->parentSymbol->hasFlag(FLAG_COMPILER_GENERATED)) {
errorPolicy->insertAtTail(
new CallExpr(PRIM_MOVE, errorVar,
new CallExpr(gChplErrorPropagateStackInfo, new SymExpr(errorVar))));
}
errorPolicy->insertAtTail(gotoHandler());
} else {
// without try, need an error variable
Expand All @@ -429,19 +432,19 @@ bool ErrorHandlingVisitor::enterCallExpr(CallExpr* node) {
if (node->parentSymbol->hasFlag(FLAG_ITERATOR_FN))
// (c) coforall or similar in a non-throwing iterator
// ==> we will propagate the error when the iterator is inlined
errorPolicy->insertAtTail(haltExpr(errorVar, false));
haltExpr(errorVar, false, errorPolicy, node->parentSymbol);
else if (node->parentSymbol->hasFlag(FLAG_TASK_FN_FROM_ITERATOR_FN))
// (d) coforall/... in a task function in a non-throwing iterator
// ==> propagate the error through the task function
errorPolicy->insertAtTail(setOutGotoEpilogue(errorVar, node->parentSymbol));
else
// (e) coforall or similar in a non-throwing procedure
// ==> halt right away
errorPolicy->insertAtTail(haltExpr(errorVar, true));
haltExpr(errorVar, true, errorPolicy, node->parentSymbol);
}
else {
// (f) a throwing call in a non-throwing function ==> halt right away
errorPolicy->insertAtTail(haltExpr(errorVar, true));
haltExpr(errorVar, true, errorPolicy, node->parentSymbol);
}
}

Expand Down Expand Up @@ -632,7 +635,7 @@ void ErrorHandlingVisitor::exitForallLoop(Stmt* node) {
} else if (outError != NULL) {
handler->insertAtTail(setOutGotoEpilogue(normErr, node->parentSymbol));
} else {
handler->insertAtTail(haltExpr(normErr, false));
haltExpr(normErr, false, handler, node->parentSymbol);
}
info.handlerLabel->defPoint->insertAfter(errorCond(err, handler));
}
Expand Down Expand Up @@ -846,11 +849,14 @@ static AList errorCondHelper(VarSymbol* errorVar,
// (with try!). If not, the compiler is adding the halt-on-error for one
// reason or another and later passes should be able to change the halt
// into other error handling (as with, say, iterator inlining).
CallExpr* ErrorHandlingVisitor::haltExpr(VarSymbol* errorVar, bool tryBang) {
if (tryBang)
return new CallExpr(gChplUncaughtError, errorVar);

return new CallExpr(gChplPropagateError, errorVar);
void ErrorHandlingVisitor::haltExpr(VarSymbol* errorVar, bool tryBang, BlockStmt* block, Symbol* parent) {
auto retFunc = tryBang ? gChplUncaughtError : gChplPropagateError;
if (!parent || !parent->hasFlag(FLAG_COMPILER_GENERATED)) {
block->insertAtTail(
new CallExpr(PRIM_MOVE, errorVar,
new CallExpr(gChplErrorPropagateStackInfo, new SymExpr(errorVar))));
}
block->insertAtTail(new CallExpr(retFunc, errorVar));
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uncaught Error: value too large
tryBangExpressionDefaultRecord.chpl:5: thrown here
tryBangExpressionDefaultRecord.chpl:22: uncaught here
tryBangExpressionDefaultRecord.chpl:22: called from here
tryBangExpressionDefaultRecord.chpl:28: uncaught here
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(x = 8)
uncaught Error: value too large
tryBangExpressionRecord.chpl:5: thrown here
tryBangExpressionRecord.chpl:14: uncaught here
tryBangExpressionRecord.chpl:14: called from here
tryBangExpressionRecord.chpl:22: uncaught here
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uncaught Error:
initWithTryBang.chpl:16: thrown here
initWithTryBang.chpl:19: called from here
initWithTryBang.chpl:19: uncaught here
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uncaught Error:
initWithTryBang2.chpl:14: thrown here
initWithTryBang2.chpl:17: called from here
initWithTryBang2.chpl:17: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/output-format.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
MyError: custom message
uncaught MyError: custom message
output-format.chpl:14: thrown here
output-format.chpl:18: called from here
output-format.chpl:18: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/ferguson/returns-in-try.1.good
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uncaught MyError:
returns-in-try.chpl:10: thrown here
returns-in-try.chpl:17: uncaught here
returns-in-try.chpl:17: called from here
returns-in-try.chpl:16: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/ferguson/returns-in-try.2.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
1
uncaught MyError:
returns-in-try.chpl:10: thrown here
returns-in-try.chpl:22: uncaught here
returns-in-try.chpl:22: called from here
returns-in-try.chpl:21: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/ferguson/returns-in-try.6.good
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
5
uncaught MyError:
returns-in-try.chpl:10: thrown here
returns-in-try.chpl:50: uncaught here
returns-in-try.chpl:50: called from here
returns-in-try.chpl:49: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/throws-destroys.1.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ in simpleThrow, r=(x = 1)
destroying R(x=1)
uncaught Error:
throws-destroys.chpl:36: thrown here
throws-destroys.chpl:9: called from here
throws-destroys.chpl:9: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/throws-destroys.2.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ in conditionalThrow, r=(x = 2)
destroying R(x=2)
uncaught Error:
throws-destroys.chpl:42: thrown here
throws-destroys.chpl:11: called from here
throws-destroys.chpl:11: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/throws-destroys.4.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ in loopThrow, r=(x = 3)
destroying R(x=3)
uncaught Error:
throws-destroys.chpl:49: thrown here
throws-destroys.chpl:15: called from here
throws-destroys.chpl:15: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/throws-destroys.5.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ in loopThrow, r=(x = 3)
destroying R(x=3)
uncaught Error:
throws-destroys.chpl:49: thrown here
throws-destroys.chpl:17: called from here
throws-destroys.chpl:17: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/throws-destroys.6.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ in inThrow, r=(x = 4)
destroying R(x=4)
uncaught Error:
throws-destroys.chpl:55: thrown here
throws-destroys.chpl:19: called from here
throws-destroys.chpl:19: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/throws-destroys.7.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ in loopThrow, r=(x = 101)
destroying R(x=101)
uncaught Error:
throws-destroys.chpl:63: thrown here
throws-destroys.chpl:21: called from here
throws-destroys.chpl:21: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/throws-destroys.8.good
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ in loopThrow, r=(x = 102)
destroying R(x=102)
uncaught Error:
throws-destroys.chpl:63: thrown here
throws-destroys.chpl:23: called from here
throws-destroys.chpl:23: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/try-expr-nested.4.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
uncaught StringError: Test
try-expr-nested.chpl:9: thrown here
try-expr-nested.chpl:31: called from here
try-expr-nested.chpl:39: called from here
try-expr-nested.chpl:39: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/ferguson/try-expr-nested.5.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
uncaught StringError: Test
try-expr-nested.chpl:9: thrown here
try-expr-nested.chpl:33: called from here
try-expr-nested.chpl:39: called from here
try-expr-nested.chpl:39: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/ferguson/try-expr.8.good
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uncaught StringError: Test
try-expr.chpl:9: thrown here
try-expr.chpl:18: uncaught here
try-expr.chpl:18: called from here
try-expr.chpl:39: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/misc/issue-23905.comm-none.good
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uncaught TaskErrors: 2 errors: Error: in forall ... Error: in forall
issue-23905.chpl:6: thrown here
issue-23905.chpl:6: uncaught here
issue-23905.chpl:6: called from here
issue-23905.chpl:2: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/misc/issue-23905.good
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uncaught TaskErrors: 8 errors: Error: in forall ... Error: in forall
issue-23905.chpl:6: thrown here
issue-23905.chpl:6: uncaught here
issue-23905.chpl:6: called from here
issue-23905.chpl:2: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/psahabu/coforall-try-bang-2.good
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uncaught Error:
coforall-try-bang-2.chpl:3: thrown here
coforall-try-bang-2.chpl:9: uncaught here
coforall-try-bang-2.chpl:9: called from here
coforall-try-bang-2.chpl:8: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/psahabu/coforall-try-bang-nested.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
uncaught Error:
coforall-try-bang-nested.chpl:3: thrown here
coforall-try-bang-nested.chpl:10: called from here
coforall-try-bang-nested.chpl:9: uncaught here
coforall-try-bang-nested.chpl:9: called from here
coforall-try-bang-nested.chpl:8: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/psahabu/defer-throw-fatal.1.good
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uncaught Error:
defer-throw-fatal.chpl:14: thrown here
defer-throw-fatal.chpl:13: uncaught here
defer-throw-fatal.chpl:13: called from here
defer-throw-fatal.chpl:42: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/psahabu/no-prop.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ calling noPropError
should not propagate
uncaught Error:
../ExampleErrors.chpl:2: thrown here
no-prop.chpl:5: called from here
no-prop.chpl:5: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/psahabu/propagate-implicit.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
calling propError
uncaught Error:
../ExampleErrors.chpl:2: thrown here
propagate-implicit.chpl:4: uncaught here
propagate-implicit.chpl:4: called from here
propagate-implicit.chpl:9: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/psahabu/propagate.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ calling propError
uncaught Error:
../ExampleErrors.chpl:2: thrown here
propagate.chpl:4: called from here
propagate.chpl:4: uncaught here
propagate.chpl:4: called from here
propagate.chpl:9: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/psahabu/throw-nil.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
throwing nil
uncaught NilThrownError: thrown error was nil
throw-nil.chpl:3: thrown here
throw-nil.chpl:7: called from here
throw-nil.chpl:7: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/psahabu/top-try-bang.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
should not continue
uncaught Error:
../ExampleErrors.chpl:2: thrown here
top-try-bang.chpl:5: called from here
top-try-bang.chpl:5: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/stacktrace/basic.1-0.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ uncaught Error: oops
basic.chpl:2: thrown here
basic.chpl:5: called from here
basic.chpl:8: called from here
basic.chpl:24: called from here
basic.chpl:24: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/stacktrace/basic.2-0.good
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ uncaught Error: oops
basic.chpl:2: thrown here
basic.chpl:5: called from here
basic.chpl:8: called from here
basic.chpl:24: called from here
basic.chpl:24: uncaught here
3 changes: 2 additions & 1 deletion test/errhandling/stacktrace/basicExpr.good
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
uncaught Error: oops
basicExpr.chpl:2: thrown here
basicExpr.chpl:6: called from here
basicExpr.chpl:9: uncaught here
basicExpr.chpl:9: called from here
basicExpr.chpl:13: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/stacktrace/basicInline.1-0.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ uncaught Error: oops
basicInline.chpl:2: thrown here
basicInline.chpl:5: called from here
basicInline.chpl:8: called from here
basicInline.chpl:24: called from here
basicInline.chpl:24: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/stacktrace/basicInline.2-0.good
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ uncaught Error: oops
basicInline.chpl:2: thrown here
basicInline.chpl:5: called from here
basicInline.chpl:8: called from here
basicInline.chpl:24: called from here
basicInline.chpl:24: uncaught here
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ uncaught TaskErrors: 1 errors: Error: oops
propagateThroughCoforall.chpl:5: thrown here
propagateThroughCoforall.chpl:5: called from here
propagateThroughCoforall.chpl:11: called from here
propagateThroughCoforall.chpl:34: called from here
propagateThroughCoforall.chpl:34: uncaught here
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ uncaught TaskErrors: 1 errors: Error: oops
propagateThroughCoforall.chpl:5: thrown here
propagateThroughCoforall.chpl:5: called from here
propagateThroughCoforall.chpl:11: called from here
propagateThroughCoforall.chpl:34: called from here
propagateThroughCoforall.chpl:34: uncaught here
2 changes: 2 additions & 0 deletions test/errhandling/stacktrace/propagateThroughForall.1-0.good
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
uncaught TaskErrors: 1 errors: Error: oops
propagateThroughForall.chpl:5: thrown here
propagateThroughForall.chpl:5: called from here
propagateThroughForall.chpl:5: called from here
propagateThroughForall.chpl:11: called from here
propagateThroughForall.chpl:34: called from here
propagateThroughForall.chpl:34: uncaught here
7 changes: 5 additions & 2 deletions test/errhandling/stacktrace/propagateThroughForall.2-0.good
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ caught error: 1 errors: Error: oops
stack trace:
(frame 1) propagateThroughForall.chpl:5
(frame 2) propagateThroughForall.chpl:5
(frame 3) propagateThroughForall.chpl:11
(frame 4) propagateThroughForall.chpl:17
(frame 3) propagateThroughForall.chpl:5
(frame 4) propagateThroughForall.chpl:11
(frame 5) propagateThroughForall.chpl:17
caught error: oops
stack trace:
(frame 1) propagateThroughForall.chpl:2
(frame 2) propagateThroughForall.chpl:7
uncaught TaskErrors: 1 errors: Error: oops
propagateThroughForall.chpl:5: thrown here
propagateThroughForall.chpl:5: called from here
propagateThroughForall.chpl:5: called from here
propagateThroughForall.chpl:11: called from here
propagateThroughForall.chpl:34: called from here
propagateThroughForall.chpl:34: uncaught here
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ uncaught Error: oops
propagateThroughIterator2.chpl:2: thrown here
propagateThroughIterator2.chpl:14: called from here
propagateThroughIterator2.chpl:14: called from here
propagateThroughIterator2.chpl:30: called from here
propagateThroughIterator2.chpl:30: uncaught here
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ uncaught Error: oops
propagateThroughIterator2.chpl:2: thrown here
propagateThroughIterator2.chpl:14: called from here
propagateThroughIterator2.chpl:14: called from here
propagateThroughIterator2.chpl:30: called from here
propagateThroughIterator2.chpl:30: uncaught here
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ uncaught Error: oops
propagateThroughParIterator.chpl:2: thrown here
propagateThroughParIterator.chpl:21: called from here
propagateThroughParIterator.chpl:21: called from here
propagateThroughParIterator.chpl:37: called from here
propagateThroughParIterator.chpl:37: uncaught here
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ uncaught Error: oops
propagateThroughParIterator.chpl:2: thrown here
propagateThroughParIterator.chpl:21: called from here
propagateThroughParIterator.chpl:21: called from here
propagateThroughParIterator.chpl:37: called from here
propagateThroughParIterator.chpl:37: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/stacktrace/stressTest.16.good
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ uncaught MyError: oops
stressTest.chpl:9: called from here
stressTest.chpl:9: called from here
stressTest.chpl:9: called from here
stressTest.chpl:17: called from here
stressTest.chpl:17: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/stacktrace/stressTest.256.good
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,5 @@ uncaught MyError: oops
stressTest.chpl:9: called from here
stressTest.chpl:9: called from here
stressTest.chpl:9: called from here
stressTest.chpl:17: called from here
stressTest.chpl:17: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/stacktrace/throwFromCoforall.1-0.good
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ uncaught TaskErrors: 1 errors: Error: oops
throwFromCoforall.chpl:2: called from here
throwFromCoforall.chpl:8: called from here
throwFromCoforall.chpl:11: called from here
throwFromCoforall.chpl:34: called from here
throwFromCoforall.chpl:34: uncaught here
1 change: 1 addition & 0 deletions test/errhandling/stacktrace/throwFromCoforall.2-0.good
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ uncaught TaskErrors: 1 errors: Error: oops
throwFromCoforall.chpl:2: called from here
throwFromCoforall.chpl:8: called from here
throwFromCoforall.chpl:11: called from here
throwFromCoforall.chpl:34: called from here
throwFromCoforall.chpl:34: uncaught here
2 changes: 2 additions & 0 deletions test/errhandling/stacktrace/throwFromForall.1-0.good
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
uncaught TaskErrors: 1 errors: Error: oops
throwFromForall.chpl:2: thrown here
throwFromForall.chpl:2: called from here
throwFromForall.chpl:2: called from here
throwFromForall.chpl:8: called from here
throwFromForall.chpl:11: called from here
throwFromForall.chpl:34: called from here
throwFromForall.chpl:34: uncaught here
Loading
Loading