OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [trailing1.C] - Blame information for rev 338

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.