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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.tests.expression@1.0;
interface IExpression {
enum UInt64LiteralTypeGuessing : uint64_t {
noSuffixDec1 = 0,
noSuffixDec2 = 1,
noSuffixDec3 = -1,
noSuffixDec4 = ~0,
noSuffixDec5 = 2147483647,
noSuffixDec6 = -2147483648,
noSuffixDec7 = 2147483648,
noSuffixDec8 = -2147483649,
noSuffixDec9 = ~(-1),
noSuffixHex1 = 0x7fffffff,
noSuffixHex2 = 0x80000000,
noSuffixHex3 = 0xffffffff,
longHex1 = 0xffffffffl,
longHex2 = 0Xfffffffff,
longHex3 = 0x7fffffffffffffff,
longHex4 = 0x8000000000000000,
longHex5 = 0xFFFFFFFFFFFFFFFF,
};
enum SuffixedLiteralTypeGuessing : int32_t {
// Should be all true / ones.
// dec literals are either int32_t or int64_t
decInt32_1 = (~(-1)) == 0,
decInt32_2 = -(1 << 31) == (1 << 31),
decInt64_1 = (~(-1l)) == 0,
decInt64_2 = (~4294967295) != 0,
decInt64_3 = (~4294967295l) != 0,
decInt64_4 = -(1l << 63) == (1l << 63),
// hex literals could be (u)int32_t or (u)int64_t
// 0x7fffffff is int32_t, hence can be negated
hexInt32_1 = -0x7fffffff < 0,
// 0x80000000 is uint32_t; if it were int32_t then -(int32_t)0x80000000 == (int32_t)0x80000000 > 0
hexUInt32_1 = -0x80000000 > 0,
// 0xFFFFFFFF is uint32_t, not int64_t; if it were int64_t then ~(int64_t)0xFFFFFFFF != 0
hexUInt32_2 = ~0xFFFFFFFF == 0,
// 0x7FFFFFFFFFFFFFFF is int64_t, hence can be negated
hexInt64_1 = -0x7FFFFFFFFFFFFFFF < 0,
// 0x8000000000000000 is uint64_t
hexUInt64_1 = -0x8000000000000000 > 0,
};
enum Int64LiteralTypeGuessing : int64_t {
// both treated int32_t, sum = (int64_t)(int32_t)0x80000000 = (int64_t)(-2147483648)
noSuffixDec11 = 1 + 0x7fffffff,
// 0x80000000 is uint32_t, sum = (int64_t)(uint32_t)0x7fffffff = (int64_t)(2147483647)
noSuffixDec12 = 0x80000000 - 1,
};
enum Int32BitShifting : int32_t {
// Shifting for more than 31 bits are undefined. Not tested.
int32BitShift1 = 1 << 31,
};
enum UInt32BitShifting : uint32_t {
uint32BitShift1 = 1 << 31,
};
enum Int64BitShifting : int64_t {
int64BitShift1 = 1l << 63,
};
enum UInt64BitShifting : uint64_t {
uint64BitShift1 = 1l << 63,
};
enum Precedence : int32_t {
literal = 4,
neg = -4,
literalL = -4L,
hex = 0xffffffff,
hexLong = 0xffffffffl,
hexLong2 = 0xfffffffff,
simpleArithmetic = 4 + 1,
simpleArithmetic2 = 2 + 3 - 4,
simpleArithmetic3 = 2 - 3 + 4,
simpleBoolExpr = 1 == 4,
simpleLogical = 1 && 1,
simpleLogical2 = 1 || 1 && 0, // && higher than ||
simpleComp = 1 < 2,
boolExpr1 = !((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
boolExpr = 1 == 7 && !((3 != 4 || (2 < 3 <= 3 > 4)) >= 0),
simpleBitShift = 1 << 2,
simpleBitShift2 = 4 >> 1,
simpleBitShiftNeg = 4 << -1,
simpleArithmeticRightShift = 1 << 31 >> 31,
simpleBitExpr = 1 | 16 >> 2,
simpleBitExpr2 = 0x0f ^ 0x33 & 0x99, // & higher than ^
bitExpr = ~42 & (1 << 3 | 16 >> 2) ^ 7,
arithmeticExpr = 2 + 3 - 4 * -7 / (10 % 3),
messyExpr = 2 + (-3&4 / 7),
paranExpr = (((((1 + 1))))),
ternary = 1?2:3,
ternary2 = 1&&2?3:4,
complicatedTernary2 = 1 - 1 && 2 + 3 || 5 ? 7 * 8 : -3,
};
enum OperatorSanityCheck : int32_t {
// Should be all true / ones.
plus = (1 + 2) == 3,
minus = (8 - 9) == -1,
product = (9 * 9) == 81,
division = (29 / 3) == 9,
mod = (29 % 3) == 2,
bit_or = (0xC0010000 | 0xF00D) == (0xC001F00D),
bit_or2 = (10 | 6) == 14,
bit_and = (10 & 6) == 2,
bit_xor = (10 ^ 6) == 12,
lt1 = 6 < 10,
lt2 = (10 < 10) == 0,
gt1 = (6 > 10) == 0,
gt2 = (10 > 10) == 0,
gte1 = 19 >= 10,
gte2 = 10 >= 10,
lte1 = 5 <= 10,
lte2 = (19 <= 10) == 0,
ne1 = 19 != 10,
ne2 = (10 != 10) == 0,
lshift = (22 << 1) == 44,
rshift = (11 >> 1) == 5,
logor1 = (1 || 0) == 1,
logor2 = (1 || 1) == 1,
logor3 = (0 || 0) == 0,
logor4 = (0 || 1) == 1,
logand1 = (1 && 0) == 0,
logand2 = (1 && 1) == 1,
logand3 = (0 && 0) == 0,
logand4 = (0 && 1) == 0,
};
// Tests for enum tags
enum NoElements : uint32_t {};
enum OneElement : uint32_t {A};
enum TwoElement : uint32_t {A,B};
enum TwoCollidingElements : uint32_t {A=1,B=1};
enum ThreeFromInheritance : TwoElement {C};
enum ThreeFromDoubleInheritance : ThreeFromInheritance {};
enum ThreeCollidingFromInheritance : TwoCollidingElements {C};
enum EnumTagTest : uint32_t {
a = NoElements#len == 0,
b = OneElement#len == 1,
c = TwoElement#len == 2,
d = TwoCollidingElements#len == 2,
e = ThreeFromInheritance#len == 3,
f = ThreeFromDoubleInheritance#len == 3,
g = ThreeCollidingFromInheritance#len == 3,
// fine to reference current enum as well
h = EnumTagTest#len == 8,
};
enum Grayscale : int8_t {
WHITE = 126,
GRAY, // 127
DARK_GRAY, // -128
BLACK // -127
};
enum Color : Grayscale {
RED, // -126
RUBY = 0,
GREEN, // 1
BLUE = 5,
CYAN, // 6
ORANGE, // 7
ROSE = WHITE,
};
enum Foo1 : int8_t {};
enum Foo2 : Foo1 {};
enum Foo3 : Foo2 {
BAR1, // 0
BAR2 = 10,
};
enum Foo4 : Foo3 {
BAR3, // 11
BAR4 = BAR2 + BAR3 // 21
};
enum Number : uint8_t {
MAX = 255,
MAX_PLUS_1, // 0
MAX_PLUS_2 // 1
};
enum Constants : int32_t {
CONST_FOO,
CONST_BAR = 70,
MAX_ARRAY_SIZE = 20,
MAX_ARRAY_SIZE2,
MAX_ARRAY_SIZE3 = MAX_ARRAY_SIZE + MAX_ARRAY_SIZE,
MY_INT32_MAX_MINUS_1 = 0x7FFFFFFE,
MY_INT32_MAX, // 0x7FFFFFFF
MY_INT32_MIN, // 0x80000000
MY_INT32_MIN_PLUS_1, // 0x80000001
};
foo1(int32_t[Constants:CONST_FOO + 1] array);
foo2(int32_t[5 + 8] array);
foo3(int32_t[Constants:MAX_ARRAY_SIZE] array);
};
|