diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCXX/exceptions-seh.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/warn-bool-conversion.cpp | 24 | ||||
-rw-r--r-- | clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp | 32 |
3 files changed, 57 insertions, 6 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/SemaCXX/warn-bool-conversion.cpp b/clang/test/SemaCXX/warn-bool-conversion.cpp index ab563aa6898..6eca171f254 100644 --- a/clang/test/SemaCXX/warn-bool-conversion.cpp +++ b/clang/test/SemaCXX/warn-bool-conversion.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,expected-cxx11 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,expected-cxx11 -std=c++11 %s namespace BooleanFalse { int* j = false; @@ -192,3 +192,23 @@ namespace macros { // expected-warning@-1{{address of 'x' will always evaluate to 'true'}} } } + +namespace Template { + // FIXME: These cases should not warn. + template<int *p> void f() { if (p) {} } // expected-warning 2{{will always evaluate to 'true'}} expected-cxx11-warning {{implicit conversion of nullptr}} + template<int (*p)[3]> void g() { if (p) {} } // expected-warning 2{{will always evaluate to 'true'}} expected-cxx11-warning {{implicit conversion of nullptr}} + template<int (*p)()> void h() { if (p) {} } + + int a, b[3], c[3][3], d(); + template void f<&a>(); // expected-note {{instantiation of}} + template void f<b>(); // expected-note {{instantiation of}} +#if __cplusplus >= 201103L + template void f<(int*)nullptr>(); // expected-note {{instantiation of}} +#endif + template void g<&b>(); // expected-note {{instantiation of}} + template void g<c>(); // expected-note {{instantiation of}} +#if __cplusplus >= 201103L + template void g<(int(*)[3])nullptr>(); // expected-note {{instantiation of}} +#endif + template void h<d>(); +} 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>(); } |