]> gcc.gnu.org Git - gcc.git/blame - gcc/testsuite/g++.dg/cpp0x/trailing1.C
re PR libfortran/47567 (Wrong output for small absolute values with F editing)
[gcc.git] / gcc / testsuite / g++.dg / cpp0x / trailing1.C
CommitLineData
38179091 1// Tests for late-specified return type.
f57ca1ea
JM
2// { dg-options "-std=c++0x" }
3
4auto f() -> int
5{
6 return 0;
7}
8
9template<class T, class U>
18802917
JM
10auto add(T t, U u) -> decltype (t+u)
11{
12 return t+u;
13}
b344d949
JM
14
15template<class T, class U>
38179091
JM
16decltype(T()+U()) add2(T t, U u)
17{
18 return t+u;
19}
b344d949
JM
20
21template <class T, class U>
38179091
JM
22U ag (T, U)
23{
24 return U();
25}
b344d949
JM
26
27template<class T, class U>
38179091
JM
28auto add3(T t, U u) -> decltype (ag(t,u))
29{
30 return ag(t,u);
31}
32
a77f94e2
JM
33template<class T, class U>
34decltype(*(T*)0+*(U*)0) add4(T t, U u)
35{
36 return t+u;
37}
38
38179091
JM
39template <class T>
40struct A
41{
42 T f() {}
43 template <class U>
44 T g() {}
45 template <class V>
46 struct B
47 {
48 int MEM;
49 };
50};
51
52template <class T>
53auto f(T* t) -> decltype (t->f())
54{
55 return t->f();
56}
57
58template <class T>
59auto g(T t) -> decltype (t.f())
60{
61 return t.f();
62}
63
64template <class T, class U>
65auto h(T t, U u) -> decltype (t.template g<U>())
66{
67 return t.template g<U>();
68}
69
70struct D { };
71struct C: public A<int>::B<D>
72{
73};
74
75template <class T, class U, class V>
76auto k(T t, U u, V v) -> decltype (t.U::template B<V>::MEM)
77{
78 return t.U::template B<V>::MEM;
79}
80
a77f94e2
JM
81// For these two examples we can elide the 'decltype' and just mangle the type.
82template <class T>
83auto l(T t) -> decltype (t)
84{
85 return t;
86}
87
88template <class T, T u>
89auto m(T t) -> decltype (u)
90{
91 return t;
92}
93
38179091 94A<int> a, *p;
b344d949
JM
95
96int main()
97{
448545cb 98 // { dg-final { scan-assembler "_Z3addIidEDTplfp_fp0_ET_T0_" } }
b344d949 99 auto i = add(1, 2.0);
448545cb 100 // { dg-final { scan-assembler "_Z4add4IidEDTpldecvPT_Li0EdecvPT0_Li0EES0_S2_" } }
a77f94e2 101 auto i4 = add4(1, 2.0);
448545cb 102 // { dg-final { scan-assembler "_Z4add2IidEDTplcvT__EcvT0__EES0_S1_" } }
b344d949 103 auto i2 = add2(1, 2.0);
a3c49752 104 // { dg-final { scan-assembler "_Z4add3IidEDTcl2agfp_fp0_EET_T0_" } }
b344d949 105 auto i3 = add3(1, 2.0);
448545cb 106 // { dg-final { scan-assembler "_Z1fI1AIiEEDTclptfp_1fEEPT_" } }
38179091 107 f(p);
448545cb 108 // { dg-final { scan-assembler "_Z1gI1AIiEEDTcldtfp_1fEET_" } }
38179091 109 g(a);
448545cb 110 // { dg-final { scan-assembler "_Z1hI1AIiEdEDTcldtfp_1gIT0_EEET_S2_" } }
38179091 111 h(a,1.0);
448545cb 112 // { dg-final { scan-assembler "_Z1kI1C1AIiE1DEDtdtfp_srNT0_1BIT1_EE3MEMET_S4_S6_" } }
38179091 113 k( C(), A<int>(), D() );
a77f94e2
JM
114 // { dg-final { scan-assembler "_Z1lIiET_S0_" } }
115 l(1);
116 // { dg-final { scan-assembler "_Z1mIiLi1EET_S0_" } }
117 m<int,1>(1);
b344d949 118}
This page took 1.436263 seconds and 5 git commands to generate.