Skip to content

Commit 57f5453

Browse files
committed
Add tests for function call inout passing style
1 parent eb5bf28 commit 57f5453

8 files changed

+43
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
f2: (inout x) -> _ = {
2+
return x * 2;
3+
}
4+
5+
main: () -> int = {
6+
x := 21;
7+
std::cout << f2(inout x) << std::endl;
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
42

regression-tests/test-results/apple-clang-14/pure2-inout-passing-style-call.cpp.output

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
42

regression-tests/test-results/clang-12/pure2-inout-passing-style-call.cpp.output

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
#define CPP2_USE_MODULES Yes
3+
4+
#include "cpp2util.h"
5+
6+
7+
#line 1 "pure2-inout-passing-style-call.cpp2"
8+
[[nodiscard]] auto f2(auto& x) -> auto;
9+
#line 5 "pure2-inout-passing-style-call.cpp2"
10+
[[nodiscard]] auto main() -> int;
11+
12+
//=== Cpp2 definitions ==========================================================
13+
14+
#line 1 "pure2-inout-passing-style-call.cpp2"
15+
[[nodiscard]] auto f2(auto& x) -> auto{
16+
return x * 2;
17+
}
18+
19+
[[nodiscard]] auto main() -> int{
20+
auto x {21};
21+
std::cout << f2( x) << std::endl;
22+
}
23+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
f2: (inout x) -> _ = {
2+
return x * 2;
3+
}
4+
5+
main: () -> int = {
6+
x := 21;
7+
std::cout << f2(inout x) << std::endl;
8+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pure2-inout-passing-style-call.cpp2... ok (all Cpp2, passes safety checks)
2+

0 commit comments

Comments
 (0)