Skip to content

Commit

Permalink
[Clang] Fix overloading for constrained variadic functions (llvm#93817)
Browse files Browse the repository at this point in the history
Found by llvm#93667
  • Loading branch information
cor3ntin authored May 30, 2024
1 parent 647d272 commit 1ee02f9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
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();
}

}

0 comments on commit 1ee02f9

Please sign in to comment.