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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [union3.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
// Runtime test for C++0x unrestricted unions
2
// { dg-options -std=c++0x }
3
// { dg-do run }
4
 
5
int c, d;
6
struct A
7
{
8
  int i;
9
  A(): i(1) { ++c; }
10
  A(const A&): i(2) { ++c; }
11
  ~A() { ++d; }
12
};
13
 
14
union B
15
{
16
  A a;
17
  B() { }
18
  B(const B& b) { }
19
  ~B() { }
20
};
21
 
22
struct C
23
{
24
  union { A a; };
25
  C() { }
26
  C(const C&) { }
27
  ~C() { }
28
};
29
 
30
union D
31
{
32
  A a;
33
  D(): a() { }
34
  D(const D& d): a(d.a) { }
35
  ~D() { a.~A(); }
36
};
37
 
38
struct E
39
{
40
  union { A a; };
41
  E(): a() { }
42
  E(const E& e): a (e.a) { }
43
  ~E() { a.~A(); }
44
};
45
 
46
int main()
47
{
48
  {
49
    B b1;
50
    B b2(b1);
51
 
52
    C c1;
53
    C c2(c1);
54
  }
55
 
56
  if (c != 0 || d != 0)
57
    return c+d*10;
58
 
59
  {
60
    D d1;
61
    D d2(d1);
62
 
63
    E e1;
64
    E e2(e1);
65
  }
66
 
67
  if (c != 4 || d != 4)
68
    return c*100+d*1000;
69
}

powered by: WebSVN 2.1.0

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