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
3 changes: 2 additions & 1 deletion semantics/common/execution/thread_local.k
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module COMMON-THREAD-LOCAL
<this> .K </this>
// object being constructed
<constructing> .K </constructing>
<constructing-history> .List </constructing-history>
// most derived class being constructed
<most-derived-class> .K </most-derived-class>

Expand Down Expand Up @@ -82,7 +83,6 @@ module COMMON-THREAD-LOCAL
// used to store the catch handlers if this
// block is a try block in C++
<catch-handlers> .List </catch-handlers>
<current-exception> .K </current-exception>
</block-control>

// used to control initialization when gotoing
Expand All @@ -99,6 +99,7 @@ module COMMON-THREAD-LOCAL
// Used to catch potential stack size overflows.
<stack-depth> 0 </stack-depth>

<current-exception> .K </current-exception>
<uncaught-exception> false </uncaught-exception>

// stdarg
Expand Down
14 changes: 11 additions & 3 deletions semantics/cpp/language/execution/binding.k
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,19 @@ module CPP-EXECUTION-BINDING
<this> _ => Obj </this>

rule <k> beginConstruction(Obj:LVal, IsBaseClassSubobject:Bool) => Obj ...</k>
<constructing> _ => Obj </constructing>
<most-derived-class> MostDerived:K => #if IsBaseClassSubobject #then MostDerived #else type(Obj) #fi </most-derived-class>
<constructing> Old::K => Obj </constructing>
<constructing-history>
.List => ListItem(<constructing>Old</constructing>)
...</constructing-history>
<most-derived-class>
MostDerived:K => #if IsBaseClassSubobject #then MostDerived #else type(Obj) #fi
</most-derived-class>

rule <k> endConstruction(Obj:LVal, IsConstructor::Bool) => finishConstruction(Obj, IsConstructor) ...</k>
<constructing> _ => .K </constructing>
<constructing> _ => Old </constructing>
<constructing-history>
ListItem(<constructing> Old::K </constructing>) => .List
...</constructing-history>

rule <k> finishConstruction(Obj:LVal, IsConstructor:Bool) => Obj ...</k>
<locally-constructed> .List =>
Expand Down
5 changes: 3 additions & 2 deletions semantics/cpp/language/execution/stmt/try.k
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ module CPP-EXECUTION-STMT-TRY
rule <k> activateHandler => .K ...</k>
<uncaught-exception> _ => false </uncaught-exception>

rule <k> deactivateHandler => .K ...</k>
<current-exception> _ => .K </current-exception>
// @ref n4296 15.1/4
rule <k> deactivateHandler => destructLocal(false, lcentry(V, true, true, false)) ...</k>
<current-exception> V::LVal => .K </current-exception>

rule tryMark(_) => .K

Expand Down
18 changes: 18 additions & 0 deletions tests/unit-pass/copy-construction.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
struct E {
E(){}
~E(){}
E(E const &){}
int x;
};

E foo() {
return E();
//return {};
}

int main() {
foo();
//E(E());
E e = E();
try { throw E(); } catch(...){}
}
15 changes: 15 additions & 0 deletions tests/unit-pass/destruct-thrown.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extern "C" int puts(char const *);

struct E {
int x = 0;
E(){puts("E()");}
~E(){puts("~E()");}
E(E const &){puts("E(E const &)");}
};

int main() {
try {
throw E();
} catch(E const &e) {}
puts("---");
}