[clang] f8c5a68 - [clang][test] Add test for incompatible cv-qualified reference types in conversion function template (#81950)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 6 14:19:31 PST 2024
Author: Duo Wang
Date: 2024-03-06T14:19:27-08:00
New Revision: f8c5a68365fb82d9ffc64511f4b50b9c1e68144f
URL: https://github.com/llvm/llvm-project/commit/f8c5a68365fb82d9ffc64511f4b50b9c1e68144f
DIFF: https://github.com/llvm/llvm-project/commit/f8c5a68365fb82d9ffc64511f4b50b9c1e68144f.diff
LOG: [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.
Added:
Modified:
clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp
Removed:
################################################################################
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp
index 085976b081332b..974240c514846c 100644
--- a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp
@@ -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 {
More information about the cfe-commits
mailing list