Skip to content

Commit f9fbd75

Browse files
committed
fix(cpp1): emit correct UFCS in aliases
1 parent eb1dd68 commit f9fbd75

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

regression-tests/mixed-bugfix-for-ufcs-non-local.cpp2

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ g: () [[pre: o.f()]] = { }
2020

2121
h: () -> t<o.f()> = o;
2222

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()>;
30+
31+
d: _ == t<o.f()>();
32+
2333
main: () = { }
2434

2535
// [GCC109781]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109781

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

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ auto g() -> void;
3232

3333
[[nodiscard]] auto h() -> t<CPP2_UFCS(,,(f),(o),())>;
3434

35+
// Aliases.
36+
37+
// a: <V: t<o.f()>> type == bool; // Blocked on [GCC109781][].
38+
39+
// b: <V: t<o.f()>> _ == false; // Blocked on [GCC109781][].
40+
41+
using c = t<CPP2_UFCS(,,(f),(o),())>;
42+
43+
auto const& d = t<CPP2_UFCS(,,(f),(o),())>();
44+
3545
auto main() -> int;
3646

3747
// [GCC109781]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109781
@@ -55,5 +65,6 @@ auto g() -> void{
5565

5666
[[nodiscard]] auto h() -> t<CPP2_UFCS(,,(f),(o),())> { return o; }
5767

68+
#line 33 "mixed-bugfix-for-ufcs-non-local.cpp2"
5869
auto main() -> int{}
5970

source/cppfront.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -2950,6 +2950,7 @@ class cppfront
29502950
|| (
29512951
(
29522952
current_declarations.back()->is_object()
2953+
|| current_declarations.back()->is_alias()
29532954
|| (
29542955
current_declarations.back()->is_function()
29552956
&& current_declarations.back() == having_signature_emitted
@@ -4844,6 +4845,9 @@ class cppfront
48444845
};
48454846
auto stack = stack_value(having_signature_emitted, &n);
48464847

4848+
current_declarations.push_back(&n);
4849+
auto guard = finally([&]{ current_declarations.pop_back(); });
4850+
48474851
// Handle aliases
48484852

48494853
if (n.is_alias())
@@ -4957,9 +4961,6 @@ class cppfront
49574961
return;
49584962
}
49594963

4960-
current_declarations.push_back(&n);
4961-
auto guard = finally([&]{ current_declarations.pop_back(); });
4962-
49634964
// If this is a function that has multiple return values,
49644965
// first we need to emit the struct that contains the returns
49654966
if (

0 commit comments

Comments
 (0)