comparison gcc/testsuite/g++.dg/torture/pr81360.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* { dg-do compile } */
2 /* { dg-options "-fno-early-inlining" } */
3
4 template <int dim> class B;
5 template <int, int dim> class TriaObjectAccessor;
6 template <int, typename Accessor> class A;
7 template <int dim> class TriaDimensionInfo {
8 public:
9 typedef A<3, TriaObjectAccessor<2, 3> > raw_quad_iterator;
10 typedef A<3, B<3> > raw_hex_iterator;
11 typedef raw_hex_iterator raw_cell_iterator;
12 };
13 template <int dim> class Triangulation : public TriaDimensionInfo<1> {
14 public:
15 typedef typename TriaDimensionInfo<dim>::raw_quad_iterator raw_quad_iterator;
16 TriaDimensionInfo::raw_cell_iterator end() const;
17 raw_quad_iterator end_quad() const {
18 return raw_quad_iterator(const_cast<Triangulation *>(this), 0, 0);
19 }
20 };
21 template <int dim> class TriaAccessor {
22 public:
23 typedef void AccessorData;
24 TriaAccessor(const Triangulation<dim> * = 0);
25 Triangulation<1> *tria;
26
27 int a, b, c;
28 };
29 template <int dim> class TriaObjectAccessor<2, dim> : public TriaAccessor<dim> {
30 public:
31 typedef typename TriaAccessor<dim>::AccessorData AccessorData;
32 TriaObjectAccessor(const Triangulation<dim> * = 0);
33 };
34 template <int dim> class TriaObjectAccessor<3, dim> : public TriaAccessor<dim> {
35 public:
36 typedef typename TriaAccessor<dim>::AccessorData AccessorData;
37 TriaObjectAccessor(const Triangulation<dim> * = 0);
38 };
39 template <int dim> class B : public TriaObjectAccessor<dim, dim> {
40 public:
41 typedef typename TriaObjectAccessor<dim, dim>::AccessorData AccessorData;
42 B(const Triangulation<dim> * = 0);
43 };
44 template <int dim, typename Accessor> class A {
45 public:
46 A(const A &);
47 A(const Triangulation<dim> *, int, int);
48 Accessor accessor;
49 };
50 template class Triangulation<3>;
51 template <int dim, typename Accessor>
52 A<dim, Accessor>::A(const Triangulation<dim> *, int, int) {}
53 template <int dim>
54 TriaAccessor<dim>::TriaAccessor(const Triangulation<dim> *)
55 : tria(), a(-1), b(-2), c(-3) {}
56 template <int dim>
57 TriaObjectAccessor<2, dim>::TriaObjectAccessor(const Triangulation<dim> *) {}
58 template <int dim>
59 TriaObjectAccessor<3, dim>::TriaObjectAccessor(const Triangulation<dim> *) {}
60 template <int dim> B<dim>::B(const Triangulation<dim> *) {}
61 template <>
62 TriaDimensionInfo<3>::raw_cell_iterator Triangulation<3>::end() const {
63 return raw_hex_iterator(const_cast<Triangulation *>(this), 0, 0);
64 }
65
66 #pragma GCC optimize ("-O0")
67 int main()
68 {
69 Triangulation <3> t;
70 Triangulation<3>::raw_quad_iterator i1 = t.end_quad();
71 TriaDimensionInfo<3>::raw_cell_iterator i2 = t.end();
72
73 if(i2.accessor.c != -3)
74 return 1;
75
76 return 0;
77 }
78