Skip to content

Commit e929854

Browse files
committed
test: add unit tests for fixed UFCS corner cases
1 parent ad9708f commit e929854

25 files changed

+374
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
template<bool> struct t { };
2+
constexpr bool f(const t<true>&) { return true; }
3+
constexpr t<true> o{};
4+
5+
// Variables.
6+
7+
// _: <V: t<o.f()>> bool = (); // Blocked on #389, [GCC109781][].
8+
9+
// _: t<o.f()> = (); // Blocked on Clang 12 (lambda in unevaluated context).
10+
11+
_: bool = o.f();
12+
13+
// Functions.
14+
15+
// g: <V: t<o.f()>> () = { } // Blocked on [GCC109781][].
16+
17+
// g: (x: t<o.f()>) = { } // Blocked on Clang 12 (lambda in unevaluated context).
18+
19+
g: () [[pre: o.f()]] = { }
20+
21+
// h: () -> t<o.f()> = o; // Blocked on Clang 12 (lambda in unevaluated context).
22+
23+
// Aliases.
24+
25+
// a: <V: t<o.f()>> type == bool; // Blocked on [GCC109781][].
26+
27+
// b: <V: t<o.f()>> _ == false; // Blocked on [GCC109781][].
28+
29+
// c: type == t<o.f()>; // Blocked on Clang 12 (lambda in unevaluated context).
30+
31+
// d: _ == t<o.f()>(); // Blocked on Clang 12 (lambda in unevaluated context).
32+
33+
main: () = { }
34+
35+
// [GCC109781]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109781
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
print_res: (x: i32) -> i32 = {
2+
std::cout << x;
3+
if (x == 9) { std::cout << '\n'; }
4+
return x;
5+
}
6+
t: @struct type = {
7+
f: (inout this) -> i32 = print_res(0);
8+
f: (inout this, x) -> i32 = print_res(1);
9+
f: <T> (inout this) -> i32 = print_res(2);
10+
f: <T> (inout this, x) -> i32 = print_res(3);
11+
f: <T, U> (inout this, x, y) -> i32 = print_res(4);
12+
}
13+
f: (o: t) -> i32 = print_res(5);
14+
f: (o: t, x) -> i32 = print_res(6);
15+
f: <T> (o: t) -> i32 = print_res(7);
16+
f: <T> (o: t, x) -> i32 = print_res(8);
17+
f: <T, U> (o: t, x, y) -> i32 = print_res(9);
18+
m: t = ();
19+
n: const t = ();
20+
a: <T, U> _ == n;
21+
_: i32 = m.f();
22+
_: i32 = m.f(0);
23+
_: i32 = m.f<t>();
24+
_: i32 = m.f<t>(0);
25+
_: i32 = m.f<t, t>(0, 0);
26+
_: i32 = n.f();
27+
_: i32 = n.f(0);
28+
_: i32 = n.f<t>();
29+
_: i32 = n.f<t>(0);
30+
_: i32 = n.f<t, t>(0, 0);
31+
_: i32 = a<t, t>.f<t, t>(0, 0);
32+
main: () = {
33+
_: i32 = m.f();
34+
_: i32 = m.f(0);
35+
_: i32 = m.f<t>();
36+
_: i32 = m.f<t>(0);
37+
_: i32 = m.f<t, t>(0, 0);
38+
_: i32 = n.f();
39+
_: i32 = n.f(0);
40+
_: i32 = n.f<t>();
41+
_: i32 = n.f<t>(0);
42+
_: i32 = n.f<t, t>(0, 0);
43+
_: i32 = a<t, t>.f<t, t>(0, 0);
44+
45+
_ = :(a, f) = { _ = a.f(a).f(); };
46+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
t: type = {
2+
f: (this) -> i32 = 0;
3+
}
4+
main: () = {
5+
f := t().f();
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
t: type = {
2+
// swap: (inout this, that) = { } // Blocked on #508.
3+
}
4+
main: () = {
5+
// static_assert(noexcept(t().swap(t()))); // Blocked on Clang 12 (lambda in unevaluated context).
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// f: <T> () -> std::type_identity_t<decltype(T().a())> = { } // Blocked on Clang 12 (lambda in unevaluated context).
2+
B: type = { }
3+
main: () = {
4+
// static_assert(!std::invocable<decltype(:<T> (x: T) -> std::void_t<decltype(f<T>())> = {}), B>); // Blocked on Clang 12 (lambda in unevaluated context).
5+
}

regression-tests/test-results/clang-18/mixed-bugfix-for-ufcs-non-local.cpp.execution

Whitespace-only changes.

regression-tests/test-results/clang-18/mixed-bugfix-for-ufcs-non-local.cpp.output

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0123456789
2+
9
3+
0123456789
4+
9

regression-tests/test-results/clang-18/pure2-bugfix-for-ufcs-arguments.cpp.output

Whitespace-only changes.

regression-tests/test-results/clang-18/pure2-bugfix-for-ufcs-name-lookup.cpp.execution

Whitespace-only changes.

0 commit comments

Comments
 (0)