1 // RUN: %clang_cc1 -verify %s -DTEST=1
2 // RUN: %clang_cc1 -verify %s -DTEST=2
3 // RUN: %clang_cc1 -verify %s -DTEST=3
4 // REQUIRES: thread_support
6 // FIXME: Detection of, or recovery from, stack exhaustion does not work on
7 // NetBSD at the moment. Since this is a best-effort mitigation for exceeding
8 // implementation limits, just disable the test.
9 // UNSUPPORTED: system-netbsd
11 // asan has own stack-overflow check.
14 // expected-warning@* 0-1{{stack nearly exhausted}}
15 // expected-note@* 0+{{}}
19 template<int N
> struct X
: X
<N
-1> {};
20 template<> struct X
<0> {};
23 template<typename
...T
> struct tuple
{};
24 template<typename
...T
> auto f(tuple
<T
...> t
) -> decltype(f(tuple
<T
...>(t
))) {} // expected-error {{exceeded maximum depth}}
25 void g() { f(tuple
<int, int>()); }
28 template<int N
> auto f(X
<N
>) -> f(X
<N
-1>());
34 namespace template_argument_recursion
{
36 template<typename T
> T
&&declval();
39 template<typename T
, typename
= decltype(declval
<ostream
&>() << declval
<T
&>())>
40 ostream
&operator<<(ostream
& os
, const T
& obj
); // expected-error {{exceeded maximum depth}}
44 void printFunctionalType(ostream
&os
, mlir::Value
&v
) { os
<< v
; }
49 namespace template_parameter_type_recursion
{
51 template<typename T
> T
&&declval();
52 template<bool B
, typename T
> struct enable_if
{ using type
= T
; };
55 template<typename T
, typename enable_if
<declval
<ostream
&>() << declval
<T
&>(), void*>::type
= nullptr>
56 ostream
&operator<<(ostream
& os
, const T
& obj
); // expected-error {{exceeded maximum depth}}
60 void printFunctionalType(ostream
&os
, mlir::Value
&v
) { os
<< v
; }