https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/93817
Found by #93667 >From cee8bbd3c1e1a642622da0eaa26886ad9ce14c3c Mon Sep 17 00:00:00 2001 From: Corentin Jabot <corentinja...@gmail.com> Date: Thu, 30 May 2024 14:26:27 +0200 Subject: [PATCH] [Clang] Fix overloading for constrained variadic functions Found by #93667 --- clang/docs/ReleaseNotes.rst | 2 ++ clang/lib/Sema/SemaOverload.cpp | 2 +- clang/test/SemaTemplate/concepts.cpp | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) 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 + differering 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