Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ C++ Language Changes

C++20 Feature Support
^^^^^^^^^^^^^^^^^^^^^
- Fix a bug in conversion sequence of arguments to a function with reversed parameter order.
Fixes `GH <https://github.com/llvm/llvm-project/issues/53954>`_.

C++23 Feature Support
^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7688,7 +7688,7 @@ bool Sema::CheckNonDependentConversions(
QualType ParamType = ParamTypes[I + Offset];
if (!ParamType->isDependentType()) {
unsigned ConvIdx = PO == OverloadCandidateParamOrder::Reversed
? 0
? Args.size() - 1 - (ThisConversions + I)
: (ThisConversions + I);
Conversions[ConvIdx]
= TryCopyInitialization(*this, Args[I], ParamType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,41 @@ bool x = X() == X(); // expected-warning {{ambiguous}}
}
} // namespace P2468R2

namespace GH53954{
namespace test1 {
struct P {
template <class T>
friend bool operator==(const P&, const T&); // expected-note {{candidate}} \
// expected-note {{reversed parameter order}}
};
struct A : public P {};
struct B : public P {};
bool check(A a, B b) { return a == b; } // expected-error {{ '==' is ambiguous}}
}

namespace test2 {
struct P {
template <class T>
friend bool operator==(const T&, const P&); // expected-note {{candidate}} \
// expected-note {{reversed parameter order}}
};
struct A : public P {};
struct B : public P {};
bool check(A a, B b) { return a == b; } // expected-error {{ '==' is ambiguous}}
}

namespace test3 {
struct P {
template<class S>
bool operator==(const S &) const; // expected-note {{candidate}} \
// expected-note {{reversed parameter order}}
};
struct A : public P {};
struct B : public P {};
bool check(A a, B b) { return a == b; } // expected-error {{ '==' is ambiguous}}
}
}

#else // NO_ERRORS

namespace problem_cases {
Expand Down