repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
modula2 testsuite: new libc unit test
[official-gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
torture
/
pr37146-1.C
blob
ea65226f13dfdbb95181cfa9f742565c7b73757b
1
// PR c++/37146
2
// { dg-do run }
3
4
extern "C" void abort ();
5
int a, b;
6
struct A { int i:8; int j:8; int k:16; int l:32; } c;
7
8
void
9
f1 (int x, int y)
10
{
11
(x ? a : b) = y;
12
}
13
14
void
15
f2 (int x, int y)
16
{
17
(x ? c.i : c.j) = y;
18
}
19
20
void
21
f3 (int x, int y)
22
{
23
(x ? c.i : a) = y;
24
}
25
26
void
27
f4 (int x, int y)
28
{
29
(x ? c.i : c.k) = y;
30
}
31
32
void
33
f5 (int x, int y)
34
{
35
(x ? c.l : b) = y;
36
}
37
38
#define CHECK(var, exp) \
39
do \
40
{ \
41
if (var != exp) \
42
abort (); \
43
var = -1; \
44
if (a != -1 \
45
|| b != -1 \
46
|| c.i != -1 \
47
|| c.j != -1 \
48
|| c.k != -1 \
49
|| c.l != -1) \
50
abort (); \
51
} \
52
while (0)
53
54
int
55
main ()
56
{
57
a = -1;
58
b = -1;
59
c.i = -1;
60
c.j = -1;
61
c.k = -1;
62
c.l = -1;
63
f1 (1, 264);
64
CHECK (a, 264);
65
f1 (0, 264);
66
CHECK (b, 264);
67
f2 (1, 112);
68
CHECK (c.i, 112);
69
f2 (0, 112);
70
CHECK (c.j, 112);
71
f3 (1, 26);
72
CHECK (c.i, 26);
73
f3 (0, 26);
74
CHECK (a, 26);
75
f4 (1, 107);
76
CHECK (c.i, 107);
77
f4 (0, 107);
78
CHECK (c.k, 107);
79
f5 (1, 95);
80
CHECK (c.l, 95);
81
f5 (0, 95);
82
CHECK (b, 95);
83
}