Skip to content

Commit 1ee02f9

Browse files
authored
[Clang] Fix overloading for constrained variadic functions (#93817)
Found by #93667
1 parent 647d272 commit 1ee02f9

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,8 @@ Bug Fixes to C++ Support
816816
- Fix incorrect merging of modules which contain using declarations which shadow
817817
other declarations. This could manifest as ODR checker false positives.
818818
Fixes (`#80252 <https://github.com/llvm/llvm-project/issues/80252>`_)
819+
- Fix a regression introduced in Clang 18 causing incorrect overload resolution in the presence of functions only
820+
differering by their constraints when only one of these function was variadic.
819821

820822
Bug Fixes to AST Handling
821823
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaOverload.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10367,7 +10367,7 @@ static bool sameFunctionParameterTypeLists(Sema &S,
1036710367
FunctionDecl *Fn1 = Cand1.Function;
1036810368
FunctionDecl *Fn2 = Cand2.Function;
1036910369

10370-
if (Fn1->isVariadic() != Fn1->isVariadic())
10370+
if (Fn1->isVariadic() != Fn2->isVariadic())
1037110371
return false;
1037210372

1037310373
if (!S.FunctionNonObjectParamTypesAreEqual(

clang/test/SemaTemplate/concepts.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,3 +1122,25 @@ template <typename d> concept f = c< d >;
11221122
template <f> struct e; // expected-note {{}}
11231123
template <f d> struct e<d>; // expected-error {{class template partial specialization is not more specialized than the primary template}}
11241124
}
1125+
1126+
1127+
namespace constrained_variadic {
1128+
template <typename T = int>
1129+
struct S {
1130+
void f(); // expected-note {{candidate}}
1131+
void f(...) requires true; // expected-note {{candidate}}
1132+
1133+
void g(...); // expected-note {{candidate}}
1134+
void g() requires true; // expected-note {{candidate}}
1135+
1136+
consteval void h(...);
1137+
consteval void h(...) requires true {};
1138+
};
1139+
1140+
int test() {
1141+
S{}.f(); // expected-error{{call to member function 'f' is ambiguous}}
1142+
S{}.g(); // expected-error{{call to member function 'g' is ambiguous}}
1143+
S{}.h();
1144+
}
1145+
1146+
}

0 commit comments

Comments
 (0)