1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1z -triple=x86_64-linux-gnu
3 template <typename U
, typename V
>
5 static constexpr const bool value
= false;
8 template <typename U
, typename V
>
9 inline constexpr bool global_inline_var
= S1
<U
, V
>::value
;
13 template <typename U
, typename V
>
14 static inline constexpr bool var
= global_inline_var
<U
, V
>;
17 template <typename U
, typename V
>
18 inline constexpr bool constexpr_return_false() {
22 template <typename U
, typename V
>
24 static_assert(S1
<U
, V
>::value
);
25 // expected-error@-1{{static assertion failed due to requirement 'S1<int, float>::value'}}
27 template void foo
<int, float>();
28 // expected-note@-1{{in instantiation of function template specialization 'foo<int, float>' requested here}}
30 template <typename U
, typename V
>
32 static_assert(global_inline_var
<U
, V
>);
33 // expected-error@-1{{static assertion failed due to requirement 'global_inline_var<int, float>'}}
35 template void foo2
<int, float>();
36 // expected-note@-1{{in instantiation of function template specialization 'foo2<int, float>' requested here}}
38 template <typename T
, typename U
, typename V
>
40 static_assert(T::template var
<U
, V
>);
41 // expected-error@-1{{static assertion failed due to requirement 'S2<long>::var<int, float>'}}
43 template void foo3
<S2
<long>, int, float>();
44 // expected-note@-1{{in instantiation of function template specialization 'foo3<S2<long>, int, float>' requested here}}
48 static_assert(S1
<T
[sizeof(T
)], int[4]>::value
, "");
49 // expected-error@-1{{static assertion failed due to requirement 'S1<float[4], int[4]>::value'}}
51 template void foo4
<float>();
52 // expected-note@-1{{in instantiation of function template specialization 'foo4<float>' requested here}}
55 template <typename U
, typename V
>
57 static_assert(!!(global_inline_var
<U
, V
>));
58 // expected-error@-1{{static assertion failed due to requirement '!!(global_inline_var<int, float>)'}}
60 template void foo5
<int, float>();
61 // expected-note@-1{{in instantiation of function template specialization 'foo5<int, float>' requested here}}
64 explicit ExampleTypes(int);
73 constexpr operator bool() const { return false; }
78 static_assert(X
<typename
T::T
>());
79 // expected-error@-1{{static assertion failed due to requirement 'X<int>()'}}
80 static_assert(X
<typename
T::T
>{});
81 // expected-error@-1{{static assertion failed due to requirement 'X<int>{}'}}
82 static_assert(X
<typename
T::T
>{1, 2});
83 // expected-error@-1{{static assertion failed due to requirement 'X<int>{1, 2}'}}
84 static_assert(X
<typename
T::T
>({1, 2}));
85 // expected-error@-1{{static assertion failed due to requirement 'X<int>({1, 2})'}}
86 static_assert(typename
T::T
{0});
87 // expected-error@-1{{static assertion failed due to requirement 'int{0}'}}
88 static_assert(typename
T::T(0));
89 // expected-error@-1{{static assertion failed due to requirement 'int(0)'}}
90 static_assert(sizeof(X
<typename
T::T
>) == 0);
91 // expected-error@-1{{static assertion failed due to requirement 'sizeof(X<int>) == 0'}} \
92 // expected-note@-1 {{evaluates to '8 == 0'}}
93 static_assert((const X
<typename
T::T
> *)nullptr);
94 // expected-error@-1{{static assertion failed due to requirement '(const X<int> *)nullptr'}}
95 static_assert(static_cast<const X
<typename
T::T
> *>(nullptr));
96 // expected-error@-1{{static assertion failed due to requirement 'static_cast<const X<int> *>(nullptr)'}}
97 static_assert((const X
<typename
T::T
>[]){} == nullptr);
98 // expected-error@-1{{static assertion failed due to requirement '(const X<int>[0]){} == nullptr'}}
99 static_assert(sizeof(X
<decltype(X
<typename
T::T
>().X
<typename
T::T
>::~X())>) == 0);
100 // expected-error@-1{{static assertion failed due to requirement 'sizeof(X<void>) == 0'}} \
101 // expected-note@-1 {{evaluates to '8 == 0'}}
102 static_assert(constexpr_return_false
<typename
T::T
, typename
T::U
>());
103 // expected-error@-1{{static assertion failed due to requirement 'constexpr_return_false<int, float>()'}}
105 template void foo6
<ExampleTypes
>();
106 // expected-note@-1{{in instantiation of function template specialization 'foo6<ExampleTypes>' requested here}}