Skip to content

Commit

Permalink
[clang][test] Add test for incompatible cv-qualified reference types …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
wdunicornpro committed Mar 6, 2024
1 parent 5cd45e4 commit f8c5a68
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ namespace non_ptr_ref_cv_qual {
int (&test_conv_to_arr_1)[3] = ConvToArr(); // ok
const int (&test_conv_to_arr_2)[3] = ConvToArr(); // ok, with qualification conversion

struct ConvToConstArr {
template <int N>
operator const Arr<int, N> &() { // expected-note {{candidate}}
static_assert(N == 3, "");
}
};
Arr<int, 3> &test_conv_to_const_arr_1 = ConvToConstArr(); // expected-error {{no viable}}
const Arr<int, 3> &test_conv_to_const_arr_2 = ConvToConstArr(); // ok

#if __cplusplus >= 201702L
template<bool Noexcept, typename T, typename ...U> using Function = T(U...) noexcept(Noexcept);
template<bool Noexcept> struct ConvToFunction {
Expand Down

0 comments on commit f8c5a68

Please sign in to comment.