Debian Codegraph @

gcc/testsuite/g++.dg/torture/pr71281.C

raw
1 // PR middle-end/71281
2 // { dg-do compile }
3 // { dg-additional-options "-std=c++11 -Ofast" }
4
5
6 template <typename> struct A;
7 template <typename _Tp> struct A<_Tp *> { typedef _Tp reference; };
8
9 template <typename _Iterator> class B {
10 public:
11 typename A<_Iterator>::reference operator*();
12 };
13
14 template <typename> class C;
15 template <typename> struct D;
16
17 template <typename _Tp> struct D<C<_Tp>> {
18 using value_type = _Tp;
19 using const_pointer = _Tp *;
20 template <typename _Up> using rebind_alloc = C<_Up>;
21 };
22
23 template <typename _Alloc> struct __alloc_traits : D<_Alloc> {
24 typedef D<_Alloc> _Base_type;
25 typedef typename _Base_type::value_type &reference;
26 template <typename _Tp> struct F {
27 typedef typename _Base_type::template rebind_alloc<_Tp> other;
28 };
29 };
30
31 template <typename _Tp, typename _Alloc> struct G {
32 typedef typename __alloc_traits<_Alloc>::template F<_Tp>::other
33 _Tp_alloc_type;
34 };
35
36 int a, b;
37 long d[1][1][1];
38 void fn1() __attribute__((__noreturn__));
39 template <typename _Tp, typename _Alloc = C<_Tp>> class H {
40 typedef __alloc_traits<typename G<_Tp, _Alloc>::_Tp_alloc_type> _Alloc_traits;
41 typedef typename _Alloc_traits::reference reference;
42
43 public:
44 B<typename _Alloc_traits::const_pointer> m_fn1();
45 long m_fn2();
46 reference operator[](unsigned);
47 reference m_fn3(unsigned){
48 if (m_fn2())
49 fn1();
50 } // { dg-warning "control reaches end of non-void function" }
51 };
52
53 H<H<H<unsigned>>> c;
54 void fn2() {
55 H<unsigned, C<int>> e;
56 for (int f = 1;;)
57 for (int g = 0;;)
58 for (int h = 0;;)
59 {
60 *d[0][h] =
61 c.m_fn3(f)[0][g] * a + -*(e).m_fn1() * b + (*c[f].m_fn1()).m_fn3(g);
62 }
63 }