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