Title: [Clang] UFCS on shared identifier between types in non-this member function.
Description:
The type of this and the unrelated type share f.
In a non-this member function,
UFCS on f with the unrelated type breaks Clang.
GCC and MSVC work, so it may be a Clang bug: https://compiler-explorer.com/z/vEEovohd3.
Minimal reproducer (https://cpp2.godbolt.org/z/qWjx6Pav7):
t: type = {
f: (this) = { }
}
u: type = {
f: (this) = { }
g: (inout self: u) = {
a: t = ();
a.f();
}
}
main: () = { }
Commands:
cppfront main.cpp2
clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cpp
Expected result: A working program.
Actual result and error:
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
class t;
class u;
//=== Cpp2 type definitions and function declarations ===========================
class t {
public: auto f() const -> void;
public: t() = default;
public: t(t const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(t const&) -> void = delete;
};
class u {
public: auto f() const -> void;
public: static auto g(u& self) -> void;
public: u() = default;
public: u(u const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(u const&) -> void = delete;
};
auto main() -> int;
//=== Cpp2 function definitions =================================================
auto t::f() const -> void{}
auto u::f() const -> void{}
auto u::g(u& self) -> void{
t a {};
CPP2_UFCS_0(f, std::move(a));
}
auto main() -> int{}
Output:
main.cpp2:8:17: error: call to non-static member function without an object argument
8 | CPP2_UFCS_0(f, std::move(a));
| ^
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:727:16: note: expanded from macro 'CPP2_UFCS_0'
727 | return FUNCNAME(CPP2_FORWARD(obj)); \
| ^~~~~~~~
1 error generated.
Title: [Clang] UFCS on shared identifier between types in non-
thismember function.Description:
The type of
thisand the unrelated type sharef.In a non-
thismember function,UFCS on
fwith the unrelated type breaks Clang.GCC and MSVC work, so it may be a Clang bug: https://compiler-explorer.com/z/vEEovohd3.
Minimal reproducer (https://cpp2.godbolt.org/z/qWjx6Pav7):
Commands:
cppfront main.cpp2 clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cppExpected result: A working program.
Actual result and error:
Cpp2 lowered to Cpp1: