From 01a8227eea2b25e522d4a19290db07c097c8b6dd Mon Sep 17 00:00:00 2001 From: evans1629 Date: Sun, 17 Mar 2002 19:19:54 +0000 Subject: [PATCH] Added htmlfileformat flag. --- src/Headers/idDecl.h | 16 +- src/Headers/llerror.h | 20 +- src/Makefile.am | 1 - src/cgrammar.c.der | 117 +++++----- src/cgrammar.y | 3 +- src/clabstract.c | 487 ++++++++++++++++++++++-------------------- src/context.c | 2 +- src/ctype.c | 8 +- src/fileloc.c | 63 ++++-- src/flags.def | 7 + src/llerror.c | 27 ++- src/qtype.c | 2 + 12 files changed, 417 insertions(+), 336 deletions(-) diff --git a/src/Headers/idDecl.h b/src/Headers/idDecl.h index 83cda5a..5702c08 100644 --- a/src/Headers/idDecl.h +++ b/src/Headers/idDecl.h @@ -31,15 +31,15 @@ extern /*@only@*/ idDecl idDecl_createClauses (/*@only@*/ cstring p_s, /*@only@*/ qtype p_t, /*@only@*/ functionClauseList p_clauses); -extern /*@only@*/ cstring idDecl_unparse (idDecl p_d); -extern /*@only@*/ cstring idDecl_unparseC (idDecl p_d); -extern /*@exposed@*/ qtype idDecl_getTyp (idDecl p_d); -extern void idDecl_setTyp (idDecl p_d, /*@only@*/ qtype p_c); -extern idDecl idDecl_expectFunction (/*@returned@*/ idDecl p_d); +extern /*@only@*/ cstring idDecl_unparse (idDecl p_d) /*@*/ ; +extern /*@only@*/ cstring idDecl_unparseC (idDecl p_d) /*@*/ ; +extern /*@exposed@*/ qtype idDecl_getTyp (idDecl p_d) /*@*/ ; +extern void idDecl_setTyp (idDecl p_d, /*@only@*/ qtype p_c) /*@modifies p_d@*/ ; +extern idDecl idDecl_expectFunction (/*@returned@*/ idDecl p_d) /*@*/ ; extern void idDecl_notExpectingFunction (idDecl p_d) /*@modifies p_d@*/ ; -extern idDecl idDecl_replaceCtype (/*@returned@*/ idDecl p_d, ctype p_c); -extern idDecl idDecl_fixBase (/*@returned@*/ idDecl p_t, qtype p_b); -extern idDecl idDecl_fixParamBase (/*@returned@*/ idDecl p_t, qtype p_b); +extern idDecl idDecl_replaceCtype (/*@returned@*/ idDecl p_d, ctype p_c) /*@modifies p_d@*/ ; +extern idDecl idDecl_fixBase (/*@returned@*/ idDecl p_t, qtype p_b) /*@modifies p_t@*/ ; +extern idDecl idDecl_fixParamBase (/*@returned@*/ idDecl p_t, qtype p_b) /*@modifies p_t@*/ ; extern void idDecl_addClauses (idDecl p_d, /*@only@*/ functionClauseList) /*@modifies p_d@*/ ; diff --git a/src/Headers/llerror.h b/src/Headers/llerror.h index cf21295..2e6d33e 100644 --- a/src/Headers/llerror.h +++ b/src/Headers/llerror.h @@ -121,17 +121,31 @@ extern void llerror (flagcode p_o, /*@only@*/ cstring p_s) extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_warningstream@*/ ; +extern /*@noreturn@*/ /*@private@*/ +void xllfatalerror (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s) + /*@modifies g_errorstream@*/ ; + extern /*@noreturn@*/ void llfatalerror (/*@only@*/ cstring p_s) /*@modifies g_errorstream@*/ ; +# define llfatalerror(p_s) xllfatalerror (__FILE__, __LINE__, p_s) -extern /*@noreturn@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s) +extern /*@noreturn@*/ /*@private@*/ void +xllfatalerrorLoc (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s) /*@globals g_currentloc@*/ /*@modifies g_errorstream@*/ ; -extern void llparseerror (/*@only@*/ cstring p_s) - /*@globals g_errorstream, g_currentloc@*/ +extern /*@noreturn@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s) + /*@globals g_currentloc@*/ /*@modifies g_errorstream@*/ ; +# define llfatalerrorLoc(p_s) xllfatalerrorLoc (__FILE__, __LINE__, p_s) + +extern /*@private@*/ void + xllparseerror (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s) + /*@modifies g_warningstream@*/ ; +extern void llparseerror (/*@only@*/ cstring p_s) + /*@globals g_currentloc@*/ ; +# define llparseerror(p_s) xllparseerror (__FILE__, __LINE__, p_s) # ifndef NOLCL extern /*@noreturn@*/ void lclplainfatalerror (/*@only@*/ cstring p_msg) /*@modifies g_warningstream@*/ ; extern /*@noreturn@*/ void lclfatalbug (/*@temp@*/ char *p_msg) /*@modifies g_warningstream@*/ ; diff --git a/src/Makefile.am b/src/Makefile.am index 72c7f52..55b8539 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -90,7 +90,6 @@ LCLLISTSRC = initDeclNodeList.c sortList.c declaratorInvNodeList.c \ varDeclarationNodeList.c varNodeList.c quantifierNodeList.c \ replaceNodeList.c importNodeList.c - HEADERSRC = Headers/abstBodyNode.h Headers/ltokenList.h \ Headers/abstract.h Headers/macrocache.h \ Headers/abstractNode.h Headers/mapping.h \ diff --git a/src/cgrammar.c.der b/src/cgrammar.c.der index 19fa926..01c2152 100644 --- a/src/cgrammar.c.der +++ b/src/cgrammar.c.der @@ -731,63 +731,63 @@ static const short yyrline[] = { 0, 630, 638, 640, 644, 647, 648, 651, 654, 660, 664, 665, 668, 671, 672, 675, 676, 677, 680, 681, 682, 683, 684, 687, 688, 689, 690, 691, 694, 695, 698, - 704, 708, 710, 714, 715, 717, 724, 734, 735, 738, - 739, 740, 741, 742, 743, 744, 745, 749, 750, 754, - 755, 758, 760, 762, 763, 764, 765, 766, 768, 772, - 773, 776, 780, 792, 793, 794, 795, 796, 797, 798, - 799, 803, 804, 805, 806, 807, 808, 809, 810, 811, - 812, 816, 817, 820, 821, 822, 823, 824, 825, 826, - 827, 828, 829, 830, 833, 834, 837, 841, 842, 845, - 846, 847, 848, 851, 852, 856, 857, 858, 859, 862, - 863, 864, 867, 868, 869, 872, 873, 874, 875, 876, - 879, 880, 881, 884, 885, 888, 889, 893, 894, 897, - 898, 903, 909, 910, 916, 922, 923, 923, 925, 928, - 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, - 939, 942, 943, 946, 947, 950, 955, 956, 957, 960, - 974, 979, 985, 987, 993, 998, 998, 1002, 1003, 1005, - 1006, 1009, 1012, 1015, 1018, 1019, 1022, 1023, 1026, 1027, - 1028, 1029, 1036, 1037, 1041, 1042, 1045, 1046, 1049, 1051, - 1060, 1061, 1062, 1063, 1064, 1067, 1070, 1076, 1085, 1088, - 1091, 1098, 1105, 1111, 1136, 1137, 1140, 1141, 1142, 1143, - 1144, 1147, 1148, 1149, 1150, 1153, 1154, 1155, 1156, 1157, - 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, - 1168, 1169, 1173, 1174, 1177, 1178, 1181, 1182, 1185, 1186, - 1187, 1188, 1191, 1192, 1193, 1194, 1195, 1196, 1199, 1200, - 1201, 1202, 1205, 1206, 1207, 1208, 1211, 1212, 1213, 1214, - 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1228, 1229, 1230, - 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, - 1241, 1244, 1248, 1249, 1253, 1254, 1258, 1259, 1260, 1263, - 1264, 1268, 1275, 1277, 1279, 1281, 1283, 1285, 1286, 1288, - 1290, 1292, 1294, 1295, 1296, 1299, 1300, 1302, 1304, 1305, - 1308, 1311, 1312, 1313, 1316, 1318, 1322, 1324, 1328, 1329, - 1330, 1334, 1336, 1336, 1338, 1341, 1343, 1345, 1348, 1353, - 1360, 1361, 1362, 1369, 1373, 1374, 1378, 1379, 1382, 1383, - 1386, 1387, 1390, 1391, 1392, 1393, 1396, 1397, 1400, 1401, - 1404, 1405, 1406, 1409, 1409, 1410, 1411, 1414, 1426, 1442, - 1443, 1446, 1447, 1448, 1451, 1452, 1455, 1457, 1458, 1460, - 1461, 1463, 1465, 1467, 1469, 1475, 1476, 1477, 1478, 1479, - 1480, 1481, 1482, 1483, 1487, 1490, 1493, 1494, 1498, 1500, - 1502, 1504, 1508, 1509, 1511, 1515, 1517, 1519, 1522, 1523, - 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, - 1534, 1537, 1538, 1543, 1546, 1549, 1550, 1553, 1554, 1555, - 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1566, 1567, - 1574, 1575, 1581, 1582, 1583, 1584, 1587, 1588, 1589, 1590, - 1593, 1594, 1598, 1601, 1604, 1607, 1610, 1613, 1616, 1617, - 1618, 1619, 1621, 1622, 1624, 1626, 1632, 1636, 1638, 1640, - 1642, 1646, 1647, 1650, 1651, 1654, 1655, 1658, 1659, 1662, - 1663, 1666, 1667, 1670, 1671, 1672, 1675, 1688, 1693, 1694, - 1698, 1699, 1702, 1707, 1710, 1711, 1712, 1720, 1721, 1721, - 1725, 1726, 1727, 1738, 1745, 1746, 1749, 1750, 1753, 1754, - 1755, 1756, 1757, 1759, 1760, 1761, 1762, 1765, 1766, 1767, - 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1777, 1778, 1781, - 1782, 1783, 1784, 1787, 1788, 1789, 1792, 1793, 1794, 1797, - 1798, 1799, 1800, 1801, 1804, 1805, 1806, 1809, 1810, 1813, - 1814, 1818, 1819, 1822, 1823, 1826, 1827, 1830, 1831, 1832, - 1833, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, - 1845, 1846, 1847, 1850, 1851, 1854, 1857, 1859, 1861, 1865, - 1866, 1868, 1870, 1873, 1874, 1875, 1877, 1878, 1879, 1880, - 1881, 1882, 1883, 1886, 1887, 1890, 1891, 1894, 1897, 1898, - 1899, 1900, 1901, 1904, 1905, 1906, 1907 + 705, 709, 711, 715, 716, 718, 725, 735, 736, 739, + 740, 741, 742, 743, 744, 745, 746, 750, 751, 755, + 756, 759, 761, 763, 764, 765, 766, 767, 769, 773, + 774, 777, 781, 793, 794, 795, 796, 797, 798, 799, + 800, 804, 805, 806, 807, 808, 809, 810, 811, 812, + 813, 817, 818, 821, 822, 823, 824, 825, 826, 827, + 828, 829, 830, 831, 834, 835, 838, 842, 843, 846, + 847, 848, 849, 852, 853, 857, 858, 859, 860, 863, + 864, 865, 868, 869, 870, 873, 874, 875, 876, 877, + 880, 881, 882, 885, 886, 889, 890, 894, 895, 898, + 899, 904, 910, 911, 917, 923, 924, 924, 926, 929, + 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, + 940, 943, 944, 947, 948, 951, 956, 957, 958, 961, + 975, 980, 986, 988, 994, 999, 999, 1003, 1004, 1006, + 1007, 1010, 1013, 1016, 1019, 1020, 1023, 1024, 1027, 1028, + 1029, 1030, 1037, 1038, 1042, 1043, 1046, 1047, 1050, 1052, + 1061, 1062, 1063, 1064, 1065, 1068, 1071, 1077, 1086, 1089, + 1092, 1099, 1106, 1112, 1137, 1138, 1141, 1142, 1143, 1144, + 1145, 1148, 1149, 1150, 1151, 1154, 1155, 1156, 1157, 1158, + 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, + 1169, 1170, 1174, 1175, 1178, 1179, 1182, 1183, 1186, 1187, + 1188, 1189, 1192, 1193, 1194, 1195, 1196, 1197, 1200, 1201, + 1202, 1203, 1206, 1207, 1208, 1209, 1212, 1213, 1214, 1215, + 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1229, 1230, 1231, + 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, + 1242, 1245, 1249, 1250, 1254, 1255, 1259, 1260, 1261, 1264, + 1265, 1269, 1276, 1278, 1280, 1282, 1284, 1286, 1287, 1289, + 1291, 1293, 1295, 1296, 1297, 1300, 1301, 1303, 1305, 1306, + 1309, 1312, 1313, 1314, 1317, 1319, 1323, 1325, 1329, 1330, + 1331, 1335, 1337, 1337, 1339, 1342, 1344, 1346, 1349, 1354, + 1361, 1362, 1363, 1370, 1374, 1375, 1379, 1380, 1383, 1384, + 1387, 1388, 1391, 1392, 1393, 1394, 1397, 1398, 1401, 1402, + 1405, 1406, 1407, 1410, 1410, 1411, 1412, 1415, 1427, 1443, + 1444, 1447, 1448, 1449, 1452, 1453, 1456, 1458, 1459, 1461, + 1462, 1464, 1466, 1468, 1470, 1476, 1477, 1478, 1479, 1480, + 1481, 1482, 1483, 1484, 1488, 1491, 1494, 1495, 1499, 1501, + 1503, 1505, 1509, 1510, 1512, 1516, 1518, 1520, 1523, 1524, + 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, + 1535, 1538, 1539, 1544, 1547, 1550, 1551, 1554, 1555, 1556, + 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1567, 1568, + 1575, 1576, 1582, 1583, 1584, 1585, 1588, 1589, 1590, 1591, + 1594, 1595, 1599, 1602, 1605, 1608, 1611, 1614, 1617, 1618, + 1619, 1620, 1622, 1623, 1625, 1627, 1633, 1637, 1639, 1641, + 1643, 1647, 1648, 1651, 1652, 1655, 1656, 1659, 1660, 1663, + 1664, 1667, 1668, 1671, 1672, 1673, 1676, 1689, 1694, 1695, + 1699, 1700, 1703, 1708, 1711, 1712, 1713, 1721, 1722, 1722, + 1726, 1727, 1728, 1739, 1746, 1747, 1750, 1751, 1754, 1755, + 1756, 1757, 1758, 1760, 1761, 1762, 1763, 1766, 1767, 1768, + 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1778, 1779, 1782, + 1783, 1784, 1785, 1788, 1789, 1790, 1793, 1794, 1795, 1798, + 1799, 1800, 1801, 1802, 1805, 1806, 1807, 1810, 1811, 1814, + 1815, 1819, 1820, 1823, 1824, 1827, 1828, 1831, 1832, 1833, + 1834, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, + 1846, 1847, 1848, 1851, 1852, 1855, 1858, 1860, 1862, 1866, + 1867, 1869, 1871, 1874, 1875, 1876, 1878, 1879, 1880, 1881, + 1882, 1883, 1884, 1887, 1888, 1891, 1892, 1895, 1898, 1899, + 1900, 1901, 1902, 1905, 1906, 1907, 1908 }; #endif @@ -3620,7 +3620,8 @@ case 122: break;} case 130: { - qtype qint = qtype_create (ctype_int); + /**!!! deal with fred; fred (int); declarations! **/ + qtype qint = qtype_create (ctype_int); yyval.ntyp = idDecl_fixBase (yyvsp[0].ntyp, qint); qtype_free (qint); ; diff --git a/src/cgrammar.y b/src/cgrammar.y index 4c7ed2c..be8ec82 100644 --- a/src/cgrammar.y +++ b/src/cgrammar.y @@ -697,7 +697,8 @@ conditionTag fcnDefHdrAux : namedDecl { - qtype qint = qtype_create (ctype_int); + /**!!! deal with fred; fred (int); declarations! **/ + qtype qint = qtype_create (ctype_int); $$ = idDecl_fixBase ($1, qint); qtype_free (qint); } diff --git a/src/clabstract.c b/src/clabstract.c index bf9e58f..e83e20f 100644 --- a/src/clabstract.c +++ b/src/clabstract.c @@ -56,11 +56,13 @@ static /*@only@*/ constraintList implicitFcnConstraints = NULL; static void clabstract_prepareFunction (uentry p_e) /*@modifies p_e@*/ ; static bool fcnNoGlobals = FALSE; -static bool ProcessingVars = FALSE; -static bool ProcessingParams = FALSE; -static bool ProcessingGlobals = FALSE; -static bool ProcessingTypedef = FALSE; -static bool ProcessingIterVars = FALSE; +static void processVariable (/*@temp@*/ idDecl p_t) /*@modifies internalState@*/ ; + +static bool s_processingVars = FALSE; +static bool s_processingParams = FALSE; +static bool s_processingGlobals = FALSE; +static bool s_processingTypedef = FALSE; +static bool s_processingIterVars = FALSE; static /*@only@*/ qtype processingType = qtype_undefined; static uentry currentIter = uentry_undefined; static /*@dependent@*/ uentryList saveParamList; /* for old style functions */ @@ -296,13 +298,13 @@ extern void declareCIter (cstring name, /*@owned@*/ uentryList params) extern void nextIterParam (void) { - llassert (ProcessingIterVars); + llassert (s_processingIterVars); saveIterParamNo++; } extern int iterParamNo (void) { - llassert (ProcessingIterVars); + llassert (s_processingIterVars); return saveIterParamNo; } @@ -609,32 +611,28 @@ static /*@exposed@*/ uentry clabstract_globalDeclareFunction (idDecl tid) ue = uentry_makeIdFunction (tid); reflectSpecialCode (ue); reflectArgsUsed (ue); + reflectStorageClass (ue); + uentry_checkParams (ue); + + DPRINTF (("Supercede function: %s", uentry_unparseFull (ue))); + + ue = usymtab_supGlobalEntryReturn (ue); + DPRINTF (("After supercede function: %s", uentry_unparseFull (ue))); + + DPRINTF (("Enter function: %s", uentry_unparseFull (ue))); + context_enterFunction (ue); + enterFunctionParams (uentry_getParams (ue)); + + resetStorageClass (); + DPRINTF (("Function: %s", uentry_unparseFull (ue))); + return (ue); } else { - llparseerror (message ("Inconsistent function declaration: %q", + llparseerror (message ("Non-function declaration: %q", idDecl_unparse (tid))); - - tid = idDecl_replaceCtype - (tid, ctype_makeFunction (ctype_unknown, uentryList_undefined)); - ue = uentry_makeIdFunction (tid); + return (uentry_undefined); } - - reflectStorageClass (ue); - uentry_checkParams (ue); - - DPRINTF (("Supercede function: %s", uentry_unparseFull (ue))); - - ue = usymtab_supGlobalEntryReturn (ue); - DPRINTF (("After supercede function: %s", uentry_unparseFull (ue))); - - DPRINTF (("Enter function: %s", uentry_unparseFull (ue))); - context_enterFunction (ue); - enterFunctionParams (uentry_getParams (ue)); - - resetStorageClass (); - DPRINTF (("Function: %s", uentry_unparseFull (ue))); - return (ue); } /* @@ -718,50 +716,67 @@ void clabstract_declareFunction (idDecl tid) /*@globals undef saveFunction; @*/ DPRINTF (("Declare function: %s", idDecl_unparse (tid))); - if (ProcessingParams) + if (ctype_isUnknown (idDecl_getCtype (tid))) { - ue = globalDeclareOldStyleFunction (tid); - saveFunction = ue; - DPRINTF (("Set save function: %s", uentry_unparseFull (ue))); + /* + ** No type, its really a plain name (int) declaration + */ + + voptgenerror (FLG_IMPTYPE, + message ("No type before declaration name (implicit int type): %q", + idDecl_unparse (tid)), + g_currentloc); + tid = idDecl_replaceCtype (tid, ctype_int); + processVariable (tid); + saveFunction = uentry_undefined; } else { - saveFunction = uentry_undefined; - - if (context_inRealFunction ()) + if (s_processingParams) { - ue = uentry_makeVariableLoc (idDecl_observeId (tid), ctype_unknown); - - llparseerror (message ("Function declared inside function: %q", - idDecl_unparse (tid))); - - context_quietExitFunction (); - ue = usymtab_supEntryReturn (ue); + ue = globalDeclareOldStyleFunction (tid); + saveFunction = ue; + DPRINTF (("Set save function: %s", uentry_unparseFull (ue))); } else { - if (context_inInnerScope ()) + saveFunction = uentry_undefined; + + if (context_inRealFunction ()) { - llparseerror (message ("Declaration in inner context: %q", + ue = uentry_makeVariableLoc (idDecl_observeId (tid), ctype_unknown); + + llparseerror (message ("Function declared inside function: %q", idDecl_unparse (tid))); - sRef_setGlobalScope (); - ue = uentry_makeVariableLoc (idDecl_observeId (tid), - ctype_unknown); - ue = usymtab_supGlobalEntryReturn (ue); - sRef_clearGlobalScope (); + context_quietExitFunction (); + ue = usymtab_supEntryReturn (ue); } else { - ue = clabstract_globalDeclareFunction (tid); + if (context_inInnerScope ()) + { + llparseerror (message ("Declaration in inner context: %q", + idDecl_unparse (tid))); + + sRef_setGlobalScope (); + ue = uentry_makeVariableLoc (idDecl_observeId (tid), + ctype_unknown); + ue = usymtab_supGlobalEntryReturn (ue); + sRef_clearGlobalScope (); + } + else + { + ue = clabstract_globalDeclareFunction (tid); + } } + + resetGlobals (); } - resetGlobals (); + resetStorageClass (); + idDecl_free (tid); } - - resetStorageClass (); - idDecl_free (tid); } void declareStaticFunction (idDecl tid) /*@globals undef saveFunction; @*/ @@ -770,7 +785,7 @@ void declareStaticFunction (idDecl tid) /*@globals undef saveFunction; @*/ DPRINTF (("Declare static funciton: %s", idDecl_unparse (tid))); - if (ProcessingParams) + if (s_processingParams) { ue = globalDeclareOldStyleFunction (tid); saveFunction = ue; @@ -828,6 +843,7 @@ void declareStaticFunction (idDecl tid) /*@globals undef saveFunction; @*/ } else { + DPRINTF (("Here we are!")); llparseerror (message ("Inconsistent function declaration: %q", idDecl_unparse (tid))); @@ -1114,7 +1130,7 @@ void setStorageClass (storageClassCode sc) void setProcessingIterVars (uentry iter) { - ProcessingIterVars = TRUE; + s_processingIterVars = TRUE; currentIter = iter; saveIterParamNo = 0; } @@ -1122,7 +1138,7 @@ setProcessingIterVars (uentry iter) void setProcessingGlobalsList () { - ProcessingGlobals = TRUE; + s_processingGlobals = TRUE; fcnNoGlobals = FALSE; } @@ -1148,20 +1164,20 @@ isProcessingGlobMods () static void resetGlobals (void) { - ProcessingGlobals = FALSE; + s_processingGlobals = FALSE; fcnNoGlobals = FALSE; } void unsetProcessingGlobals () { - ProcessingGlobals = FALSE; + s_processingGlobals = FALSE; } void setProcessingVars (/*@only@*/ qtype q) { - ProcessingVars = TRUE; + s_processingVars = TRUE; qtype_free (processingType); processingType = q; } @@ -1169,14 +1185,14 @@ setProcessingVars (/*@only@*/ qtype q) static void setGenericParamList (/*@dependent@*/ uentryList pm) { - ProcessingParams = TRUE; + s_processingParams = TRUE; saveParamList = pm; } void setProcessingTypedef (qtype q) { - ProcessingTypedef = TRUE; + s_processingTypedef = TRUE; qtype_free (processingType); processingType = q; @@ -1186,13 +1202,13 @@ void unsetProcessingVars () { resetStorageClass (); - ProcessingVars = FALSE; + s_processingVars = FALSE; } void oldStyleDoneParams () { - if (ProcessingParams) + if (s_processingParams) { if (uentry_isInvalid (saveFunction)) { @@ -1205,7 +1221,7 @@ oldStyleDoneParams () ctype ct2 = ctype_makeFunction (ct, params); uentry_setType (saveFunction, ct2); - ProcessingParams = FALSE; + s_processingParams = FALSE; oldStyleCompleteFunction (saveFunction); saveFunction = uentry_undefined; @@ -1245,7 +1261,7 @@ checkDoneParams () ct2 = ctype_makeParamsFunction (ct, uentryList_copy (saveParamList)); uentry_setType (saveFunction, ct2); - ProcessingParams = FALSE; + s_processingParams = FALSE; oldStyleDeclareFunction (saveFunction); saveFunction = uentry_undefined; @@ -1254,7 +1270,7 @@ checkDoneParams () void clabstract_declareType (/*@only@*/ exprNodeList decls, /*@only@*/ warnClause warn) { - llassert (ProcessingTypedef); + llassert (s_processingTypedef); DPRINTF (("Declare type: %s", exprNodeList_unparse (decls))); @@ -1296,7 +1312,7 @@ void clabstract_declareType (/*@only@*/ exprNodeList decls, /*@only@*/ warnClaus void unsetProcessingTypedef () { - ProcessingTypedef = FALSE; + s_processingTypedef = FALSE; } void checkConstant (qtype t, idDecl id) @@ -1353,206 +1369,217 @@ void checkValueConstant (qtype t, idDecl id, exprNode e) usymtab_supGlobalEntry (ue); } -void processNamedDecl (idDecl t) +static void processVariable (idDecl t) { - if (qtype_isUndefined (processingType)) - { - llparseerror (message ("No type before declaration name: %q", idDecl_unparse (t))); - - processingType = qtype_create (ctype_unknown); - } - - t = idDecl_fixBase (t, processingType); - - DPRINTF (("Declare: %s", idDecl_unparse (t))); + uentry e; + ctype ct; - if (ProcessingGlobals) + ct = ctype_realType (idDecl_getCtype (t)); + + if (s_processingParams) { cstring id = idDecl_getName (t); - uentry ue = usymtab_lookupSafe (id); + int paramno = uentryList_lookupRealName (saveParamList, id); - if (!uentry_isValid (ue)) + if (paramno >= 0) { - llerror (FLG_UNRECOG, - message ("Variable used in globals list is undeclared: %s", id)); + uentry cparam = uentryList_getN (saveParamList, paramno); + + DPRINTF (("Processing param: %s", uentry_unparseFull (cparam))); + uentry_setType (cparam, idDecl_getCtype (t)); + uentry_reflectQualifiers (cparam, idDecl_getQuals (t)); + uentry_setDeclaredOnly (cparam, context_getSaveLocation ()); + DPRINTF (("Processing param: %s", uentry_unparseFull (cparam))); } else { - if (!ctype_match (uentry_getType (ue), idDecl_getCtype (t))) - { - voptgenerror - (FLG_INCONDEFS, - message ("Variable %s used in globals list declared %s, " - "but listed as %s", - id, ctype_unparse (uentry_getType (ue)), - ctype_unparse (idDecl_getCtype (t))), - g_currentloc); - } - else - { - sRef sr = sRef_copy (uentry_getSref (ue)); - reflectGlobalQualifiers (sr, idDecl_getQuals (t)); - } + llfatalerrorLoc + (message ("Old style declaration uses unlisted parameter: %s", + id)); } } - else if (ProcessingVars) + else { - uentry e; - ctype ct; + fileloc loc; - ct = ctype_realType (idDecl_getCtype (t)); - - if (ProcessingParams) + if (context_inIterDef ()) { - cstring id = idDecl_getName (t); - int paramno = uentryList_lookupRealName (saveParamList, id); - - if (paramno >= 0) - { - uentry cparam = uentryList_getN (saveParamList, paramno); - - DPRINTF (("Processing param: %s", uentry_unparseFull (cparam))); - uentry_setType (cparam, idDecl_getCtype (t)); - uentry_reflectQualifiers (cparam, idDecl_getQuals (t)); - uentry_setDeclaredOnly (cparam, context_getSaveLocation ()); - DPRINTF (("Processing param: %s", uentry_unparseFull (cparam))); - } - else + cstring pname = makeParam (idDecl_observeId (t)); + uentry p = usymtab_lookupSafe (pname); + + cstring_free (pname); + + if (uentry_isYield (p)) { - llfatalerrorLoc - (message ("Old style declaration uses unlisted parameter: %s", - id)); + e = uentry_makeParam (t, sRef_getParam (uentry_getSref (p))); + uentry_checkYieldParam (p, e); + usymtab_supEntrySref (e); + return; } } + + if ((hasSpecialCode () || argsUsed) + && ctype_isFunction (idDecl_getCtype (t))) + { + e = uentry_makeIdFunction (t); + reflectSpecialCode (e); + reflectArgsUsed (e); + } else { - fileloc loc; - - if (context_inIterDef ()) - { - cstring pname = makeParam (idDecl_observeId (t)); - uentry p = usymtab_lookupSafe (pname); - - cstring_free (pname); - - if (uentry_isYield (p)) - { - e = uentry_makeParam (t, sRef_getParam (uentry_getSref (p))); - uentry_checkYieldParam (p, e); - usymtab_supEntrySref (e); - return; - } - } - - if ((hasSpecialCode () || argsUsed) - && ctype_isFunction (idDecl_getCtype (t))) - { - e = uentry_makeIdFunction (t); - reflectSpecialCode (e); - reflectArgsUsed (e); - } - else - { - e = uentry_makeIdVariable (t); - } - - loc = uentry_whereDeclared (e); - - /* - if (context_inGlobalScope ()) - { - uentry_checkParams was here! - } - */ + e = uentry_makeIdVariable (t); + } + + loc = uentry_whereDeclared (e); + + /* + if (context_inGlobalScope ()) + { + uentry_checkParams was here! + } + */ + + if (ctype_isFunction (uentry_getType (e))) + { + clabstract_prepareFunction (e); + } + + DPRINTF (("Superceding... %s", uentry_unparseFull (e))); + e = usymtab_supEntrySrefReturn (e); + DPRINTF (("After superceding... %s", uentry_unparseFull (e))); + + if (uentry_isExtern (e) && !context_inGlobalScope ()) + { + voptgenerror + (FLG_NESTEDEXTERN, + message ("Declaration using extern inside function scope: %q", + uentry_unparse (e)), + g_currentloc); - if (ctype_isFunction (uentry_getType (e))) + uentry_setDefined (e, fileloc_getExternal ()); + sRef_setDefined (uentry_getSref (e), fileloc_getExternal ()); + } + + if (uentry_isFunction (e)) + { + if (!context_inXHFile ()) { - clabstract_prepareFunction (e); + checkParamNames (e); } + } + + if (uentry_isVar (e) && uentry_isCheckedUnknown (e)) + { + sRef sr = uentry_getSref (e); - DPRINTF (("Superceding... %s", uentry_unparseFull (e))); - e = usymtab_supEntrySrefReturn (e); - DPRINTF (("After superceding... %s", uentry_unparseFull (e))); - - if (uentry_isExtern (e) && !context_inGlobalScope ()) + if (sRef_isLocalVar (sr)) { - voptgenerror - (FLG_NESTEDEXTERN, - message ("Declaration using extern inside function scope: %q", - uentry_unparse (e)), - g_currentloc); - - uentry_setDefined (e, fileloc_getExternal ()); - sRef_setDefined (uentry_getSref (e), fileloc_getExternal ()); + if (context_getFlag (FLG_IMPCHECKMODINTERNALS)) + { + uentry_setCheckMod (e); + } + else + { + uentry_setUnchecked (e); + } } - - if (uentry_isFunction (e)) + else if (sRef_isFileStatic (sr)) { - if (!context_inXHFile ()) + if (context_getFlag (FLG_IMPCHECKEDSTRICTSTATICS)) + { + uentry_setCheckedStrict (e); + } + else if (context_getFlag (FLG_IMPCHECKEDSTATICS)) { - checkParamNames (e); + uentry_setChecked (e); + } + else if (context_getFlag (FLG_IMPCHECKMODSTATICS)) + { + uentry_setCheckMod (e); + } + else + { + ; } } - - if (uentry_isVar (e) && uentry_isCheckedUnknown (e)) + else /* real global */ { - sRef sr = uentry_getSref (e); + llassert (sRef_isRealGlobal (sr)); - if (sRef_isLocalVar (sr)) + if (context_getFlag (FLG_IMPCHECKEDSTRICTGLOBALS)) { - if (context_getFlag (FLG_IMPCHECKMODINTERNALS)) - { - uentry_setCheckMod (e); - } - else - { - uentry_setUnchecked (e); - } + uentry_setCheckedStrict (e); } - else if (sRef_isFileStatic (sr)) + else if (context_getFlag (FLG_IMPCHECKEDGLOBALS)) { - if (context_getFlag (FLG_IMPCHECKEDSTRICTSTATICS)) - { - uentry_setCheckedStrict (e); - } - else if (context_getFlag (FLG_IMPCHECKEDSTATICS)) - { - uentry_setChecked (e); - } - else if (context_getFlag (FLG_IMPCHECKMODSTATICS)) - { - uentry_setCheckMod (e); - } - else - { - ; - } + uentry_setChecked (e); } - else /* real global */ + else if (context_getFlag (FLG_IMPCHECKMODGLOBALS)) { - llassert (sRef_isRealGlobal (sr)); - - if (context_getFlag (FLG_IMPCHECKEDSTRICTGLOBALS)) - { - uentry_setCheckedStrict (e); - } - else if (context_getFlag (FLG_IMPCHECKEDGLOBALS)) - { - uentry_setChecked (e); - } - else if (context_getFlag (FLG_IMPCHECKMODGLOBALS)) - { - uentry_setCheckMod (e); - } - else - { - ; - } + uentry_setCheckMod (e); + } + else + { + ; } } } } - else if (ProcessingTypedef) +} + +void processNamedDecl (idDecl t) +{ + if (qtype_isUndefined (processingType)) + { + processingType = qtype_create (ctype_int); + t = idDecl_fixBase (t, processingType); + + voptgenerror (FLG_IMPTYPE, + message ("No type before declaration name (implicit int type): %q", + idDecl_unparse (t)), + g_currentloc); + } + else + { + t = idDecl_fixBase (t, processingType); + } + + DPRINTF (("Declare: %s", idDecl_unparse (t))); + + if (s_processingGlobals) + { + cstring id = idDecl_getName (t); + uentry ue = usymtab_lookupSafe (id); + + if (!uentry_isValid (ue)) + { + llerror (FLG_UNRECOG, + message ("Variable used in globals list is undeclared: %s", id)); + } + else + { + if (!ctype_match (uentry_getType (ue), idDecl_getCtype (t))) + { + voptgenerror + (FLG_INCONDEFS, + message ("Variable %s used in globals list declared %s, " + "but listed as %s", + id, ctype_unparse (uentry_getType (ue)), + ctype_unparse (idDecl_getCtype (t))), + g_currentloc); + } + else + { + sRef sr = sRef_copy (uentry_getSref (ue)); + reflectGlobalQualifiers (sr, idDecl_getQuals (t)); + } + } + } + else if (s_processingVars) + { + processVariable (t); + } + else if (s_processingTypedef) { ctype ct = idDecl_getCtype (t); uentry e; @@ -1777,7 +1804,7 @@ handleEnum (cstring id) bool processingIterVars (void) { - return ProcessingIterVars; + return s_processingIterVars; } uentry getCurrentIter (void) @@ -1846,7 +1873,7 @@ doVaDcl () cstring id = cstring_makeLiteral ("va_alist"); uentry e; - if (ProcessingParams) + if (s_processingParams) { int i = uentryList_lookupRealName (saveParamList, id); diff --git a/src/context.c b/src/context.c index 4037e4d..4d11f04 100644 --- a/src/context.c +++ b/src/context.c @@ -1047,7 +1047,7 @@ context_setModeAux (cstring s, bool warn) FLG_TYPEUNUSED, FLG_CONSTUNUSED, FLG_ENUMMEMUNUSED, FLG_FIELDUNUSED, FLG_PTRNUMCOMPARE, FLG_BOOLCOMPARE, FLG_UNSIGNEDCOMPARE, - FLG_MUTREP, FLG_NOEFFECT, FLG_IMPTYPE, + FLG_MUTREP, FLG_NOEFFECT, FLG_IMPTYPE, FLG_RETVALOTHER, FLG_RETVALBOOL, FLG_RETVALINT, FLG_SPECUNDEF, FLG_INCONDEFS, FLG_INCONDEFSLIB, FLG_MISPLACEDSHAREQUAL, FLG_MATCHFIELDS, diff --git a/src/ctype.c b/src/ctype.c index 6a3bcd6..1227234 100644 --- a/src/ctype.c +++ b/src/ctype.c @@ -80,7 +80,7 @@ ctkind ctkind_fromInt (int i) { /*@+enumint@*/ - if (i < CTK_UNKNOWN || i > CTK_COMPLEX) + if (i < CTK_ANYTYPE || i > CTK_COMPLEX) { llcontbug (message ("ctkind_fromInt: out of range: %d", i)); return CTK_INVALID; @@ -2669,7 +2669,9 @@ static /*@observer@*/ ctbase ctype_getCtbase (ctype c) llbuglit ("ctype_getCtbase: ctype dne"); if (c == ctype_elipsMarker) llbuglit ("ctype_getCtbase: elips marker"); - + if (c == ctype_anytype) + llbuglit ("ctype_getCtbase: ctype anytype"); + llfatalbug (message ("ctype_getCtbase: ctype out of range: %d", c)); BADEXIT; } @@ -2712,6 +2714,8 @@ ctype_getCtentry (ctype c) } else if (c == CTK_UNKNOWN) llcontbuglit ("ctype_getCtentry: ctype unknown"); + else if (c == CTK_ANYTYPE) + llcontbuglit ("ctype_getCtentry: ctype unknown"); else if (c == CTK_INVALID) llcontbuglit ("ctype_getCtentry: ctype invalid (ctype_undefined)"); else if (c == CTK_DNE) diff --git a/src/fileloc.c b/src/fileloc.c index 063ec7e..5cafa56 100644 --- a/src/fileloc.c +++ b/src/fileloc.c @@ -646,6 +646,8 @@ fileloc_column (fileloc f) fileloc_unparse (fileloc f) { bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); + bool htmlFormat = context_getFlag (FLG_HTMLFILEFORMAT); + cstring res = cstring_undefined; if (fileloc_isDefined (f)) { @@ -656,23 +658,29 @@ fileloc_unparse (fileloc f) case FL_IMPORT: if (parenFormat) { - return (message ("import file %q(%d)", fileloc_outputFilename (f), f->lineno)); + res = message ("import file %q(%d)", fileloc_outputFilename (f), f->lineno); } else { - return (message ("import file %q:%d", fileloc_outputFilename (f), f->lineno)); + res = message ("import file %q:%d", fileloc_outputFilename (f), f->lineno); } + break; case FL_PREPROC: - if (parenFormat) - { - return (message ("%q(%d)", fileloc_outputFilename (f), f->lineno)); - } - else - { - return (message ("%q:%d", fileloc_outputFilename (f), f->lineno)); - } + { + if (parenFormat) + { + res = message ("%q(%d)", fileloc_outputFilename (f), f->lineno); + } + else + { + res = message ("%q:%d", fileloc_outputFilename (f), f->lineno); + } + + break; + } case FL_EXTERNAL: - return (cstring_makeLiteral ("")); + res = cstring_makeLiteral (""); + break; default: { cstring fname; @@ -694,48 +702,59 @@ fileloc_unparse (fileloc f) { if (parenFormat) { - return (message ("%q(%d,%d)", fname, f->lineno, f->column)); + res = message ("%q(%d,%d)", fname, f->lineno, f->column); } else { - return (message ("%q:%d:%d", fname, f->lineno, f->column)); + res = message ("%q:%d:%d", fname, f->lineno, f->column); } } else { if (parenFormat) { - return (message ("%q(%d)", fname, f->lineno)); + res = message ("%q(%d)", fname, f->lineno); } else { - return (message ("%q:%d", fname, f->lineno)); + res = message ("%q:%d", fname, f->lineno); } } } - - return fname; + else + { + res = fname; + } } else if (fileloc_linenoDefined (f)) { if (parenFormat) { - return (message ("%q(%d)", fname, f->lineno)); + res = message ("%q(%d)", fname, f->lineno); } else { - return (message ("%q:%d", fname, f->lineno)); + res = message ("%q:%d", fname, f->lineno); } } else { - return fname; + res = fname; } } } - } - return (cstring_makeLiteral ("< Location unknown >")); + if (htmlFormat && fileloc_linenoDefined (f)) + { + res = message ("%s", f->lineno, res); + } + } + else + { + res = cstring_makeLiteral ("< Location unknown >"); + } + + return res; } /*@only@*/ cstring diff --git a/src/flags.def b/src/flags.def index 921167e..f3167fc 100644 --- a/src/flags.def +++ b/src/flags.def @@ -3270,6 +3270,13 @@ static flaglist flags = "show column number where error is found", NULL, 0, 0 }, + { + FK_FORMAT, FK_DISPLAY, plainFlag, + "htmlfileformat", + FLG_HTMLFILEFORMAT, + "show file locations as links", + NULL, 0, 0 + }, { FK_FORMAT, FK_NONE, plainFlag, "showfunc", diff --git a/src/llerror.c b/src/llerror.c index 4b82b31..95c9621 100644 --- a/src/llerror.c +++ b/src/llerror.c @@ -1449,21 +1449,23 @@ lclbug (/*@only@*/ cstring s) # endif void -llfatalerror (cstring s) +xllfatalerror (char *srcFile, int srcLine, cstring s) { prepareMessage (); printError (g_errorstream, s); printError (g_errorstream, cstring_makeLiteral ("*** Cannot continue.")); + showSourceLoc (srcFile, srcLine); llexit (LLFAILURE); } void -llfatalerrorLoc (/*@only@*/ cstring s) +xllfatalerrorLoc (char *srcFile, int srcLine, /*@only@*/ cstring s) { prepareMessage (); (void) fflush (g_warningstream); printError (g_errorstream, message ("%q: %q", fileloc_unparse (g_currentloc), s)); printError (g_errorstream, cstring_makeLiteral ("*** Cannot continue.")); + showSourceLoc (srcFile, srcLine); (void) fflush (g_warningstream); llexit (LLFAILURE); } @@ -1802,7 +1804,7 @@ bool xllnoptgenerror (char *srcFile, int srcLine, return FALSE; } -void llparseerror (cstring s) +void xllparseerror (char *srcFile, int srcLine, cstring s) { if (context_getFlag (FLG_TRYTORECOVER)) { @@ -1812,14 +1814,16 @@ void llparseerror (cstring s) { if (cstring_isDefined (s)) { - llfatalerror (message ("%q: Parse Error: %q. " - "Too many errors, giving up.", - fileloc_unparse (g_currentloc), s)); + xllfatalerror (srcFile, srcLine, + message ("%q: Parse Error: %q. " + "Too many errors, giving up.", + fileloc_unparse (g_currentloc), s)); } else { - llfatalerror (message ("%q: Parse Error. Too many errors, giving up.", - fileloc_unparse (g_currentloc))); + xllfatalerror (srcFile, srcLine, + message ("%q: Parse Error. Too many errors, giving up.", + fileloc_unparse (g_currentloc))); } } else @@ -1828,10 +1832,12 @@ void llparseerror (cstring s) { llreportparseerror (message ("Parse Error: %q. Attempting to continue.", s)); + showSourceLoc (srcFile, srcLine); } else { llreportparseerror (message ("Parse Error. Attempting to continue.")); + showSourceLoc (srcFile, srcLine); } } } @@ -1848,8 +1854,9 @@ void llparseerror (cstring s) msg = message ("Parse Error."); } - llfatalerror - (message ("%q: %s (For help on parse errors, " + xllfatalerror + (srcFile, srcLine, + message ("%q: %s (For help on parse errors, " "see splint -help parseerrors.)", fileloc_unparse (g_currentloc), msg)); } diff --git a/src/qtype.c b/src/qtype.c index 4255936..10dd023 100644 --- a/src/qtype.c +++ b/src/qtype.c @@ -163,7 +163,9 @@ qtype qtype_resolve (/*@returned@*/ qtype q) { if (qtype_isDefined (q)) { + DPRINTF (("Resolving: %s", qtype_unparse (q))); q->type = ctype_resolve (q->type); + DPRINTF (("Resolving: %s", qtype_unparse (q))); } return q; -- 2.45.1