@@ -7,6 +7,7 @@ module CPP-EXECUTION-STMT-TRY
77 imports CPP-CONVERSION-SYNTAX
88 imports CPP-DYNAMIC-SYNTAX
99 imports CPP-EXECUTION-ENV-SYNTAX
10+ imports CPP-EXECUTION-STMT-BLOCK-SYNTAX
1011 imports CPP-EXECUTION-TEMPORARY-SYNTAX
1112 imports CPP-ERROR-SYNTAX
1213 imports CPP-SETTINGS-SYNTAX
@@ -25,14 +26,21 @@ module CPP-EXECUTION-STMT-TRY
2526 rule <k> ThrowOp(V:LVal) => throw(V) ...</k>
2627 <uncaught-exception> _ => true </uncaught-exception>
2728
29+ rule <k> (.K => destructLocal(true, LCE)) ~> throw(V::LVal) ...</k>
30+ <catch-handlers> .List </catch-handlers>
31+ <ret-constructed-temporary> lcentry(...) #as LCE::KItem => .K </ret-constructed-temporary>
32+ requires canUnwindStack(V)
33+
2834 rule <k> (.K => destructTemporaries(true)) ~> throw(V::LVal) ...</k>
2935 <catch-handlers> .List </catch-handlers>
36+ <ret-constructed-temporary> .K </ret-constructed-temporary>
3037 <constructed-temporaries> ListItem(_) _ </constructed-temporaries>
3138 requires canUnwindStack(V)
3239
3340 // if there are still blocks in this function, pop them
3441 rule <k> (.K => popBlock(true)) ~> throw(V::LVal) ...</k>
3542 <catch-handlers> .List </catch-handlers>
43+ <ret-constructed-temporary> .K </ret-constructed-temporary>
3644 <constructed-temporaries> .List </constructed-temporaries>
3745 <block-stack> ListItem(_) _ </block-stack>
3846 <block-history> ListItem(Num::Int) ...</block-history>
@@ -43,6 +51,7 @@ module CPP-EXECUTION-STMT-TRY
4351 // if we are at the root of a loop, pop it before popping further blocks
4452 rule <k> throw(V::LVal) ~> (_ => K) </k>
4553 <catch-handlers> .List </catch-handlers>
54+ <ret-constructed-temporary> .K </ret-constructed-temporary>
4655 <constructed-temporaries> .List </constructed-temporaries>
4756 <block-stack> ListItem(_) _ </block-stack>
4857 <block-history> ListItem(Num::Int) ...</block-history>
@@ -52,6 +61,7 @@ module CPP-EXECUTION-STMT-TRY
5261 // if there are still functions in the stack trace, pop them
5362 rule <k> (.K => unwindFunction) ~> throw(V::LVal) ...</k>
5463 <catch-handlers> .List </catch-handlers>
64+ <ret-constructed-temporary> .K </ret-constructed-temporary>
5565 <constructed-temporaries> .List </constructed-temporaries>
5666 <block-stack> .List </block-stack>
5767 <call-stack> ListItem(_) _ </call-stack>
@@ -161,7 +171,8 @@ module CPP-EXECUTION-STMT-TRY
161171
162172 rule <k> catchWithHandler(CatchOp(_, pushBlock(N::Int) ~> declareNonStaticObjectExec(... id: X::CId) #as D:KItem ~> Rest:K), V::LVal)
163173 ~> tryMark(I::Int)
164- => popBlock(true)
174+ => destructTemporaries(true)
175+ ~> popBlock(true)
165176 ~> pushBlock(N)
166177 ~> setCurrentException(V)
167178 ~> #if X ==K #NoName #then .K #else D #fi
0 commit comments