summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-07-12 18:49:13 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-07-12 18:49:13 +0000
commit746e35e8a13b35197f9ede1cf5b4e7629c18ff75 (patch)
tree008a0376d37a248bcacb7149110de8316d72172c
parentb6d5c5871857f101cd88e99d115b310abf565bba (diff)
downloadbcm5719-llvm-746e35e8a13b35197f9ede1cf5b4e7629c18ff75.tar.gz
bcm5719-llvm-746e35e8a13b35197f9ede1cf5b4e7629c18ff75.zip
Add tests for function conversions in conversion function template
deduction. llvm-svn: 336931
-rw-r--r--clang/lib/Sema/SemaTemplateDeduction.cpp3
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp17
2 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 5c3f2ca32ce..8ae22136e1e 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 89478ed39f6..085976b0813 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<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
}
OpenPOWER on IntegriCloud