aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/testdata/errors.txt
blob: dc9170315a6b577c89dc012120b86467c954d1ab (plain)
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# Copyright 2017 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

# Errors that happen during type checking phase.

meta foobar			### unknown type foobar
meta noextract["foo"]		### wrong number of arguments for type noextract, expect no arguments
meta "foobar"			### unexpected string "foobar", expect type
meta arches["z80"]		### unknown arch z80

#include "something"		### confusing comment faking a directive (rephrase if it's intentional)
#define FOO BAR			### confusing comment faking a directive (rephrase if it's intentional)
# include "something"		### confusing comment faking a directive (rephrase if it's intentional)
#	incdir "dir"		### confusing comment faking a directive (rephrase if it's intentional)

foo$0(x fileoff, y int8, z buffer[in])
foo$1(x "bar")			### unexpected string "bar", expect type
foo$2(x 123, y "bar")		### unexpected int 123, expect type	### unexpected string "bar", expect type
foo$3(x string)			### string can't be syscall argument

resource r0[int32]: 0, 0x1
resource r1[string["foo"]]	### string can't be resource base (int types can)
resource r1[int32]		### type r1 redeclared, previously declared as resource at LOCATION
resource int32[int32]		### resource name int32 conflicts with builtin type
resource fileoff[intptr]	### type fileoff redeclared, previously declared as type alias at builtins

s1 {
	f1	int32
}

s1 {				### type s1 redeclared, previously declared as struct at LOCATION
	f1	int32
	f1	intptr		### duplicate field f1 in struct s1
	parent	int8		### reserved field name parent in struct s1
}

s2 {				### struct s2 has no fields, need at least 1 field
}

int32 {				### struct name int32 conflicts with builtin type
	f1	int32
}

r0 {				### type r0 redeclared, previously declared as resource at LOCATION
	f1	int32
}

u0 [
	f1	int32
	f2	fileoff[int32]
]

u1 [				### union u1 has no fields, need at least 1 field
]

u2 [
	f1	int8
	f1	int16		### duplicate field f1 in union u2
	parent	int32		### reserved field name parent in union u2
]

foo$4(a int8, a int16)		### duplicate argument a in syscall foo$4
foo$4()				### syscall foo$4 redeclared, previously declared at LOCATION
foo()
foo()				### syscall foo redeclared, previously declared at LOCATION
foo$5(a0 int8, a1 int8, a2 int8, a3 int8, a4 int8, a5 int8, a6 int8, a7 int8, a8 int8, a9 int8)	### syscall foo$5 has 10 arguments, allowed maximum is 9
foo$6(parent int8)		### reserved argument name parent in syscall foo$6

f1 = 1
f2 = 1, 2
f2 = 1, 2			### flags f2 redeclared, previously declared at LOCATION
sf1 = "a"
sf2 = "a", "b"
sf2 = "c"			### string flags sf2 redeclared, previously declared at LOCATION

f1000 = 0, 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, f1100	### f1000 has more than 2000 values
f1100 = 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, f1200
f1200 = 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, f1300
f1300 = 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, f1400
f1400 = 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, f1500
f1500 = 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, f1600
f1600 = 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, f1700
f1700 = 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, f1800
f1800 = 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, f1900
f1900 = 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, f2000
f2000 = 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, f2100
f2100 = 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, f2200
f2200 = 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, f2300
f2300 = 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, f2400
f2400 = 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, f2500
f2500 = 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, f2600
f2600 = 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, f2700
f2700 = 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, f2800
f2800 = 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, f2900
f2900 = 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, f3000
f3000 = 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099

nested_flags(a flags[f1000], b flags[f1100])

f110 = 1, 2, 3, 4, f120		### flags f110 used twice or circular dependency on f110
f120 = 10, 11, 12, f130		### flags f120 used twice or circular dependency on f120
f130 = 100, 110, f110		### flags f130 used twice or circular dependency on f130

loop_flags(a flags[f110])

f200 = f300, 200, 201		### flags identifier not at the end in f200 definition
f300 = 300, 301

f210 = "1", "2", "3", f220	### flags f210 used twice or circular dependency on f210
f220 = "10", "11", f230		### flags f220 used twice or circular dependency on f220
f230 = "100", "110", f210	### flags f230 used twice or circular dependency on f230

