summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ipa/pr63587-1.C
blob: a727b9e9e4c76247ebc4f54046d19c7a69277c23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// PR ipa/63587
// { dg-do compile { target c++11 } }
// { dg-options "-O2 -fno-strict-aliasing" }

template <class> struct A
{
};
template <typename> struct B
{
  template <typename> struct C;
};
class D;
template <typename> class F;
struct G
{
  void operator()(const D &, D);
};
class D
{
public:
  D (int);
};
struct H
{
  H (int);
};
template <typename _Key, typename, typename, typename _Compare, typename>
class I
{
  typedef _Key key_type;
  template <typename _Key_compare> struct J
  {
    _Key_compare _M_key_compare;
  };
  J<_Compare> _M_impl;

public:
  A<int> _M_get_insert_unique_pos (const key_type &);
  A<int> _M_get_insert_hint_unique_pos (H &);
  template <typename... _Args> int _M_emplace_hint_unique (H, _Args &&...);
};
template <typename _Key, typename _Tp, typename _Compare = G,
	  typename _Alloc = F<A<_Tp> > >
class K
{
  typedef _Key key_type;
  typedef _Key value_type;
  typedef typename B<_Alloc>::template C<value_type> _Pair_alloc_type;
  I<key_type, value_type, int, _Compare, _Pair_alloc_type> _M_t;

public:
  void operator[](key_type)
  {
    _M_t._M_emplace_hint_unique (0);
  }
};
template <typename _Key, typename _Val, typename _KeyOfValue,
	  typename _Compare, typename _Alloc>
A<int>
I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos (
  const key_type &p1)
{
  _M_impl._M_key_compare (p1, 0);
  return A<int>();
}
template <typename _Key, typename _Val, typename _KeyOfValue,
	  typename _Compare, typename _Alloc>
A<int>
I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_hint_unique_pos (
  H &)
{
  _M_get_insert_unique_pos (0);
  return A<int>();
}
template <typename _Key, typename _Val, typename _KeyOfValue,
	  typename _Compare, typename _Alloc>
template <typename... _Args>
int
I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique (
  H p1, _Args &&...)
{
  _M_get_insert_hint_unique_pos (p1);
  return 0;
}
namespace {
struct L;
}
void
fn1 ()
{
  K<D, L> a;
  a[0];
  K<D, int> b;
  b[0];
}