summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2019-12-04 18:53:34 -0800
committerRichard Smith <richard@metafoo.co.uk>2019-12-04 18:55:24 -0800
commit11d10527852b4d3ed738aa90d8bec0f398160593 (patch)
treed1e0f889396a53c0ec944115941fad265397acf5 /clang/test
parenta1d2611c046efa46cf32a10c9e9a8a7a8a06feba (diff)
downloadbcm5719-llvm-11d10527852b4d3ed738aa90d8bec0f398160593.tar.gz
bcm5719-llvm-11d10527852b4d3ed738aa90d8bec0f398160593.zip
Properly convert all declaration non-type template arguments when
forming non-type template parameter values.
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/exceptions-seh.cpp7
-rw-r--r--clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp32
2 files changed, 35 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/exceptions-seh.cpp b/clang/test/SemaCXX/exceptions-seh.cpp
index 1d8cc4917e9..02bb786160d 100644
--- a/clang/test/SemaCXX/exceptions-seh.cpp
+++ b/clang/test/SemaCXX/exceptions-seh.cpp
@@ -39,14 +39,13 @@ void instantiate_bad_scope_tmpl() {
}
#if __cplusplus < 201103L
-// FIXME: Diagnose this case. For now we produce undef in codegen.
template <typename T, T FN()>
T func_template() {
- return FN();
+ return FN(); // expected-error 2{{builtin functions must be directly called}}
}
void inject_builtins() {
- func_template<void *, __exception_info>();
- func_template<unsigned long, __exception_code>();
+ func_template<void *, __exception_info>(); // expected-note {{instantiation of}}
+ func_template<unsigned long, __exception_code>(); // expected-note {{instantiation of}}
}
#endif
diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
index 7a58dd5dcae..7232598215a 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -394,6 +394,21 @@ namespace PR42362 {
Z<f, f, f>::Q q;
}
+namespace QualConv {
+ int *X;
+ template<const int *const *P> void f() {
+ using T = decltype(P);
+ using T = const int* const*;
+ }
+ template void f<&X>();
+
+ template<const int *const &R> void g() {
+ using T = decltype(R);
+ using T = const int *const &;
+ }
+ template void g<(const int *const&)X>();
+}
+
namespace FunctionConversion {
struct a { void c(char *) noexcept; };
template<void (a::*f)(char*)> void g() {
@@ -401,4 +416,21 @@ namespace FunctionConversion {
using T = void (a::*)(char*); // (not 'noexcept')
}
template void g<&a::c>();
+
+ void c() noexcept;
+ template<void (*p)()> void h() {
+ using T = decltype(p);
+ using T = void (*)(); // (not 'noexcept')
+ }
+ template void h<&c>();
+}
+
+namespace VoidPtr {
+ // Note, this is an extension in C++17 but valid in C++20.
+ template<void *P> void f() {
+ using T = decltype(P);
+ using T = void*;
+ }
+ int n;
+ template void f<(void*)&n>();
}
OpenPOWER on IntegriCloud