github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/compiler/testdata/errors.txt (about)

     1  # Copyright 2017 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  # Errors that happen during type checking phase.
     5  
     6  meta foobar			### unknown type foobar
     7  meta noextract["foo"]		### wrong number of arguments for type noextract, expect no arguments
     8  meta "foobar"			### unexpected string "foobar", expect type
     9  meta arches["z80"]		### unknown arch z80
    10  
    11  #include "something"		### confusing comment faking a directive (rephrase if it's intentional)
    12  #define FOO BAR			### confusing comment faking a directive (rephrase if it's intentional)
    13  # include "something"		### confusing comment faking a directive (rephrase if it's intentional)
    14  #	incdir "dir"		### confusing comment faking a directive (rephrase if it's intentional)
    15  
    16  foo$0(x fileoff, y int8, z buffer[in])
    17  foo$1(x "bar")			### unexpected string "bar", expect type
    18  foo$2(x 123, y "bar")		### unexpected int 123, expect type	### unexpected string "bar", expect type
    19  foo$3(x string)			### string can't be syscall argument
    20  
    21  resource r0[int32]: 0, 0x1
    22  resource r1[string["foo"]]	### string can't be resource base (int types can)
    23  resource r1[int32]		### type r1 redeclared, previously declared as resource at LOCATION
    24  resource int32[int32]		### resource name int32 conflicts with builtin type
    25  resource fileoff[intptr]	### type fileoff redeclared, previously declared as type alias at builtins
    26  
    27  s1 {
    28  	f1	int32
    29  }
    30  
    31  s1 {				### type s1 redeclared, previously declared as struct at LOCATION
    32  	f1	int32
    33  	f1	intptr		### duplicate field f1 in struct s1
    34  	parent	int8		### reserved field name parent in struct s1
    35  }
    36  
    37  s2 {				### struct s2 has no fields, need at least 1 field
    38  }
    39  
    40  int32 {				### struct name int32 conflicts with builtin type
    41  	f1	int32
    42  }
    43  
    44  r0 {				### type r0 redeclared, previously declared as resource at LOCATION
    45  	f1	int32
    46  }
    47  
    48  u0 [
    49  	f1	int32
    50  	f2	fileoff[int32]
    51  ]
    52  
    53  u1 [				### union u1 has no fields, need at least 1 field
    54  ]
    55  
    56  u2 [
    57  	f1	int8
    58  	f1	int16		### duplicate field f1 in union u2
    59  	parent	int32		### reserved field name parent in union u2
    60  ]
    61  
    62  foo$4(a int8, a int16)		### duplicate argument a in syscall foo$4
    63  foo$4()				### syscall foo$4 redeclared, previously declared at LOCATION
    64  foo()
    65  foo()				### syscall foo redeclared, previously declared at LOCATION
    66  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
    67  foo$6(parent int8)		### reserved argument name parent in syscall foo$6
    68  
    69  f1 = 1
    70  f2 = 1, 2
    71  f2 = 1, 2			### flags f2 redeclared, previously declared at LOCATION
    72  sf1 = "a"
    73  sf2 = "a", "b"
    74  sf2 = "c"			### string flags sf2 redeclared, previously declared at LOCATION
    75  
    76  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
    77  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
    78  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
    79  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
    80  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
    81  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
    82  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
    83  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
    84  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
    85  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
    86  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
    87  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
    88  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
    89  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
    90  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
    91  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
    92  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
    93  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
    94  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
    95  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
    96  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
    97  
    98  nested_flags(a flags[f1000], b flags[f1100])
    99  
   100  f110 = 1, 2, 3, 4, f120		### flags f110 used twice or circular dependency on f110
   101  f120 = 10, 11, 12, f130		### flags f120 used twice or circular dependency on f120
   102  f130 = 100, 110, f110		### flags f130 used twice or circular dependency on f130
   103  
   104  loop_flags(a flags[f110])
   105  
   106  f200 = f300, 200, 201		### flags identifier not at the end in f200 definition
   107  f300 = 300, 301
   108  
   109  f210 = "1", "2", "3", f220	### flags f210 used twice or circular dependency on f210
   110  f220 = "10", "11", f230		### flags f220 used twice or circular dependency on f220
   111  f230 = "100", "110", f210	### flags f230 used twice or circular dependency on f230
   112  
   113  resource r2[r0]: 2
   114  resource r3[int32:1]		### unexpected ':', only struct fields can be bitfields
   115  resource r4[int32[opt]]		### resource base can't be marked as opt
   116  resource r5[non_existent]	### unknown type non_existent
   117  resource r6[int64be]		### int64be can't be resource base (int types can)
   118  resource r9["foo"]		### unexpected string "foo", expect type
   119  
   120  foo$7(a r0, a1 r2[opt])
   121  foo$8(a fileoff[a, b, int8])	### template fileoff needs 0 arguments instead of 3
   122  foo$9(a buffer[inout])
   123  foo$10(a buffer[intout])	### unexpected value intout for direction argument of ptr type, expect [in out inout]
   124  foo$11(a buffer["in"])		### unexpected string "in" for direction argument of ptr type, expect [in out inout]
   125  foo$12(a buffer[10])		### unexpected int 10 for direction argument of ptr type, expect [in out inout]
   126  foo$13(a int32[2:3])
   127  foo$14(a int32[2:2])
   128  foo$17(a ptr[in, int32])
   129  foo$18(a ptr[in, int32[2:3]])
   130  foo$19(a ptr[in, int32[opt]])
   131  foo$20(a ptr)			### wrong number of arguments for type ptr, expect direction, type, [opt]
   132  foo$21(a ptr["foo"])		### wrong number of arguments for type ptr, expect direction, type, [opt]
   133  foo$22(a ptr[in])		### wrong number of arguments for type ptr, expect direction, type, [opt]
   134  foo$23(a ptr[in, s3[in]])	### wrong number of arguments for type s3, expect no arguments
   135  foo$25(a proc[0, "foo"])	### unexpected string "foo" for per-proc values argument of proc type, expect int
   136  foo$26(a flags[no])		### unknown flags no
   137  foo$27(a flags["foo"])		### unexpected string "foo" for flags argument of flags type, expect identifier
   138  foo$28(a ptr[in, string["foo"]], b ptr[in, string["foo", 4]])
   139  foo$30(a ptr[in, string[no]])	### unknown string flags no
   140  foo$31(a int8, b ptr[in, csum[a, inet]])		### wrong number of arguments for type csum, expect csum target, kind, [proto], base type
   141  foo$32(a int8, b ptr[in, csum[a, inet, 1, int32]])	### only pseudo csum can have proto
   142  foo$33(a int8, b ptr[in, csum[a, pseudo, 1, int32]])
   143  foo$34(a int32["foo"])		### unexpected string "foo" for value argument of int32 type, expect identifier or int
   144  foo$35(a ptr[in, s3[opt]])	### s3 can't be marked as opt
   145  foo$36(a const[1:2])		### unexpected ':'
   146  foo$39(a fileoff:1)		### type alias fileoff with ':'
   147  foo$40(a len["a"])		### unexpected string "a" for len target argument of len type, expect identifier
   148  foo$41(a vma[C1:C2])
   149  foo$43(a ptr[in, string[1]])	### unexpected int 1 for literal or flags argument of string type, expect string or identifier
   150  foo$44(a int32) len[a]		### len can't be syscall return
   151  foo$45(a int32) len[b]		### len can't be syscall return
   152  foo$46(a ptr[in, in])		### unknown type in
   153  foo$47(a int32:2)		### unexpected ':', only struct fields can be bitfields
   154  foo$48(a ptr[in, int32:7])	### unexpected ':', only struct fields can be bitfields
   155  foo$49(a ptr[in, array[int32, 0:1]])
   156  foo$52(a intptr, b bitsize[a])
   157  foo$53(a proc[20, 10, opt])
   158  # This must not error yet (consts are not patched).
   159  foo$54(a ptr[in, string["foo", C1]])
   160  foo$55(a int8[opt[int8]])	### opt can't have arguments
   161  foo$56(a void)			### void can't be syscall argument
   162  foo$57(a ptr[in, stringnoz["foo", 10]])	### fixed-size string can't be non-zero-terminated
   163  foo$58(a ptr[in, stringnoz[sf2, 10]])	### fixed-size string can't be non-zero-terminated
   164  foo$59(a s1)			### s1 can't be syscall argument
   165  foo$60() s1			### s1 can't be syscall return
   166  foo$61(a u6)			### u6 can't be syscall argument
   167  foo$62() u6			### u6 can't be syscall return
   168  foo$63(a int32[1[2]])		### value argument has subargs
   169  foo$64(a ptr[in, flags[f1[int32], int32]])	### flags argument has subargs
   170  foo$65(a int32, b len[1])	### unexpected int 1 for len target argument of len type, expect identifier
   171  foo$66(a int32, b len[a:1])	### unexpected int 1 after colon, expect identifier
   172  foo$67(x int32[1:2:3, opt])	### unexpected ':'
   173  foo$68(a int32[15, 2])		### align argument of int32 is not supported unless first argument is a range
   174  foo$69() (foo)			### unknown syscall foo$69 attribute foo
   175  foo$70() ("foo")		### unexpected string "foo", expect attribute
   176  foo$71() (42)			### unexpected int 42, expect attribute
   177  foo$72() (disabled, disabled)	### duplicate syscall foo$72 attribute disabled
   178  foo$73(a int32[int_flags, 2])	### align argument of int32 is not supported unless first argument is a range
   179  foo$74() (int8:1)		### unexpected ':'
   180  
   181  opt {				### struct uses reserved name opt
   182  	f1	int32
   183  }
   184  
   185  in = 1, 2			### flags uses reserved name in
   186  out = "1", "2"			### string flags uses reserved name out
   187  int_flags = 0, 1, 0xabc, 'x', -11
   188  
   189  out [				### union uses reserved name out
   190  	f1	int32
   191  	f2	int8
   192  ]
   193  
   194  resource inout[int32]		### resource uses reserved name inout
   195  
   196  bar()
   197  
   198  s3 {
   199  	f1	int8:0		### bitfields of size 0 are not supported
   200  	f2	int8:1
   201  	f3	int8:7
   202  	f4	int8:8
   203  	f5	int8:9		### bitfield of size 9 is too large for base type of size 8
   204  	f6	int32:32
   205  	f7	int32:33	### bitfield of size 33 is too large for base type of size 32
   206  	f8	const[0, int32:C1]	### literal const bitfield sizes are not supported
   207  	f9	const[0]	### wrong number of arguments for type const, expect value, base type
   208  	f10	int8:1:1	### unexpected ':'
   209  } [packed, align[4]]
   210  
   211  s5 {
   212  	f1	int8
   213  } [varlen]			### unknown struct s5 attribute varlen
   214  
   215  s7 {
   216  	f1	ptr64[in, int32]
   217  }
   218  
   219  s8 {
   220  	f1	int8
   221  } [unknown]			### unknown struct s8 attribute unknown
   222  
   223  s9 {
   224  	f1	int8
   225  } ["foo"[0]]			### unexpected string "foo", expect attribute
   226  
   227  s10 {
   228  	f1	int8
   229  } [packed[0]]			### packed attribute has args
   230  
   231  s11 {
   232  	f1	int8
   233  } [size["foo"]]			### unexpected string "foo", expect int
   234  
   235  s12 {
   236  	f1	int8
   237  } [size[0:1]]			### size attribute has colon or args
   238  
   239  s13 {
   240  	f1	int8
   241  } [size[0[0]]]			### size attribute has colon or args
   242  
   243  s14 {
   244  	f1	int8
   245  } [size[1, 2]]			### size attribute is expected to have 1 argument
   246  
   247  u3 [
   248  	f1	int8
   249  	f2	int32
   250  ] [varlen]
   251  
   252  u4 [
   253  	f1	int8
   254  	f2	int32
   255  ] [packed]			### unknown union u4 attribute packed
   256  
   257  u5 [
   258  	f1	int8:1		### unexpected ':', only struct fields can be bitfields
   259  	f2	int8:2		### unexpected ':', only struct fields can be bitfields
   260  ]
   261  
   262  u6 [
   263  	f1	int8
   264  	f2	int64
   265  	f3	array[int8]
   266  ]
   267  
   268  define d0 SOMETHING
   269  define d1 `some C expression`
   270  define d2 some C expression
   271  define d2 SOMETHING		### duplicate define d2
   272  define d3 1
   273  
   274  # Type aliases.
   275  
   276  type mybool8 int8[0:1]
   277  type mybool16 int16[0:1]
   278  type net_port proc[100, 1, int16be]
   279  resource typeres0[mybool8]
   280  typestruct {
   281  	f1	mybool8
   282  	f2	mybool16
   283  }
   284  
   285  type type0 int8
   286  type type0 int8			### type type0 redeclared, previously declared as type alias at LOCATION
   287  resource type0[int32]		### type type0 redeclared, previously declared as type alias at LOCATION
   288  type0 = 0, 1
   289  type type1 type1		### type instantiation loop: type1 -> type1
   290  type type2 int8:4		### unexpected ':', only struct fields can be bitfields
   291  type type3 type2		### unknown type type2
   292  type type4 const[0]		### wrong number of arguments for type const, expect value, base type
   293  type type6 len[foo, int32]	### len can't be type alias target
   294  type type7 len[foo]		### len can't be type alias target
   295  resource typeres1[int32]
   296  type type8 typeres1		### typeres1 can't be type alias target
   297  type int8 int8			### type name int8 conflicts with builtin type
   298  type opt int8			### type uses reserved name opt
   299  type type9 const[0, int8]
   300  type type12 proc[123, 2, int16, opt]
   301  type type13 ptr[in, typestruct13]
   302  type type14 flags[type0, int32]
   303  type type15 const[0, type0]	### unexpected value type0 for base type argument of const type, expect [int8 int16 int32 int64 int16be int32be int64be intptr]
   304  type type16 type17		### type instantiation loop: type16 -> type16
   305  type type17 type18		### unknown type type16
   306  type type18 type16		### unknown type type16
   307  type bool8 int8[0:1]		### type bool8 redeclared, previously declared as type alias at builtins
   308  
   309  typestruct11 {
   310  	f	type11		### unknown type type11
   311  }
   312  
   313  typestruct12 {
   314  	f	type11		### unknown type type11
   315  }
   316  
   317  typestruct13 {
   318  	f1	type9
   319  	f2	type12
   320  }
   321  
   322  foo$100(a mybool8, b mybool16)
   323  foo$102(a type2)		### unknown type type2
   324  foo$103(a type0:4)		### type alias type0 with ':'
   325  foo$104(a type0[opt])		### type type0 is not a template
   326  foo$105() type0			### int8 can't be syscall return
   327  foo$106() type6			### unknown type type6
   328  foo$107(a type9, b type12)
   329  foo$108(a flags[type0])
   330  foo$109(a ptr[in, type0])
   331  
   332  # Type templates.
   333  
   334  type templ0[A, B] const[A, B]
   335  type templ2[A] A[0]
   336  type templ3[A] ptr[in, A]
   337  type templ4[A, A] ptr[in, A]	### duplicate type argument A
   338  type templ5[abc] ptr[in, abc]	### type argument abc must be ALL_CAPS
   339  type templ6[T] ptr[in, T]
   340  type templ7 templ0[templ6, int8]
   341  type templ8[BASE, A] BASE[A]	### type argument BASE must be the last argument
   342  type templ9[BASE] BASE
   343  type templ10[A] templ9[A]
   344  type templ11[VAL, BASE] const[VAL, BASE]
   345  
   346  # Note: here 42 is stripped as base type, so const ends up without arguments.
   347  foo$201(a templ1[42])		### wrong number of arguments for type const, expect value
   348  type templ1[A] const[A]
   349  
   350  type templ_struct0[A, B] {
   351  	len	len[parent, int16]
   352  	typ	const[A, int16]
   353  	data	B
   354  } [align[4]]
   355  
   356  type templ_struct1[STR] {
   357  	f	string[STR, 40]
   358  	f	int32		### duplicate field f in template struct templ_struct1
   359  }
   360  
   361  type templ_struct2[A] {
   362  	f	B
   363  }
   364  
   365  type templ_base0[TYPE] {
   366  	f1	TYPE
   367  }
   368  
   369  type templ_templ0[B] {
   370  	f1	B
   371  }
   372  
   373  type templ_templ1[B] {
   374  	f1	B[int16]			### both template parameter B and its usage have sub-arguments
   375  }
   376  
   377  templ_templ_use0 {
   378  	f1	templ_templ0[templ_base0]	### template templ_base0 needs 1 arguments instead of 0
   379  	f2	templ_templ1[templ_base0[int32]]
   380  }
   381  
   382  foo$200(a templ0[42, int8])
   383  foo$202(a templ0)		### template templ0 needs 2 arguments instead of 0
   384  foo$203(a type0[42])		### type type0 is not a template
   385  foo$204(a ptr[in, templ_struct0[42, int8]])
   386  foo$205(a ptr[in, templ_struct0[int8, int8]])
   387  foo$207(a ptr[in, templ_struct2[1]])		### template argument A is not used
   388  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]
   389  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]
   390  foo$210(a ptr[in, templ11[0, 1, int8]])		### template templ11 needs 2 arguments instead of 3
   391  foo$211(a ptr[in, templ9])			### template templ9 needs 1 arguments instead of 0
   392  foo$212(a ptr[in, templ11[1]])			### template templ11 needs 2 arguments instead of 1
   393  
   394  type TR[A, B] {
   395  	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]]]]]]]]]]]]
   396  }
   397  type TU TR[X, Y]
   398  
   399  type TT1[A] {
   400  	f0 templ_base0[A]
   401  	f1 TT2[A]
   402  }
   403  
   404  type TT2[A] {
   405  	f1 templ_base0[A]
   406  	f2 TT3[A]
   407  }
   408  
   409  type TT3[A] {
   410  	f1 templ_base0[A]
   411  	f2 TT1[A]				### type instantiation loop: TT1[int8] -> TT2[int8] -> TT3[int8] -> TT1[int8]
   412  }
   413  
   414  foo$213(a ptr[in, TT1[int8]])
   415  
   416  foo$glob001(a ptr[in, glob[1]])			### unexpected int 1 for literal or flags argument of glob type, expect string or identifier
   417  foo$glob002(a ptr[in, glob])			### glob only accepts 1 arg, provided 0
   418  foo$glob003(a ptr[in, glob["/sys", 5]])		### glob only accepts 1 arg, provided 2
   419  foo$glob004(a ptr[in, glob["/sys", 5, 2]])	### wrong number of arguments for type glob, expect [literal or flags], [size], [opt]
   420  
   421  # fmt
   422  
   423  foo$fmt0(a ptr[in, fmt])			### wrong number of arguments for type fmt, expect format, value
   424  foo$fmt1(a fmt[dec, int8])			### fmt can't be syscall argument
   425  foo$fmt2(a ptr[in, fmt[dec, ptr[in, int8]]])	### bad fmt value ptr, expect an integer
   426  foo$fmt3(a ptr[in, fmt[foo, int8]])		### unexpected value foo for format argument of fmt type, expect [dec hex oct]
   427  foo$fmt4(a ptr[in, fmt[dec, int8:3]])		### unexpected ':', only struct fields can be bitfields
   428  
   429  struct$fmt0 {
   430  	f0	fmt[dec, int8:3]		### unexpected ':', only struct fields can be bitfields
   431  	f1	int32:-1			### bitfield of size 18446744073709551615 is too large for base type of size 32
   432  }
   433  
   434  struct$perfielddir {
   435  	f0	int32	(in, in)	### duplicate arg/field f0 attribute in
   436  	f1	int32	(out, out)	### duplicate arg/field f1 attribute out
   437  	f2	int32	(inout, inout)	### duplicate arg/field f2 attribute inout
   438  	f3	int32	(in, out)	### arg/field has multiple direction attributes
   439  	f4	int32	(in, inout)	### arg/field has multiple direction attributes
   440  	f5	int32	(out, inout)	### arg/field has multiple direction attributes
   441  	f6	int32	(in, out, inout)	### arg/field has multiple direction attributes
   442  }
   443  
   444  struct$overlay0 {
   445  	f0	int32	(out_overlay)	### out_overlay attribute must not be specified on the first field
   446  	f1	int32	(out_overlay)	### multiple out_overlay attributes
   447  }
   448  
   449  struct$overlay1 {
   450  	f0	int32
   451  	f1	int32	(out_overlay, out_overlay)	### duplicate arg/field f1 attribute out_overlay
   452  	f2	int32	(out_overlay)	### multiple out_overlay attributes
   453  }
   454  
   455  struct$overlay2 {
   456  	f0	int32	(in)
   457  	f1	int32	(out_overlay)	### mix of direction and out_overlay attributes is not supported
   458  }
   459  
   460  union$overlay0 [
   461  	f0	int32
   462  	f1	int32	(out_overlay)	### unknown arg/field f1 attribute out_overlay
   463  ]
   464  
   465  union$directions [
   466  	f1	int32	(in)
   467  	f2	int32	(out)	### unknown arg/field f2 attribute out
   468  	f3	int32	(inout)	### unknown arg/field f3 attribute inout
   469  ]
   470  
   471  
   472  compressed$test(a int32) compressed_image	### compressed_image can't be syscall return
   473  
   474  define FLAG1 = 1
   475  define FLAG2 = 2
   476  
   477  some_nested_flags {
   478  	f1	int32
   479  }
   480  
   481  conditional_fields {
   482  	f1	int32
   483  	f2      some_nested_flags (if[value[f1] & FLAG1])
   484  	f3      some_nested_flags (if[value[f1] & FLAG1], if[value[f1] & FLAG1]) ### duplicate arg/field f3 attribute if
   485  	f4      some_nested_flags (if[value & FLAG1]) ### value reference must have only one argument
   486  	f5      some_nested_flags (if[value[f1] & FLAG1, FLAG2]) ### if attribute is expected to have only one argument
   487  	f6      some_nested_flags (if[value[f1, FLAG2] & FLAG1]) ### value reference must have only one argument
   488  	f7      some_nested_flags (if[5])
   489  	f8      some_nested_flags
   490  	f9      some_nested_flags (if[value[f8:f1] & FLAG1])
   491  	f10     some_nested_flags (if[value[f8:f1, A] & FLAG1]) ### value reference must have only one argument
   492  	f11     some_nested_flags (if[value[f8:f1[A]] & FLAG1]) ### value aguments must not have any further arguments
   493  	f12     some_nested_flags (if[f1 == "A"]) ### the token must be either an integer or an identifier
   494  	f13     some_nested_flags (if["ABCD"]) ### if argument must be an expression
   495  	f14     some_nested_flags (if[X[Y]]) ### consts in expressions must not have any arguments
   496  	f15	conditional_fields_union1
   497  	f16	conditional_fields_union2
   498  }
   499  
   500  conditional_fields_union1 [
   501  	u1	int32 (if [value[parent:f1] & FLAG1])
   502  	u2	int32 (if [value[parent:f1] & FLAG2]) ### unions must not have if conditions on the last field
   503  ]
   504  
   505  conditional_fields_union2 [
   506  	u1	int32 (if [value[parent:f1] & FLAG1])
   507  	u2	int32 ### either no fields have conditions or all except the last
   508  	u3	int32
   509  ]