-
Notifications
You must be signed in to change notification settings - Fork 261
feat: accept type arguments in function calls #923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6c32f2e
refactor: rename `expression_list_node::expressions` to `arguments`
JohelEGP 73f8b3d
refactor: rename `expression_list_node::term` to `expression_term`
JohelEGP 8f13c29
refactor: add `expression_list_node::type_id_term`
JohelEGP f6c399d
feat: accept type arguments in function calls
JohelEGP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,21 @@ | ||
#include <cstddef> | ||
main: () = { | ||
_ = alignof(int); | ||
_ = sizeof(int); | ||
_ = typeid(int); | ||
_ = offsetof(t, a); | ||
_ = :<T> (_: T) _ = sizeof(T::value);(std::true_type()); | ||
_ = :<T> (_: T) _ = sizeof(type T::value_type);(std::true_type()); | ||
_ = alignof(const int); | ||
_ = sizeof(const int); | ||
_ = typeid(const int); | ||
_ = alignof(*int); | ||
_ = sizeof(*int); | ||
_ = typeid(*int); | ||
} | ||
#if defined(_MSC_VER) || defined(__GNUC__) | ||
_: int == __builtin_bit_cast(const int, 0); | ||
#endif | ||
t: @struct type = { | ||
a: int; | ||
} |
This file contains hidden or 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
63 changes: 63 additions & 0 deletions
63
regression-tests/test-results/mixed-function-type-argument.cpp
This file contains hidden or 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,63 @@ | ||
|
||
|
||
//=== Cpp2 type declarations ==================================================== | ||
|
||
|
||
#include "cpp2util.h" | ||
|
||
#line 1 "mixed-function-type-argument.cpp2" | ||
|
||
#line 19 "mixed-function-type-argument.cpp2" | ||
class t; | ||
|
||
|
||
//=== Cpp2 type definitions and function declarations =========================== | ||
|
||
#line 1 "mixed-function-type-argument.cpp2" | ||
#include <cstddef> | ||
auto main() -> int; | ||
#line 16 "mixed-function-type-argument.cpp2" | ||
#if defined(_MSC_VER) || defined(__GNUC__) | ||
int inline constexpr _{ __builtin_bit_cast(int const, 0) }; | ||
#line 18 "mixed-function-type-argument.cpp2" | ||
#endif | ||
class t { | ||
public: int a; | ||
public: t(auto&& a_) | ||
CPP2_REQUIRES_ (std::is_convertible_v<CPP2_TYPEOF(a_), std::add_const_t<int>&>) ; | ||
|
||
public: auto operator=(auto&& a_) -> t& | ||
CPP2_REQUIRES_ (std::is_convertible_v<CPP2_TYPEOF(a_), std::add_const_t<int>&>) ; | ||
|
||
#line 21 "mixed-function-type-argument.cpp2" | ||
}; | ||
|
||
|
||
//=== Cpp2 function definitions ================================================= | ||
|
||
#line 1 "mixed-function-type-argument.cpp2" | ||
|
||
#line 2 "mixed-function-type-argument.cpp2" | ||
auto main() -> int{ | ||
static_cast<void>(alignof(int)); | ||
static_cast<void>(sizeof(int)); | ||
static_cast<void>(typeid(int)); | ||
static_cast<void>(offsetof(t, a)); | ||
static_cast<void>([]<typename T>([[maybe_unused]] T const& unnamed_param_1) -> auto { return static_cast<void>(sizeof(T::value)); }(std::true_type())); | ||
static_cast<void>([]<typename T>([[maybe_unused]] T const& unnamed_param_1) -> auto { return static_cast<void>(sizeof(typename T::value_type)); }(std::true_type())); | ||
static_cast<void>(alignof(int const)); | ||
static_cast<void>(sizeof(int const)); | ||
static_cast<void>(typeid(int const)); | ||
static_cast<void>(alignof(int*)); | ||
static_cast<void>(sizeof(int*)); | ||
static_cast<void>(typeid(int*)); | ||
} | ||
|
||
t::t(auto&& a_) | ||
requires (std::is_convertible_v<CPP2_TYPEOF(a_), std::add_const_t<int>&>) | ||
: a{ CPP2_FORWARD(a_) }{} | ||
|
||
auto t::operator=(auto&& a_) -> t& | ||
requires (std::is_convertible_v<CPP2_TYPEOF(a_), std::add_const_t<int>&>) { | ||
a = CPP2_FORWARD(a_); | ||
return *this;} |
2 changes: 2 additions & 0 deletions
2
regression-tests/test-results/mixed-function-type-argument.cpp2.output
This file contains hidden or 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 @@ | ||
mixed-function-type-argument.cpp2... ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks) | ||
|
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.