From: Richard Smith Date: Thu, 12 Jul 2018 18:49:13 +0000 (+0000) Subject: Add tests for function conversions in conversion function template X-Git-Tag: llvmorg-7.0.0-rc1~1588 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=746e35e8a13b35197f9ede1cf5b4e7629c18ff75;p=platform%2Fupstream%2Fllvm.git Add tests for function conversions in conversion function template deduction. llvm-svn: 336931 --- diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 5c3f2ca..8ae2213 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -1645,6 +1645,9 @@ DeduceTemplateArgumentsByTypeMatch(Sema &S, } } // 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; } 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 89478ed..085976b 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 @@ -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 using Function = T(U...) noexcept(Noexcept); + template struct ConvToFunction { + template operator Function&(); // expected-note {{candidate}} + }; + void (&fn1)(int) noexcept(false) = ConvToFunction(); + void (&fn2)(int) noexcept(true) = ConvToFunction(); // expected-error {{no viable}} + void (&fn3)(int) noexcept(false) = ConvToFunction(); + void (&fn4)(int) noexcept(true) = ConvToFunction(); + + struct ConvToFunctionDeducingNoexcept { + template operator Function&(); + }; + void (&fn5)(int) noexcept(false) = ConvToFunctionDeducingNoexcept(); + void (&fn6)(int) noexcept(true) = ConvToFunctionDeducingNoexcept(); +#endif }