resource r2[r0]: 2
resource r3[int32:1]		### unexpected ':', only struct fields can be bitfields
resource r4[int32[opt]]		### resource base can't be marked as opt
resource r5[non_existent]	### unknown type non_existent
resource r6[int64be]		### int64be can't be resource base (int types can)
resource r9["foo"]		### unexpected string "foo", expect type

foo$7(a r0, a1 r2[opt])
foo$8(a fileoff[a, b, int8])	### template fileoff needs 0 arguments instead of 3
foo$9(a buffer[inout])
foo$10(a buffer[intout])	### unexpected value intout for direction argument of ptr type, expect [in out inout]
foo$11(a buffer["in"])		### unexpected string "in" for direction argument of ptr type, expect [in out inout]
foo$12(a buffer[10])		### unexpected int 10 for direction argument of ptr type, expect [in out inout]
foo$13(a int32[2:3])
foo$14(a int32[2:2])
foo$17(a ptr[in, int32])
foo$18(a ptr[in, int32[2:3]])
foo$19(a ptr[in, int32[opt]])
foo$20(a ptr)			### wrong number of arguments for type ptr, expect direction, type, [opt]
foo$21(a ptr["foo"])		### wrong number of arguments for type ptr, expect direction, type, [opt]
foo$22(a ptr[in])		### wrong number of arguments for type ptr, expect direction, type, [opt]
foo$23(a ptr[in, s3[in]])	### wrong number of arguments for type s3, expect no arguments
foo$25(a proc[0, "foo"])	### unexpected string "foo" for per-proc values argument of proc type, expect int
foo$26(a flags[no])		### unknown flags no
foo$27(a flags["foo"])		### unexpected string "foo" for flags argument of flags type, expect identifier
foo$28(a ptr[in, string["foo"]], b ptr[in, string["foo", 4]])
foo$30(a ptr[in, string[no]])	### unknown string flags no
foo$31(a int8, b ptr[in, csum[a, inet]])		### wrong number of arguments for type csum, expect csum target, kind, [proto], base type
foo$32(a int8, b ptr[in, csum[a, inet, 1, int32]])	### only pseudo csum can have proto
foo$33(a int8, b ptr[in, csum[a, pseudo, 1, int32]])
foo$34(a int32["foo"])		### unexpected string "foo" for value argument of int32 type, expect identifier or int
foo$35(a ptr[in, s3[opt]])	### s3 can't be marked as opt
foo$36(a const[1:2])		### unexpected ':'
foo$39(a fileoff:1)		### type alias fileoff with ':'
foo$40(a len["a"])		### unexpected string "a" for len target argument of len type, expect identifier
foo$41(a vma[C1:C2])
foo$43(a ptr[in, string[1]])	### unexpected int 1 for literal or flags argument of string type, expect string or identifier
foo$44(a int32) len[a]		### len can't be syscall return
foo$45(a int32) len[b]		### len can't be syscall return
foo$46(a ptr[in, in])		### unknown type in
foo$47(a int32:2)		### unexpected ':', only struct fields can be bitfields
foo$48(a ptr[in, int32:7])	### unexpected ':', only struct fields can be bitfields
foo$49(a ptr[in, array[int32, 0:1]])
foo$52(a intptr, b bitsize[a])
foo$53(a proc[20, 10, opt])
# This must not error yet (consts are not patched).
foo$54(a ptr[in, string["foo", C1]])
foo$55(a int8[opt[int8]])	### opt can't have arguments
foo$56(a void)			### void can't be syscall argument
foo$57(a ptr[in, stringnoz["foo", 10]])	### fixed-size string can't be non-zero-terminated
foo$58(a ptr[in, stringnoz[sf2, 10]])	### fixed-size string can't be non-zero-terminated
foo$59(a s1)			### s1 can't be syscall argument
foo$60() s1			### s1 can't be syscall return
foo$61(a u6)			### u6 can't be syscall argument
foo$62() u6			### u6 can't be syscall return
foo$63(a int32[1[2]])		### value argument has subargs
foo$64(a ptr[in, flags[f1[int32], int32]])	### flags argument has subargs
foo$65(a int32, b len[1])	### unexpected int 1 for len target argument of len type, expect identifier
foo$66(a int32, b len[a:1])	### unexpected int 1 after colon, expect identifier
foo$67(x int32[1:2:3, opt])	### unexpected ':'
foo$68(a int32[15, 2])		### align argument of int32 is not supported unless first argument is a range
foo$69() (foo)			### unknown syscall foo$69 attribute foo
foo$70() ("foo")		### unexpected string "foo", expect attribute
foo$71() (42)			### unexpected int 42, expect attribute
foo$72() (disabled, disabled)	### duplicate syscall foo$72 attribute disabled
foo$73(a int32[int_flags, 2])	### align argument of int32 is not supported unless first argument is a range
foo$74() (int8:1)		### unexpected ':'

