2015-03-24 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / pr63587-1.C
blobcbf872e2969bcc0d4e42e3a9790ceab76cd809ca
1 // PR ipa/63587
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2 -fno-strict-aliasing" }
5 template <class> struct A
7 };
8 template <typename> struct B
10   template <typename> struct C;
12 class D;
13 template <typename> class F;
14 struct G
16   void operator()(const D &, D);
18 class D
20 public:
21   D (int);
23 struct H
25   H (int);
27 template <typename _Key, typename, typename, typename _Compare, typename>
28 class I
30   typedef _Key key_type;
31   template <typename _Key_compare> struct J
32   {
33     _Key_compare _M_key_compare;
34   };
35   J<_Compare> _M_impl;
37 public:
38   A<int> _M_get_insert_unique_pos (const key_type &);
39   A<int> _M_get_insert_hint_unique_pos (H &);
40   template <typename... _Args> int _M_emplace_hint_unique (H, _Args &&...);
42 template <typename _Key, typename _Tp, typename _Compare = G,
43           typename _Alloc = F<A<_Tp> > >
44 class K
46   typedef _Key key_type;
47   typedef _Key value_type;
48   typedef typename B<_Alloc>::template C<value_type> _Pair_alloc_type;
49   I<key_type, value_type, int, _Compare, _Pair_alloc_type> _M_t;
51 public:
52   void operator[](key_type)
53   {
54     _M_t._M_emplace_hint_unique (0);
55   }
57 template <typename _Key, typename _Val, typename _KeyOfValue,
58           typename _Compare, typename _Alloc>
59 A<int>
60 I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos (
61   const key_type &p1)
63   _M_impl._M_key_compare (p1, 0);
65 template <typename _Key, typename _Val, typename _KeyOfValue,
66           typename _Compare, typename _Alloc>
67 A<int>
68 I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_hint_unique_pos (
69   H &)
71   _M_get_insert_unique_pos (0);
73 template <typename _Key, typename _Val, typename _KeyOfValue,
74           typename _Compare, typename _Alloc>
75 template <typename... _Args>
76 int
77 I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique (
78   H p1, _Args &&...)
80   _M_get_insert_hint_unique_pos (p1);
82 namespace {
83 struct L;
85 void
86 fn1 ()
88   K<D, L> a;
89   a[0];
90   K<D, int> b;
91   b[0];