Skip to content

Commit 6393e2b

Browse files
Merge pull request #47 from NinaRanns/contract_wrapper_thunk_fix
thunk thinko
2 parents 7692d13 + 69eaea2 commit 6393e2b

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

gcc/cp/contracts.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3191,7 +3191,6 @@ maybe_contract_wrap_call (tree fndecl, tree call)
31913191

31923192
tree wrapcall = build_call_expr_loc_vec(DECL_SOURCE_LOCATION (wrapdecl), wrapdecl, argwrap);
31933193

3194-
CALL_FROM_THUNK_P (wrapcall) = true;
31953194
return wrapcall;
31963195
}
31973196

@@ -3233,6 +3232,9 @@ bool define_contract_wrapper_func(const tree& fndecl, const tree& wrapdecl, void
32333232
args->length (),
32343233
args->address ());
32353234

3235+
3236+
CALL_FROM_THUNK_P (call) = true;
3237+
32363238
finish_return_stmt (call);
32373239

32383240
finish_compound_stmt (compound_stmt);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// { dg-do compile }
2+
// { dg-options "-std=c++2a -fcontracts -fcontracts-nonattr -fcontract-evaluation-semantic=observe -fcontracts-nonattr-client-contracts=all" }
3+
4+
5+
struct S{
6+
S(){};
7+
S(const S&){}
8+
~S(){};
9+
int x = 0;
10+
};
11+
12+
void f(S s) pre(s.x == 1 ) {};
13+
14+
int main()
15+
{
16+
S s;
17+
f(s);
18+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Test that non trivial types work ok with a contract wrapper for virtual
2+
// functions.
3+
// { dg-do compile }
4+
// { dg-options "-std=c++2a -fcontracts -fcontract-continuation-mode=on -fcontracts-nonattr -g3" }
5+
6+
struct NonTrivial{
7+
NonTrivial(){};
8+
NonTrivial(const NonTrivial&){}
9+
~NonTrivial(){};
10+
int x = 0;
11+
};
12+
13+
struct S
14+
{
15+
16+
virtual void f(const NonTrivial s) post(s.x >1 ) {};
17+
18+
};
19+
20+
int main()
21+
{
22+
NonTrivial nt;
23+
S s;
24+
s.f(nt);
25+
}

0 commit comments

Comments
 (0)