forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak the implementation and run regressions
- Loading branch information
Showing
15 changed files
with
154 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
regression-tests/test-results/clang-12/pure2-return-tuple-operator.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
12 , 34 | ||
23 , 45 | ||
34 , 56 |
4 changes: 4 additions & 0 deletions
4
regression-tests/test-results/clang-12/pure2-return-tuple-operator.cpp.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pure2-return-tuple-operator.cpp2:13:52: warning: unused parameter 'idx' [-Wunused-parameter] | ||
[[nodiscard]] auto A::operator[](cpp2::in<int> idx) const& -> operator_subscript_ret{ | ||
^ | ||
1 warning generated. |
3 changes: 3 additions & 0 deletions
3
regression-tests/test-results/gcc-10/pure2-return-tuple-operator.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
12 , 34 | ||
23 , 45 | ||
34 , 56 |
2 changes: 2 additions & 0 deletions
2
regression-tests/test-results/gcc-10/pure2-return-tuple-operator.cpp.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pure2-return-tuple-operator.cpp2: In member function ‘A::operator_subscript_ret A::operator[](cpp2::in<int>) const &’: | ||
pure2-return-tuple-operator.cpp2:13:52: warning: unused parameter ‘idx’ [-Wunused-parameter] |
3 changes: 3 additions & 0 deletions
3
regression-tests/test-results/gcc-13/pure2-return-tuple-operator.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
12 , 34 | ||
23 , 45 | ||
34 , 56 |
2 changes: 2 additions & 0 deletions
2
regression-tests/test-results/gcc-13/pure2-return-tuple-operator.cpp.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pure2-return-tuple-operator.cpp2: In member function ‘A::operator_subscript_ret A::operator[](cpp2::in<int>) const &’: | ||
pure2-return-tuple-operator.cpp2:13:52: warning: unused parameter ‘idx’ [-Wunused-parameter] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
regression-tests/test-results/msvc-2022/pure2-return-tuple-operator.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
12 , 34 | ||
23 , 45 | ||
34 , 56 |
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/msvc-2022/pure2-return-tuple-operator.cpp.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pure2-return-tuple-operator.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
regression-tests/test-results/pure2-return-tuple-operator.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
|
||
#define CPP2_IMPORT_STD Yes | ||
|
||
//=== Cpp2 type declarations ==================================================== | ||
|
||
|
||
#include "cpp2util.h" | ||
|
||
#line 1 "pure2-return-tuple-operator.cpp2" | ||
|
||
#line 2 "pure2-return-tuple-operator.cpp2" | ||
class A; | ||
|
||
|
||
//=== Cpp2 type definitions and function declarations =========================== | ||
|
||
#line 1 "pure2-return-tuple-operator.cpp2" | ||
|
||
#line 2 "pure2-return-tuple-operator.cpp2" | ||
class A { | ||
struct operator_call_ret{ int x; int y; }; | ||
|
||
|
||
#line 3 "pure2-return-tuple-operator.cpp2" | ||
public: [[nodiscard]] auto operator()() const& -> operator_call_ret; | ||
struct operator_dereference_ret{ int x; int y; }; | ||
|
||
|
||
|
||
#line 8 "pure2-return-tuple-operator.cpp2" | ||
public: [[nodiscard]] auto operator*() const& -> operator_dereference_ret; | ||
struct operator_subscript_ret{ int x; int y; }; | ||
|
||
|
||
|
||
#line 13 "pure2-return-tuple-operator.cpp2" | ||
public: [[nodiscard]] auto operator[](cpp2::in<int> idx) const& -> operator_subscript_ret; | ||
public: A() = default; | ||
public: A(A const&) = delete; /* No 'that' constructor, suppress copy */ | ||
public: auto operator=(A const&) -> void = delete; | ||
|
||
|
||
#line 18 "pure2-return-tuple-operator.cpp2" | ||
}; | ||
|
||
#line 21 "pure2-return-tuple-operator.cpp2" | ||
auto main() -> int; | ||
|
||
//=== Cpp2 function definitions ================================================= | ||
|
||
#line 1 "pure2-return-tuple-operator.cpp2" | ||
|
||
#line 3 "pure2-return-tuple-operator.cpp2" | ||
[[nodiscard]] auto A::operator()() const& -> operator_call_ret{ | ||
cpp2::deferred_init<int> x; | ||
cpp2::deferred_init<int> y; | ||
#line 4 "pure2-return-tuple-operator.cpp2" | ||
x.construct(12); | ||
y.construct(34); | ||
return { std::move(x.value()), std::move(y.value()) }; | ||
} | ||
[[nodiscard]] auto A::operator*() const& -> operator_dereference_ret{ | ||
cpp2::deferred_init<int> x; | ||
cpp2::deferred_init<int> y; | ||
#line 9 "pure2-return-tuple-operator.cpp2" | ||
x.construct(23); | ||
y.construct(45); | ||
return { std::move(x.value()), std::move(y.value()) }; | ||
} | ||
[[nodiscard]] auto A::operator[](cpp2::in<int> idx) const& -> operator_subscript_ret{ | ||
cpp2::deferred_init<int> x; | ||
cpp2::deferred_init<int> y; | ||
#line 14 "pure2-return-tuple-operator.cpp2" | ||
x.construct(34); | ||
y.construct(56); | ||
return { std::move(x.value()), std::move(y.value()) }; | ||
} | ||
|
||
#line 21 "pure2-return-tuple-operator.cpp2" | ||
auto main() -> int{ | ||
|
||
A a {}; | ||
|
||
auto t1 {a()}; | ||
std::cout << t1.x << " , " << std::move(t1).y << "\n"; | ||
|
||
auto t2 {*cpp2::assert_not_null(a)}; | ||
std::cout << t2.x << " , " << std::move(t2).y << "\n"; | ||
|
||
auto t3 {CPP2_ASSERT_IN_BOUNDS(std::move(a), 0)}; | ||
std::cout << t3.x << " , " << std::move(t3).y << "\n"; | ||
|
||
} | ||
|
2 changes: 2 additions & 0 deletions
2
regression-tests/test-results/pure2-return-tuple-operator.cpp2.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pure2-return-tuple-operator.cpp2... ok (all Cpp2, passes safety checks) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters