[OpenACC] Enable 'attach' clause for combined constructs
[llvm-project.git] / clang / test / SemaTemplate / stack-exhaustion.cpp
blobc7bfea4132d5ed953ff19dfe6747b96d22baa605
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.
12 // UNSUPPORTED: asan
14 // expected-warning@* 0-1{{stack nearly exhausted}}
15 // expected-note@* 0+{{}}
17 #if TEST == 1
19 template<int N> struct X : X<N-1> {};
20 template<> struct X<0> {};
21 X<1000> x;
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>()); }
27 int f(X<0>);
28 template<int N> auto f(X<N>) -> f(X<N-1>());
30 int k = f(X<1000>());
32 #elif TEST == 2
34 namespace template_argument_recursion {
35 struct ostream;
36 template<typename T> T &&declval();
38 namespace mlir {
39 template<typename T, typename = decltype(declval<ostream&>() << declval<T&>())>
40 ostream &operator<<(ostream& os, const T& obj); // expected-error {{exceeded maximum depth}}
41 struct Value;
44 void printFunctionalType(ostream &os, mlir::Value &v) { os << v; }
47 #elif TEST == 3
49 namespace template_parameter_type_recursion {
50 struct ostream;
51 template<typename T> T &&declval();
52 template<bool B, typename T> struct enable_if { using type = T; };
54 namespace mlir {
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}}
57 struct Value;
60 void printFunctionalType(ostream &os, mlir::Value &v) { os << v; }
63 #else
64 #error unknown test
65 #endif