r336931 - Add tests for function conversions in conversion function template
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 12 11:49:13 PDT 2018
Author: rsmith
Date: Thu Jul 12 11:49:13 2018
New Revision: 336931
URL: http://llvm.org/viewvc/llvm-project?rev=336931&view=rev
Log:
Add tests for function conversions in conversion function template
deduction.
Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=336931&r1=336930&r2=336931&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Jul 12 11:49:13 2018
@@ -1645,6 +1645,9 @@ DeduceTemplateArgumentsByTypeMatch(Sema
}
}
// FIXME: Detect non-deduced exception specification mismatches?
+ //
+ // Careful about [temp.deduct.call] and [temp.deduct.conv], which allow
+ // top-level differences in noexcept-specifications.
return Sema::TDK_Success;
}
Modified: cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp?rev=336931&r1=336930&r2=336931&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp Thu Jul 12 11:49:13 2018
@@ -129,4 +129,21 @@ 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
+
+#if __cplusplus >= 201702L
+ template<bool Noexcept, typename T, typename ...U> using Function = T(U...) noexcept(Noexcept);
+ template<bool Noexcept> struct ConvToFunction {
+ template <typename T, typename ...U> operator Function<Noexcept, T, U...>&(); // expected-note {{candidate}}
+ };
+ void (&fn1)(int) noexcept(false) = ConvToFunction<false>();
+ void (&fn2)(int) noexcept(true) = ConvToFunction<false>(); // expected-error {{no viable}}
+ void (&fn3)(int) noexcept(false) = ConvToFunction<true>();
+ void (&fn4)(int) noexcept(true) = ConvToFunction<true>();
+
+ struct ConvToFunctionDeducingNoexcept {
+ template <bool Noexcept, typename T, typename ...U> operator Function<Noexcept, T, U...>&();
+ };
+ void (&fn5)(int) noexcept(false) = ConvToFunctionDeducingNoexcept();
+ void (&fn6)(int) noexcept(true) = ConvToFunctionDeducingNoexcept();
+#endif
}
More information about the cfe-commits
mailing list