opt {				### struct uses reserved name opt
	f1	int32
}

in = 1, 2			### flags uses reserved name in
out = "1", "2"			### string flags uses reserved name out
int_flags = 0, 1, 0xabc, 'x', -11

out [				### union uses reserved name out
	f1	int32
	f2	int8
]

resource inout[int32]		### resource uses reserved name inout

bar()

s3 {
	f1	int8:0		### bitfields of size 0 are not supported
	f2	int8:1
	f3	int8:7
	f4	int8:8
	f5	int8:9		### bitfield of size 9 is too large for base type of size 8
	f6	int32:32
	f7	int32:33	### bitfield of size 33 is too large for base type of size 32
	f8	const[0, int32:C1]	### literal const bitfield sizes are not supported
	f9	const[0]	### wrong number of arguments for type const, expect value, base type
	f10	int8:1:1	### unexpected ':'
} [packed, align[4]]

s5 {
	f1	int8
} [varlen]			### unknown struct s5 attribute varlen

s7 {
	f1	ptr64[in, int32]
}

s8 {
	f1	int8
} [unknown]			### unknown struct s8 attribute unknown

s9 {
	f1	int8
} ["foo"[0]]			### unexpected string "foo", expect attribute

s10 {
	f1	int8
} [packed[0]]			### packed attribute has args

s11 {
	f1	int8
} [size["foo"]]			### unexpected string "foo", expect int

s12 {
	f1	int8
} [size[0:1]]			### size attribute has colon or args

s13 {
	f1	int8
} [size[0[0]]]			### size attribute has colon or args

s14 {
	f1	int8
} [size[1, 2]]			### size attribute is expected to have 1 argument

u3 [
	f1	int8
	f2	int32
] [varlen]

u4 [
	f1	int8
	f2	int32
] [packed]			### unknown union u4 attribute packed

u5 [
	f1	int8:1		### unexpected ':', only struct fields can be bitfields
	f2	int8:2		### unexpected ':', only struct fields can be bitfields
]

u6 [
	f1	int8
	f2	int64
	f3	array[int8]
]

define d0 SOMETHING
define d1 `some C expression`
define d2 some C expression
define d2 SOMETHING		### duplicate define d2
define d3 1

# Type aliases.

type mybool8 int8[0:1]
type mybool16 int16[0:1]
type net_port proc[100, 1, int16be]
resource typeres0[mybool8]
typestruct {
	f1	mybool8
	f2	mybool16
}

type type0 int8
type type0 int8			### type type0 redeclared, previously declared as type alias at LOCATION
resource type0[int32]		### type type0 redeclared, previously declared as type alias at LOCATION
type0 = 0, 1
type type1 type1		### type instantiation loop: type1 -> type1
type type2 int8:4		### unexpected ':', only struct fields can be bitfields
type type3 type2		### unknown type type2
type type4 const[0]		### wrong number of arguments for type const, expect value, base type
type type6 len[foo, int32]	### len can't be type alias target
type type7 len[foo]		### len can't be type alias target
resource typeres1[int32]
type type8 typeres1		### typeres1 can't be type alias target
type int8 int8			### type name int8 conflicts with builtin type
type opt int8			### type uses reserved name opt
type type9 const[0, int8]
type type12 proc[123, 2, int16, opt]
type type13 ptr[in, typestruct13]
type type14 flags[type0, int32]
type type15 const[0, type0]	### unexpected value type0 for base type argument of const type, expect [int8 int16 int32 int64 int16be int32be int64be intptr]
type type16 type17		### type instantiation loop: type16 -> type16
type type17 type18		### unknown type type16
type type18 type16		### unknown type type16
type bool8 int8[0:1]		### type bool8 redeclared, previously declared as type alias at builtins

typestruct11 {
	f	type11		### unknown type type11
}

typestruct12 {
	f	type11		### unknown type type11
}

typestruct13 {
	f1	type9
	f2	type12
}

