Skip to content

Commit

Permalink
fix(cpp1): emit correct UFCS in aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
JohelEGP committed Aug 7, 2023
1 parent eb1dd68 commit f9fbd75
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
10 changes: 10 additions & 0 deletions regression-tests/mixed-bugfix-for-ufcs-non-local.cpp2
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ g: () [[pre: o.f()]] = { }

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

// 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()>;

d: _ == t<o.f()>();

main: () = { }

// [GCC109781]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109781
11 changes: 11 additions & 0 deletions regression-tests/test-results/mixed-bugfix-for-ufcs-non-local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ auto g() -> void;

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

// Aliases.

// a: <V: t<o.f()>> type == bool; // Blocked on [GCC109781][].

// b: <V: t<o.f()>> _ == false; // Blocked on [GCC109781][].

using c = t<CPP2_UFCS(,,(f),(o),())>;

auto const& d = t<CPP2_UFCS(,,(f),(o),())>();

auto main() -> int;

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

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

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

7 changes: 4 additions & 3 deletions source/cppfront.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2950,6 +2950,7 @@ class cppfront
|| (
(
current_declarations.back()->is_object()
|| current_declarations.back()->is_alias()
|| (
current_declarations.back()->is_function()
&& current_declarations.back() == having_signature_emitted
Expand Down Expand Up @@ -4844,6 +4845,9 @@ class cppfront
};
auto stack = stack_value(having_signature_emitted, &n);

current_declarations.push_back(&n);
auto guard = finally([&]{ current_declarations.pop_back(); });

// Handle aliases

if (n.is_alias())
Expand Down Expand Up @@ -4957,9 +4961,6 @@ class cppfront
return;
}

current_declarations.push_back(&n);
auto guard = finally([&]{ current_declarations.pop_back(); });

// If this is a function that has multiple return values,
// first we need to emit the struct that contains the returns
if (
Expand Down

0 comments on commit f9fbd75

Please sign in to comment.