brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · c7bfea4 Raw
66 lines · cpp
1// RUN: %clang_cc1 -verify %s -DTEST=12// RUN: %clang_cc1 -verify %s -DTEST=23// RUN: %clang_cc1 -verify %s -DTEST=34// REQUIRES: thread_support5 6// FIXME: Detection of, or recovery from, stack exhaustion does not work on7// NetBSD at the moment. Since this is a best-effort mitigation for exceeding8// implementation limits, just disable the test.9// UNSUPPORTED: system-netbsd10 11// asan has own stack-overflow check.12// UNSUPPORTED: asan13 14// expected-warning@* 0-1{{stack nearly exhausted}}15// expected-note@* 0+{{}}16 17#if TEST == 118 19template<int N> struct X : X<N-1> {};20template<> struct X<0> {};21X<1000> x;22 23template<typename ...T> struct tuple {};24template<typename ...T> auto f(tuple<T...> t) -> decltype(f(tuple<T...>(t))) {} // expected-error {{exceeded maximum depth}}25void g() { f(tuple<int, int>()); }26 27int f(X<0>);28template<int N> auto f(X<N>) -> f(X<N-1>());29 30int k = f(X<1000>());31 32#elif TEST == 233 34namespace template_argument_recursion {35  struct ostream;36  template<typename T> T &&declval();37 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;42  }43 44  void printFunctionalType(ostream &os, mlir::Value &v) { os << v; }45}46 47#elif TEST == 348 49namespace 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; };53 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;58  }59 60  void printFunctionalType(ostream &os, mlir::Value &v) { os << v; }61}62 63#else64#error unknown test65#endif66