Skip to content

Commit f8c5a68

Browse files
authored
[clang][test] Add test for incompatible cv-qualified reference types in conversion function template (#81950)
We currently lack test coverage for [SemaTemplateDeduction.cpp#L1619-L1620](https://github.com/llvm/llvm-project/blob/fe20a75/clang/lib/Sema/SemaTemplateDeduction.cpp#L1619-L1620), which handles the case where both the P type and the A type are reference types but A is more cv-qualified than P. This is deemed non-deduced unless both A and P are possibly cv-qualified forms of the template parameter T. This PR adds tests for that logic.
1 parent 5cd45e4 commit f8c5a68

File tree

1 file changed

+9
-0
lines changed
  • clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv

1 file changed

+9
-0
lines changed

clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ namespace non_ptr_ref_cv_qual {
130130
int (&test_conv_to_arr_1)[3] = ConvToArr(); // ok
131131
const int (&test_conv_to_arr_2)[3] = ConvToArr(); // ok, with qualification conversion
132132

133+
struct ConvToConstArr {
134+
template <int N>
135+
operator const Arr<int, N> &() { // expected-note {{candidate}}
136+
static_assert(N == 3, "");
137+
}
138+
};
139+
Arr<int, 3> &test_conv_to_const_arr_1 = ConvToConstArr(); // expected-error {{no viable}}
140+
const Arr<int, 3> &test_conv_to_const_arr_2 = ConvToConstArr(); // ok
141+
133142
#if __cplusplus >= 201702L
134143
template<bool Noexcept, typename T, typename ...U> using Function = T(U...) noexcept(Noexcept);
135144
template<bool Noexcept> struct ConvToFunction {

0 commit comments

Comments
 (0)