repo.or.cz
/
official-gcc
/
graphite-test-results.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Merge from mainline (160224:163495).
[official-gcc/graphite-test-results.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp0x
/
union3.C
blob
f1e8ddb610930c5b6c8b8e6b4ea6b18c8be88b34
1
// 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
}