diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2018-12-19 02:24:12 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2018-12-19 02:24:12 +0000 |
commit | 55c8788102d8fd203270fabd6513247b2d7fbd87 (patch) | |
tree | 63ab727404da1afaca89c6578f37f135a50922e7 /test/SemaCXX/static-assert-cxx17.cpp | |
parent | 9fa0a1f211b7c9a402767bc895a87481cf347230 (diff) | |
parent | 46efdf2ccc2a80aefebf8433dbf9c7c959f6e629 (diff) |
Creating branches/google/stable and tags/google/stable/2018-12-18 from r349201
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@349597 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/static-assert-cxx17.cpp')
-rw-r--r-- | test/SemaCXX/static-assert-cxx17.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/SemaCXX/static-assert-cxx17.cpp b/test/SemaCXX/static-assert-cxx17.cpp new file mode 100644 index 0000000000..67b3541bea --- /dev/null +++ b/test/SemaCXX/static-assert-cxx17.cpp @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1z -triple=x86_64-linux-gnu + +template <typename U, typename V> +struct S1 { + static constexpr const bool value = false; +}; + +template <typename U, typename V> +inline constexpr bool global_inline_var = S1<U, V>::value; + +template <typename T> +struct S2 { + template <typename U, typename V> + static inline constexpr bool var = global_inline_var<U, V>; +}; + +template <typename U, typename V> +void foo() { + static_assert(S1<U, V>::value); + // expected-error@-1{{static_assert failed due to requirement 'S1<int, float>::value'}} +} +template void foo<int, float>(); +// expected-note@-1{{in instantiation of function template specialization 'foo<int, float>' requested here}} + +template <typename U, typename V> +void foo2() { + static_assert(global_inline_var<U, V>); + // expected-error@-1{{static_assert failed due to requirement 'global_inline_var<int, float>'}} +} +template void foo2<int, float>(); +// expected-note@-1{{in instantiation of function template specialization 'foo2<int, float>' requested here}} + +template <typename T, typename U, typename V> +void foo3() { + static_assert(T::template var<U, V>); + // expected-error@-1{{static_assert failed due to requirement 'S2<long>::var<int, float>'}} +} +template void foo3<S2<long>, int, float>(); +// expected-note@-1{{in instantiation of function template specialization 'foo3<S2<long>, int, float>' requested here}} + +template <typename T> +void foo4() { + static_assert(S1<T[sizeof(T)], int[4]>::value, ""); + // expected-error@-1{{static_assert failed due to requirement 'S1<float [4], int [4]>::value'}} +}; +template void foo4<float>(); +// expected-note@-1{{in instantiation of function template specialization 'foo4<float>' requested here}} + + +template <typename U, typename V> +void foo5() { + static_assert(!!(global_inline_var<U, V>)); + // expected-error@-1{{static_assert failed due to requirement '!!(global_inline_var<int, float>)'}} +} +template void foo5<int, float>(); +// expected-note@-1{{in instantiation of function template specialization 'foo5<int, float>' requested here}} |