Author: cor3ntin Date: 2024-05-30T17:22:07+02:00 New Revision: 1ee02f9b6053617b741de542ee127c17c5a548be
URL: https://github.com/llvm/llvm-project/commit/1ee02f9b6053617b741de542ee127c17c5a548be DIFF: https://github.com/llvm/llvm-project/commit/1ee02f9b6053617b741de542ee127c17c5a548be.diff LOG: [Clang] Fix overloading for constrained variadic functions (#93817) Found by #93667 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaOverload.cpp clang/test/SemaTemplate/concepts.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 9dc93f53fe716..f0cdccfcc3c23 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -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 + diff erering by their constraints when only one of these function was variadic. Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 6c5e8afbcfb6e..6c4ce1022ae27 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -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( diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index 787cc809e2535..a4b42cad79abd 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -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(); +} + +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits