| 1 |
/* Copy of g++.dg/warn/Winfinite-recursion-2.C */ |
| 2 |
|
| 3 |
/* { dg-do compile { target c++11 } } */ |
| 4 |
|
| 5 |
namespace std |
| 6 |
{ |
| 7 |
class type_info { |
| 8 |
public: |
| 9 |
void k() const; |
| 10 |
}; |
| 11 |
|
| 12 |
} // namespace std |
| 13 |
|
| 14 |
using std::type_info; |
| 15 |
|
| 16 |
template <int a> struct f { static constexpr int c = a; }; |
| 17 |
struct h { |
| 18 |
typedef int e; |
| 19 |
}; |
| 20 |
|
| 21 |
template <unsigned long, typename...> struct m; |
| 22 |
template <unsigned long ab, typename i, typename j, typename... ac> |
| 23 |
struct m<ab, i, j, ac...> : m<ab + 1, i, ac...> {}; |
| 24 |
template <unsigned long ab, typename j, typename... ac> |
| 25 |
struct m<ab, j, j, ac...> : f<ab> {}; |
| 26 |
template <unsigned long, typename...> struct n; |
| 27 |
template <unsigned long ab, typename j, typename... ac> |
| 28 |
struct n<ab, j, ac...> : n<ab - 1, ac...> {}; |
| 29 |
template <typename j, typename... ac> struct n<0, j, ac...> : h {}; |
| 30 |
template <typename... l> class F { |
| 31 |
template <typename i> struct I : m<0, i, l...> {}; |
| 32 |
template <int ab> struct s : n<ab, l...> {}; |
| 33 |
static const type_info *const b[]; |
| 34 |
struct G { |
| 35 |
template <typename ag> |
| 36 |
operator ag() const |
| 37 |
{ |
| 38 |
return *this; /* { dg-warning "-Wanalyzer-infinite-recursion" } */ |
| 39 |
} |
| 40 |
}; |
| 41 |
unsigned o; |
| 42 |
G ah; |
| 43 |
|
| 44 |
public: |
| 45 |
F(); |
| 46 |
long t() const { return o; } |
| 47 |
const type_info &m_fn3() const { return *b[o]; } |
| 48 |
template <int ab> typename s<ab>::e *m_fn4() const { |
| 49 |
if (o != ab) |
| 50 |
return nullptr; |
| 51 |
return ah; |
| 52 |
} |
| 53 |
template <int ab> void m_fn5() const { |
| 54 |
m_fn4<ab>(); |
| 55 |
const type_info &r = m_fn3(); |
| 56 |
r.k(); |
| 57 |
} |
| 58 |
template <typename i> void u() const { m_fn5<I<i>::c>(); } |
| 59 |
}; |
| 60 |
template <typename... l> const type_info *const F<l...>::b[] {&typeid(l)...}; |
| 61 |
using am = unsigned char; |
| 62 |
class H { |
| 63 |
enum bd : am { be = 2 }; |
| 64 |
using bf = F<int, int, H>; |
| 65 |
bf ah; |
| 66 |
template <typename bg> void v() const { ah.u<bg>(); } |
| 67 |
void w() const; |
| 68 |
}; |
| 69 |
void H::w() const { |
| 70 |
bd d = bd(ah.t()); |
| 71 |
switch (d) |
| 72 |
case be: |
| 73 |
v<H>(); |
| 74 |
} |