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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [auto2.C] - Blame information for rev 709

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// Positive test for auto
2
// { dg-do run }
3
// { dg-options "-std=c++0x" }
4
 
5
#include 
6
extern "C" void abort();
7
 
8
int f() {}
9
 
10
struct A
11
{
12
  int i;
13
  int f() {}
14
  A operator+(A a) { return a; }
15
};
16
 
17
template 
18
void g(T t)
19
{
20
  auto x = t+t;
21
  if (typeid(x) != typeid(t+t))
22
    abort();
23
 
24
  auto p = new auto(&t);
25
  if (typeid(p) != typeid(T**))
26
    abort();
27
}
28
 
29
int main()
30
{
31
  auto i = 42;
32
  if (typeid (i) != typeid (int))
33
    abort();
34
 
35
  auto *p = &i;
36
  if (typeid (p) != typeid (int*))
37
    abort();
38
 
39
  auto *p2 = &p;
40
  if (typeid (p2) != typeid (int**))
41
    abort();
42
 
43
  auto (*fp)() = f;
44
  if (typeid (fp) != typeid (int (*)()))
45
    abort();
46
 
47
  auto A::* pm = &A::i;
48
  if (typeid (pm) != typeid (int A::*))
49
    abort();
50
 
51
  auto (A::*pmf)() = &A::f;
52
  if (typeid (pmf) != typeid (int (A::*)()))
53
    abort();
54
 
55
  g(42);
56
  g(10.f);
57
  g(A());
58
 
59
  auto *p3 = new auto (i);
60
  if (typeid (p3) != typeid (int*))
61
    abort();
62
 
63
  for (auto idx = i; idx != 0; idx = 0);
64
  while (auto idx = 0);
65
  if (auto idx = 1);
66
 
67
  switch (auto s = i)
68
    {
69
    case 42:
70
      break;
71
    }
72
 
73
  auto j = 42, k = 24;
74
}

powered by: WebSVN 2.1.0

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