Clement Courbet | 9d432e0 | 2018-12-04 07:59:57 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1z -triple=x86_64-linux-gnu |
| 2 | |
| 3 | template <typename U, typename V> |
| 4 | struct S1 { |
| 5 | static constexpr const bool value = false; |
| 6 | }; |
| 7 | |
| 8 | template <typename U, typename V> |
| 9 | inline constexpr bool global_inline_var = S1<U, V>::value; |
| 10 | |
| 11 | template <typename T> |
| 12 | struct S2 { |
| 13 | template <typename U, typename V> |
| 14 | static inline constexpr bool var = global_inline_var<U, V>; |
| 15 | }; |
| 16 | |
| 17 | template <typename U, typename V> |
| 18 | void foo() { |
| 19 | static_assert(S1<U, V>::value); |
| 20 | // expected-error@-1{{static_assert failed due to requirement 'S1<int, float>::value'}} |
| 21 | } |
| 22 | template void foo<int, float>(); |
| 23 | // expected-note@-1{{in instantiation of function template specialization 'foo<int, float>' requested here}} |
| 24 | |
| 25 | template <typename U, typename V> |
| 26 | void foo2() { |
| 27 | static_assert(global_inline_var<U, V>); |
| 28 | // expected-error@-1{{static_assert failed due to requirement 'global_inline_var<int, float>'}} |
| 29 | } |
| 30 | template void foo2<int, float>(); |
| 31 | // expected-note@-1{{in instantiation of function template specialization 'foo2<int, float>' requested here}} |
| 32 | |
| 33 | template <typename T, typename U, typename V> |
| 34 | void foo3() { |
| 35 | static_assert(T::template var<U, V>); |
| 36 | // expected-error@-1{{static_assert failed due to requirement 'S2<long>::var<int, float>'}} |
| 37 | } |
| 38 | template void foo3<S2<long>, int, float>(); |
| 39 | // expected-note@-1{{in instantiation of function template specialization 'foo3<S2<long>, int, float>' requested here}} |
| 40 | |
| 41 | template <typename T> |
| 42 | void foo4() { |
| 43 | static_assert(S1<T[sizeof(T)], int[4]>::value, ""); |
| 44 | // expected-error@-1{{static_assert failed due to requirement 'S1<float [4], int [4]>::value'}} |
| 45 | }; |
| 46 | template void foo4<float>(); |
| 47 | // expected-note@-1{{in instantiation of function template specialization 'foo4<float>' requested here}} |