-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cpp1): handle known UFCS corner cases
Provide transparent SFINAE. Forward `noexcept`. Accept object with unparenthesized comma like `v<a, b>`. Incidentially, merge the UFCS macros.
- Loading branch information
Showing
65 changed files
with
666 additions
and
363 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
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,35 @@ | ||
template<bool> struct t { }; | ||
constexpr bool f(const t<true>&) { return true; } | ||
constexpr t<true> o{}; | ||
|
||
// Variables. | ||
|
||
// _: <V: t<o.f()>> bool = (); // Blocked on #389, [GCC109781][]. | ||
|
||
// _: t<o.f()> = (); // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
_: bool = o.f(); | ||
|
||
// Functions. | ||
|
||
// g: <V: t<o.f()>> () = { } // Blocked on [GCC109781][]. | ||
|
||
// g: (x: t<o.f()>) = { } // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
g: () [[pre: o.f()]] = { } | ||
|
||
// h: () -> t<o.f()> = o; // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
// Aliases. | ||
|
||
// a: <V: t<o.f()>> type == bool; // Blocked on [GCC109781][]. | ||
|
||
// b: <V: t<o.f()>> _ == false; // Blocked on [GCC109781][]. | ||
|
||
// c: type == t<o.f()>; // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
// d: _ == t<o.f()>(); // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
main: () = { } | ||
|
||
// [GCC109781]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109781 |
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,46 @@ | ||
print_res: (x: i32) -> i32 = { | ||
std::cout << x; | ||
if (x == 9) { std::cout << '\n'; } | ||
return x; | ||
} | ||
t: type = { | ||
f: (inout this) -> i32 = print_res(0); | ||
f: (inout this, x) -> i32 = print_res(1); | ||
f: <T> (inout this) -> i32 = print_res(2); | ||
f: <T> (inout this, x) -> i32 = print_res(3); | ||
f: <T, U> (inout this, x, y) -> i32 = print_res(4); | ||
} | ||
f: (o: t) -> i32 = print_res(5); | ||
f: (o: t, x) -> i32 = print_res(6); | ||
f: <T> (o: t) -> i32 = print_res(7); | ||
f: <T> (o: t, x) -> i32 = print_res(8); | ||
f: <T, U> (o: t, x, y) -> i32 = print_res(9); | ||
m: t = (); | ||
n: const t = (); | ||
a: <T, U> _ == n; | ||
_: i32 = m.f(); | ||
_: i32 = m.f(0); | ||
_: i32 = m.f<t>(); | ||
_: i32 = m.f<t>(0); | ||
_: i32 = m.f<t, t>(0, 0); | ||
_: i32 = n.f(); | ||
_: i32 = n.f(0); | ||
_: i32 = n.f<t>(); | ||
_: i32 = n.f<t>(0); | ||
_: i32 = n.f<t, t>(0, 0); | ||
_: i32 = a<t, t>.f<t, t>(0, 0); | ||
main: () = { | ||
_: i32 = m.f(); | ||
_: i32 = m.f(0); | ||
_: i32 = m.f<t>(); | ||
_: i32 = m.f<t>(0); | ||
_: i32 = m.f<t, t>(0, 0); | ||
_: i32 = n.f(); | ||
_: i32 = n.f(0); | ||
_: i32 = n.f<t>(); | ||
_: i32 = n.f<t>(0); | ||
_: i32 = n.f<t, t>(0, 0); | ||
_: i32 = a<t, t>.f<t, t>(0, 0); | ||
|
||
_ = :(a, f) = { _ = a.f(a).f(); }; | ||
} |
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,6 @@ | ||
t: type = { | ||
swap: (inout this, that) = { } | ||
} | ||
main: () = { | ||
// static_assert(noexcept(t().swap(t()))); // Blocked on Clang 12 (lambda in unevaluated context). | ||
} |
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,5 @@ | ||
// f: <T> () -> std::type_identity_t<decltype(T().a())> = { } // Blocked on Clang 12 (lambda in unevaluated context). | ||
B: type = { } | ||
main: () = { | ||
// static_assert(!std::invocable<decltype(:<T> (x: T) -> std::void_t<decltype(f<T>())> = {}), B>); // Blocked on Clang 12 (lambda in unevaluated context). | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
clang version 18.0.0 (https://git.uplinklabs.net/mirrors/llvm-project.git c0abd3814564a568dfc607c216e6407eaa314f46) | ||
clang version 18.0.0 (https://github.com/llvm/llvm-project.git c0abd3814564a568dfc607c216e6407eaa314f46) | ||
Target: x86_64-pc-linux-gnu | ||
Thread model: posix | ||
InstalledDir: /home/johel/root/clang-main/bin |
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions
4
regression-tests/test-results/clang-18/pure2-bugfix-for-ufcs-arguments.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,4 @@ | ||
0123456789 | ||
9 | ||
0123456789 | ||
9 |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions
4
regression-tests/test-results/gcc-13/pure2-bugfix-for-ufcs-arguments.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,4 @@ | ||
0123456789 | ||
9 | ||
0123456789 | ||
9 |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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
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
64 changes: 64 additions & 0 deletions
64
regression-tests/test-results/mixed-bugfix-for-ufcs-non-local.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,64 @@ | ||
|
||
|
||
//=== Cpp2 type declarations ==================================================== | ||
|
||
|
||
#include "cpp2util.h" | ||
|
||
|
||
|
||
//=== Cpp2 type definitions and function declarations =========================== | ||
|
||
template<bool> struct t { }; | ||
constexpr bool f(const t<true>&) { return true; } | ||
constexpr t<true> o{}; | ||
|
||
// Variables. | ||
|
||
// _: <V: t<o.f()>> bool = (); // Blocked on #389, [GCC109781][]. | ||
|
||
// _: t<o.f()> = (); // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
#line 11 "mixed-bugfix-for-ufcs-non-local.cpp2" | ||
extern bool auto_11_1; | ||
|
||
// Functions. | ||
|
||
// g: <V: t<o.f()>> () = { } // Blocked on [GCC109781][]. | ||
|
||
// g: (x: t<o.f()>) = { } // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
auto g() -> void; | ||
|
||
// h: () -> t<o.f()> = o; // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
// Aliases. | ||
|
||
// a: <V: t<o.f()>> type == bool; // Blocked on [GCC109781][]. | ||
|
||
// b: <V: t<o.f()>> _ == false; // Blocked on [GCC109781][]. | ||
|
||
// c: type == t<o.f()>; // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
// d: _ == t<o.f()>(); // Blocked on Clang 12 (lambda in unevaluated context). | ||
|
||
auto main() -> int; | ||
|
||
// [GCC109781]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109781 | ||
|
||
|
||
//=== Cpp2 function definitions ================================================= | ||
|
||
|
||
#line 11 "mixed-bugfix-for-ufcs-non-local.cpp2" | ||
bool auto_11_1 {CPP2_UFCS_NONLOCAL(f)(o)}; | ||
|
||
#line 19 "mixed-bugfix-for-ufcs-non-local.cpp2" | ||
auto g() -> void{ | ||
cpp2::Default.expects(CPP2_UFCS(f)(o), ""); | ||
#line 19 "mixed-bugfix-for-ufcs-non-local.cpp2" | ||
} | ||
|
||
#line 33 "mixed-bugfix-for-ufcs-non-local.cpp2" | ||
auto main() -> int{} | ||
|
2 changes: 2 additions & 0 deletions
2
regression-tests/test-results/mixed-bugfix-for-ufcs-non-local.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 @@ | ||
mixed-bugfix-for-ufcs-non-local.cpp2... ok (mixed Cpp1/Cpp2, Cpp2 code 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
Oops, something went wrong.