foo$100(a mybool8, b mybool16)
foo$102(a type2)		### unknown type type2
foo$103(a type0:4)		### type alias type0 with ':'
foo$104(a type0[opt])		### type type0 is not a template
foo$105() type0			### int8 can't be syscall return
foo$106() type6			### unknown type type6
foo$107(a type9, b type12)
foo$108(a flags[type0])
foo$109(a ptr[in, type0])

# Type templates.

type templ0[A, B] const[A, B]
type templ2[A] A[0]
type templ3[A] ptr[in, A]
type templ4[A, A] ptr[in, A]	### duplicate type argument A
type templ5[abc] ptr[in, abc]	### type argument abc must be ALL_CAPS
type templ6[T] ptr[in, T]
type templ7 templ0[templ6, int8]
type templ8[BASE, A] BASE[A]	### type argument BASE must be the last argument
type templ9[BASE] BASE
type templ10[A] templ9[A]
type templ11[VAL, BASE] const[VAL, BASE]

# Note: here 42 is stripped as base type, so const ends up without arguments.
foo$201(a templ1[42])		### wrong number of arguments for type const, expect value
type templ1[A] const[A]

type templ_struct0[A, B] {
	len	len[parent, int16]
	typ	const[A, int16]
	data	B
} [align[4]]

type templ_struct1[STR] {
	f	string[STR, 40]
	f	int32		### duplicate field f in template struct templ_struct1
}

type templ_struct2[A] {
	f	B
}

type templ_base0[TYPE] {
	f1	TYPE
}

type templ_templ0[B] {
	f1	B
}

type templ_templ1[B] {
	f1	B[int16]			### both template parameter B and its usage have sub-arguments
}

templ_templ_use0 {
	f1	templ_templ0[templ_base0]	### template templ_base0 needs 1 arguments instead of 0
	f2	templ_templ1[templ_base0[int32]]
}

foo$200(a templ0[42, int8])
foo$202(a templ0)		### template templ0 needs 2 arguments instead of 0
foo$203(a type0[42])		### type type0 is not a template
foo$204(a ptr[in, templ_struct0[42, int8]])
foo$205(a ptr[in, templ_struct0[int8, int8]])
foo$207(a ptr[in, templ_struct2[1]])		### template argument A is not used
foo$208(a ptr[in, templ9[string["foo"]]])	### unexpected value string for base type argument of templ9 type, expect [int8 int16 int32 int64 int16be int32be int64be intptr]
foo$209(a ptr[in, templ10[templ0[42, int8]]])	### unexpected value templ0 for base type argument of templ9 type, expect [int8 int16 int32 int64 int16be int32be int64be intptr]
foo$210(a ptr[in, templ11[0, 1, int8]])		### template templ11 needs 2 arguments instead of 3
foo$211(a ptr[in, templ9])			### template templ9 needs 1 arguments instead of 0
foo$212(a ptr[in, templ11[1]])			### template templ11 needs 2 arguments instead of 1

type TR[A, B] {
	f TR[A, A[B]]		### type instantiation recursion: TR[X, Y] -> TR[X, X[Y]] -> TR[X, X[X[Y]]] -> TR[X, X[X[X[Y]]]] -> TR[X, X[X[X[X[Y]]]]] -> TR[X, X[X[X[X[X[Y]]]]]] -> TR[X, X[X[X[X[X[X[Y]]]]]]] -> TR[X, X[X[X[X[X[X[X[Y]]]]]]]] -> TR[X, X[X[X[X[X[X[X[X[Y]]]]]]]]] -> TR[X, X[X[X[X[X[X[X[X[X[Y]]]]]]]]]] -> TR[X, X[X[X[X[X[X[X[X[X[X[Y]]]]]]]]]]] -> TR[X, X[X[X[X[X[X[X[X[X[X[X[Y]]]]]]]]]]]]
}
type TU TR[X, Y]

type TT1[A] {
	f0 templ_base0[A]
	f1 TT2[A]
}

type TT2[A] {
	f1 templ_base0[A]
	f2 TT3[A]
}

type TT3[A] {
	f1 templ_base0[A]
	f2 TT1[A]				### type instantiation loop: TT1[int8] -> TT2[int8] -> TT3[int8] -> TT1[int8]
}

foo$213(a ptr[in, TT1[int8]])

foo$glob001(a ptr[in, glob[1]])			### unexpected int 1 for literal or flags argument of glob type, expect string or identifier
foo$glob002(a ptr[in, glob])			### glob only accepts 1 arg, provided 0
foo$glob003(a ptr[in, glob["/sys", 5]])		### glob only accepts 1 arg, provided 2
foo$glob004(a ptr[in, glob["/sys", 5, 2]])	### wrong number of arguments for type glob, expect [literal or flags], [size], [opt]

