1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/* Test precedence and associativity in expressions. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "" } */
struct s { int *a; } *p, q, *r[2], *g();
int *i[2];
int j[2];
_Complex double c[2];
void
f (void)
{
#define ASSERT(expr) do { char x[(expr) ? 1 : -1]; } while (0)
/* Postfix and unary operators and casts. */
*p++;
*p--;
*p->a;
*q.a;
*r[1];
(*g()).a;
++i[0];
--i[0];
+j[0];
-j[0];
~j[0];
!j[0];
__real__ c[1];
__imag__ c[1];
ASSERT ((sizeof p++) == (sizeof p));
ASSERT ((sizeof (int) + 1) == ((sizeof (int)) + 1));
ASSERT ((__alignof p++) == (__alignof p));
ASSERT ((__alignof (int) + 1) == ((__alignof (int)) + 1));
ASSERT ((sizeof __extension__ 1 + 1) == ((sizeof 1) + 1));
/* Binary operators. */
ASSERT (((_Bool) 1 * 2) == 2);
ASSERT (((_Bool) 8 / 4) == 0);
ASSERT (((_Bool) 8 % 4) == 1);
#define ASSERT_BIN(C1, O1, C2, O2, C3, V1, V2, V3) \
do { \
ASSERT ((C1 O1 C2 O2 C3) == V1); \
ASSERT (((C1 O1 C2) O2 C3) == V2); \
ASSERT ((C1 O1 (C2 O2 C3)) == V3); \
} while (0);
ASSERT_BIN (1, *, 2, *, 3, 6, 6, 6);
ASSERT_BIN (2, *, 2, /, 3, 1, 1, 0);
ASSERT_BIN (2, *, 2, %, 3, 1, 1, 4);
ASSERT_BIN (2, /, 2, *, 3, 3, 3, 0);
ASSERT_BIN (2, /, 2, /, 2, 0, 0, 2);
ASSERT_BIN (2, /, 4, %, 3, 0, 0, 2);
ASSERT_BIN (2, %, 2, *, 3, 0, 0, 2);
ASSERT_BIN (2, %, 9, /, 3, 0, 0, 2);
ASSERT_BIN (2, %, 4, %, 3, 2, 2, 0);
ASSERT_BIN (2, *, 3, +, 4, 10, 10, 14);
ASSERT_BIN (2, *, 3, -, 4, 2, 2, -2);
ASSERT_BIN (2, /, 3, +, 4, 4, 4, 0);
ASSERT_BIN (2, /, 3, -, 4, -4, -4, -2);
ASSERT_BIN (2, %, 3, +, 4, 6, 6, 2);
ASSERT_BIN (2, %, 3, -, 4, -2, -2, 0);
ASSERT_BIN (2, +, 3, *, 4, 14, 20, 14);
ASSERT_BIN (2, +, 3, /, 4, 2, 1, 2);
ASSERT_BIN (2, +, 3, %, 4, 5, 1, 5);
ASSERT_BIN (2, -, 3, *, 4, -10, -4, -10);
ASSERT_BIN (2, -, 3, /, 4, 2, 0, 2);
ASSERT_BIN (2, -, 4, %, 4, 2, -2, 2);
ASSERT_BIN (2, +, 3, +, 4, 9, 9, 9);
ASSERT_BIN (2, +, 3, -, 4, 1, 1, 1);
ASSERT_BIN (2, -, 3, +, 4, 3, 3, -5);
ASSERT_BIN (2, -, 3, -, 4, -5, -5, 3);
ASSERT_BIN (3, +, 2, <<, 4, 80, 80, 35);
ASSERT_BIN (3, +, 2, >>, 4, 0, 0, 3);
ASSERT_BIN (3, -, 2, <<, 4, 16, 16, -29);
ASSERT_BIN (3, -, 2, >>, 4, 0, 0, 3);
ASSERT_BIN (2, <<, 4, +, 3, 256, 35, 256);
ASSERT_BIN (2, <<, 4, -, 3, 4, 29, 4);
ASSERT_BIN (2, >>, 4, +, 3, 0, 3, 0);
ASSERT_BIN (2, >>, 4, -, 3, 1, -3, 1);
ASSERT_BIN (4L, <<, 2L, <<, 3L, 128L, 128L, 262144L);
ASSERT_BIN (4L, <<, 2L, >>, 3L, 2L, 2L, 4L);
ASSERT_BIN (4L, >>, 2L, <<, 3L, 8L, 8L, 0L);
ASSERT_BIN (4L, >>, 2L, >>, 3L, 0L, 0L, 4L);
ASSERT_BIN (2, <<, 5, <, 4, 0, 0, 2);
ASSERT_BIN (2, <<, 5, >, 4, 1, 1, 4);
ASSERT_BIN (2, <<, 5, <=, 4, 0, 0, 2);
ASSERT_BIN (2, <<, 5, >=, 4, 1, 1, 4);
ASSERT_BIN (2, >>, 5, <, 4, 1, 1, 2);
ASSERT_BIN (2, >>, 5, >, 4, 0, 0, 1);
ASSERT_BIN (2, >>, 5, <=, 4, 1, 1, 2);
ASSERT_BIN (2, >>, 5, >=, 4, 0, 0, 1);
ASSERT_BIN (4, <, 3, <<, 2, 1, 0, 1);
ASSERT_BIN (4, <, 20, >>, 2, 1, 0, 1);
ASSERT_BIN (4, >, 3, <<, 2, 0, 4, 0);
ASSERT_BIN (4, >, 3, >>, 2, 1, 0, 1);
ASSERT_BIN (4, <=, 3, <<, 2, 1, 0, 1);
ASSERT_BIN (4, <=, 20, >>, 2, 1, 0, 1);
ASSERT_BIN (4, >=, 3, <<, 2, 0, 4, 0);
ASSERT_BIN (4, >=, 3, >>, 2, 1, 0, 1);
ASSERT_BIN (1, <, 2, <, 3, 1, 1, 0);
ASSERT_BIN (1, <, 2, >, 0, 1, 1, 0);
ASSERT_BIN (1, <, 2, <=, 3, 1, 1, 0);
ASSERT_BIN (0, <, 4, >=, 3, 0, 0, 1);
ASSERT_BIN (1, >, 2, <, 3, 1, 1, 0);
ASSERT_BIN (1, >, 2, >, 3, 0, 0, 1);
ASSERT_BIN (1, >, 2, <=, 3, 1, 1, 0);
ASSERT_BIN (1, >, 2, >=, 3, 0, 0, 1);
ASSERT_BIN (3, <=, 2, <, 3, 1, 1, 0);
ASSERT_BIN (2, <=, 3, >, 0, 1, 1, 0);
ASSERT_BIN (2, <=, 3, <=, 4, 1, 1, 0);
ASSERT_BIN (2, <=, 3, >=, 1, 1, 1, 0);
ASSERT_BIN (0, >=, 2, <, 3, 1, 1, 0);
ASSERT_BIN (1, >=, 2, >, 3, 0, 0, 1);
ASSERT_BIN (0, >=, 2, <=, 3, 1, 1, 0);
ASSERT_BIN (1, >=, 2, >=, 3, 0, 0, 1);
ASSERT_BIN (-1, <, 2, ==, 3, 0, 0, 1);
ASSERT_BIN (1, <, 2, !=, 3, 1, 1, 0);
ASSERT_BIN (1, >, 2, ==, 3, 0, 0, 1);
ASSERT_BIN (1, >, 2, !=, 3, 1, 1, 0);
ASSERT_BIN (0, <=, 2, ==, 3, 0, 0, 1);
ASSERT_BIN (2, <=, 2, !=, 3, 1, 1, 0);
ASSERT_BIN (1, >=, 2, ==, 3, 0, 0, 1);
ASSERT_BIN (0, >=, 2, !=, 3, 1, 1, 0);
ASSERT_BIN (1, ==, 3, <, 2, 0, 1, 0);
ASSERT_BIN (1, ==, 3, >, 2, 1, 0, 1);
ASSERT_BIN (1, ==, 3, <=, 2, 0, 1, 0);
ASSERT_BIN (1, ==, 3, >=, 2, 1, 0, 1);
ASSERT_BIN (1, !=, 2, <, 3, 0, 1, 0);
ASSERT_BIN (1, !=, 2, >, 3, 1, 0, 1);
ASSERT_BIN (1, !=, 2, <=, 3, 0, 1, 0);
ASSERT_BIN (1, !=, 2, >=, 3, 1, 0, 1);
ASSERT_BIN (1, ==, 2, ==, 0, 1, 1, 0);
ASSERT_BIN (1, ==, 2, !=, 0, 0, 0, 1);
ASSERT_BIN (1, !=, 2, ==, 3, 0, 0, 1);
ASSERT_BIN (1, !=, 2, !=, 3, 1, 1, 0);
ASSERT_BIN (0, ==, 2, &, 1, 0, 0, 1);
ASSERT_BIN (0, !=, 2, &, 1, 1, 1, 0);
ASSERT_BIN (1, &, 2, ==, 0, 0, 1, 0);
ASSERT_BIN (1, &, 2, !=, 0, 1, 0, 1);
ASSERT_BIN (1, &, 2, ^, 3, 3, 3, 1);
ASSERT_BIN (3, ^, 2, &, 1, 3, 1, 3);
ASSERT_BIN (3, ^, 2, |, 1, 1, 1, 0);
ASSERT_BIN (3, |, 2, ^, 1, 3, 2, 3);
ASSERT_BIN (2, |, 0, &&, 2, 1, 1, 2);
ASSERT_BIN (2, &&, 0, |, 2, 1, 2, 1);
ASSERT_BIN (0, &&, 0, ||, 1, 1, 1, 0);
ASSERT_BIN (1, ||, 0, &&, 0, 1, 0, 1);
/* Conditional expressions. */
ASSERT ((1 || 2 ? 3 : 4) == 3);
ASSERT ((1 || (2 ? 3 : 4)) == 1);
/* Assignment expressions. */
p = p = p;
/* Expressions. */
p, p = p;
}
|