Skip to content

[Clang] Fix overloading for constrained variadic functions #93817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2024
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 @@ -816,6 +816,8 @@ Bug Fixes to C++ Support
- Fix incorrect merging of modules which contain using declarations which shadow
other declarations. This could manifest as ODR checker false positives.
Fixes (`#80252 <https://github.com/llvm/llvm-project/issues/80252>`_)
- Fix a regression introduced in Clang 18 causing incorrect overload resolution in the presence of functions only
differering by their constraints when only one of these function was variadic.

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
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 @@ -10367,7 +10367,7 @@ static bool sameFunctionParameterTypeLists(Sema &S,
FunctionDecl *Fn1 = Cand1.Function;
FunctionDecl *Fn2 = Cand2.Function;

if (Fn1->isVariadic() != Fn1->isVariadic())
if (Fn1->isVariadic() != Fn2->isVariadic())
return false;

if (!S.FunctionNonObjectParamTypesAreEqual(
Expand Down
22 changes: 22 additions & 0 deletions clang/test/SemaTemplate/concepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,3 +1122,25 @@ template <typename d> concept f = c< d >;
template <f> struct e; // expected-note {{}}
template <f d> struct e<d>; // expected-error {{class template partial specialization is not more specialized than the primary template}}
}


namespace constrained_variadic {
template <typename T = int>
struct S {
void f(); // expected-note {{candidate}}
void f(...) requires true; // expected-note {{candidate}}

void g(...); // expected-note {{candidate}}
void g() requires true; // expected-note {{candidate}}

consteval void h(...);
consteval void h(...) requires true {};
};

int test() {
S{}.f(); // expected-error{{call to member function 'f' is ambiguous}}
S{}.g(); // expected-error{{call to member function 'g' is ambiguous}}
S{}.h();
}

}
Loading