summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/trailing1.C
blob: f637857b427a49d3c24e9c9a2643b14c223cd6c9 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Tests for late-specified return type.
// { dg-options "-std=c++0x -fabi-version=5" }

auto f() -> int
{
  return 0;
}

template<class T, class U>
auto add(T t, U u) -> decltype (t+u)
{
  return t+u;
}

template<class T, class U>
decltype(T()+U()) add2(T t, U u)
{
  return t+u;
}

template <class T, class U>
U ag (T, U)
{
  return U();
}

template<class T, class U>
auto add3(T t, U u) -> decltype (ag(t,u))
{
  return ag(t,u);
}

template<class T, class U>
decltype(*(T*)0+*(U*)0) add4(T t, U u)
{
  return t+u;
}

template <class T>
struct A
{
  T f() {}
  template <class U>
  T g() {}
  template <class V>
  struct B
  {
    int MEM;
  };
};

template <class T>
auto f(T* t) -> decltype (t->f())
{
  return t->f();
}

template <class T>
auto g(T t) -> decltype (t.f())
{
  return t.f();
}

template <class T, class U>
auto h(T t, U u) -> decltype (t.template g<U>())
{
  return t.template g<U>();
}

struct D { };
struct C: public A<int>::B<D>
{
};

template <class T, class U, class V>
auto k(T t, U u, V v) -> decltype (t.U::template B<V>::MEM)
{
  return t.U::template B<V>::MEM;
}

template <class T>
auto l(T t) -> decltype (t)
{
  return t;
}

template <class T, T u>
auto m(T t) -> decltype (u)
{
  return t;
}

A<int> a, *p;

int main()
{
  // { dg-final { scan-assembler  "_Z3addIidEDTplfp_fp0_ET_T0_" } }
  auto i = add(1, 2.0);
  // { dg-final { scan-assembler "_Z4add4IidEDTpldecvPT_Li0EdecvPT0_Li0EES0_S2_" } }
  auto i4 = add4(1, 2.0);
  // { dg-final { scan-assembler "_Z4add2IidEDTplcvT__EcvT0__EES0_S1_" } }
  auto i2 = add2(1, 2.0);
  // { dg-final { scan-assembler "_Z4add3IidEDTcl2agfp_fp0_EET_T0_" } }
  auto i3 = add3(1, 2.0);
  // { dg-final { scan-assembler "_Z1fI1AIiEEDTclptfp_1fEEPT_" } }
  f(p);
  // { dg-final { scan-assembler "_Z1gI1AIiEEDTcldtfp_1fEET_" } }
  g(a);
  // { dg-final { scan-assembler "_Z1hI1AIiEdEDTcldtfp_1gIT0_EEET_S2_" } }
  h(a,1.0);
  // { dg-final { scan-assembler "_Z1kI1C1AIiE1DEDtdtfp_srNT0_1BIT1_EE3MEMET_S4_S6_" } }
  k( C(), A<int>(), D() );
  // { dg-final { scan-assembler "_Z1lIiEDtfp_ET_" } }
  l(1);
  // { dg-final { scan-assembler "_Z1mIiLi1EEDtT0_ET_" } }
  m<int,1>(1);
}