# fmt

foo$fmt0(a ptr[in, fmt])			### wrong number of arguments for type fmt, expect format, value
foo$fmt1(a fmt[dec, int8])			### fmt can't be syscall argument
foo$fmt2(a ptr[in, fmt[dec, ptr[in, int8]]])	### bad fmt value ptr, expect an integer
foo$fmt3(a ptr[in, fmt[foo, int8]])		### unexpected value foo for format argument of fmt type, expect [dec hex oct]
foo$fmt4(a ptr[in, fmt[dec, int8:3]])		### unexpected ':', only struct fields can be bitfields

struct$fmt0 {
	f0	fmt[dec, int8:3]		### unexpected ':', only struct fields can be bitfields
	f1	int32:-1			### bitfield of size 18446744073709551615 is too large for base type of size 32
}

struct$perfielddir {
	f0	int32	(in, in)	### duplicate arg/field f0 attribute in
	f1	int32	(out, out)	### duplicate arg/field f1 attribute out
	f2	int32	(inout, inout)	### duplicate arg/field f2 attribute inout
	f3	int32	(in, out)	### arg/field has multiple direction attributes
	f4	int32	(in, inout)	### arg/field has multiple direction attributes
	f5	int32	(out, inout)	### arg/field has multiple direction attributes
	f6	int32	(in, out, inout)	### arg/field has multiple direction attributes
}

struct$overlay0 {
	f0	int32	(out_overlay)	### out_overlay attribute must not be specified on the first field
	f1	int32	(out_overlay)	### multiple out_overlay attributes
}

struct$overlay1 {
	f0	int32
	f1	int32	(out_overlay, out_overlay)	### duplicate arg/field f1 attribute out_overlay
	f2	int32	(out_overlay)	### multiple out_overlay attributes
}

struct$overlay2 {
	f0	int32	(in)
	f1	int32	(out_overlay)	### mix of direction and out_overlay attributes is not supported
}

union$overlay0 [
	f0	int32
	f1	int32	(out_overlay)	### unknown arg/field f1 attribute out_overlay
]

union$directions [
	f1	int32	(in)
	f2	int32	(out)	### unknown arg/field f2 attribute out
	f3	int32	(inout)	### unknown arg/field f3 attribute inout
]


compressed$test(a int32) compressed_image	### compressed_image can't be syscall return

define FLAG1 = 1
define FLAG2 = 2

some_nested_flags {
	f1	int32
}

conditional_fields {
	f1	int32
	f2      some_nested_flags (if[value[f1] & FLAG1])
	f3      some_nested_flags (if[value[f1] & FLAG1], if[value[f1] & FLAG1]) ### duplicate arg/field f3 attribute if
	f4      some_nested_flags (if[value & FLAG1]) ### value reference must have only one argument
	f5      some_nested_flags (if[value[f1] & FLAG1, FLAG2]) ### if attribute is expected to have only one argument
	f6      some_nested_flags (if[value[f1, FLAG2] & FLAG1]) ### value reference must have only one argument
	f7      some_nested_flags (if[5])
	f8      some_nested_flags
	f9      some_nested_flags (if[value[f8:f1] & FLAG1])
	f10     some_nested_flags (if[value[f8:f1, A] & FLAG1]) ### value reference must have only one argument
	f11     some_nested_flags (if[value[f8:f1[A]] & FLAG1]) ### value aguments must not have any further arguments
	f12     some_nested_flags (if[f1 == "A"]) ### the token must be either an integer or an identifier
	f13     some_nested_flags (if["ABCD"]) ### if argument must be an expression
	f14     some_nested_flags (if[X[Y]]) ### consts in expressions must not have any arguments
	f15	conditional_fields_union1
	f16	conditional_fields_union2
}

conditional_fields_union1 [
	u1	int32 (if [value[parent:f1] & FLAG1])
	u2	int32 (if [value[parent:f1] & FLAG2]) ### unions must not have if conditions on the last field
]

conditional_fields_union2 [
	u1	int32 (if [value[parent:f1] & FLAG1])
	u2	int32 ### either no fields have conditions or all except the last
	u3	int32
]

invalid_string_attr() (invalid["string"])	### unknown syscall invalid_string_attr attribute invalid