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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060
  
     | 
    
      -----------------------------------------------------------------------------
--                                                                          --
--                          GNATCHECK COMPONENTS                            --
--                                                                          --
--             G N A T C H E C K . R U L E S . C U S T O M _ 1              --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--                     Copyright (C) 2006-2014, AdaCore                     --
--                                                                          --
-- GNATCHECK  is  free  software;  you can redistribute it and/or modify it --
-- under terms of the  GNU  General Public License as published by the Free --
-- Software Foundation;  either version 3, or ( at your option)  any  later --
-- version.  GNATCHECK  is  distributed in the hope that it will be useful, --
-- but  WITHOUT  ANY  WARRANTY;   without  even  the  implied  warranty  of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details.  You should have received a copy of the --
-- GNU General Public License distributed with GNAT; see file  COPYING3. If --
-- not,  go  to  http://www.gnu.org/licenses  for  a  complete  copy of the --
-- license.                                                                 --
--                                                                          --
-- GNATCHECK is maintained by AdaCore (http://www.adacore.com).             --
--                                                                          --
------------------------------------------------------------------------------
pragma Ada_2012;
with Ada.Characters.Handling;     use Ada.Characters.Handling;
with Ada.Strings;                 use Ada.Strings;
with Ada.Strings.Fixed;           use Ada.Strings.Fixed;
with Ada.Strings.Wide_Fixed;      use Ada.Strings.Wide_Fixed;
with Ada.Text_IO;                 use Ada.Text_IO;
with Ada.Wide_Characters.Unicode;
with Asis.Clauses;                use Asis.Clauses;
with Asis.Compilation_Units;      use Asis.Compilation_Units;
with Asis.Declarations;           use Asis.Declarations;
with Asis.Definitions;            use Asis.Definitions;
with Asis.Elements;               use Asis.Elements;
with Asis.Expressions;            use Asis.Expressions;
with Asis.Extensions.Flat_Kinds;  use Asis.Extensions.Flat_Kinds;
with Asis.Extensions;             use Asis.Extensions;
with Asis.Iterator;
with Asis.Statements;             use Asis.Statements;
with Asis.Text;                   use Asis.Text;
with Namet;
with Snames;
with Table;
with ASIS_UL.Misc;                use ASIS_UL.Misc;
with ASIS_UL.Output;              use ASIS_UL.Output;
with ASIS_UL.Utilities;           use ASIS_UL.Utilities;
with Gnatcheck.ASIS_Utilities;    use Gnatcheck.ASIS_Utilities;
with Gnatcheck.Traversal_Stack;   use Gnatcheck.Traversal_Stack;
package body Gnatcheck.Rules.Custom_1 is
   -------------------------------------
   -- General-purpose local functions --
   -------------------------------------
   -------------------------------------
   -- Rule parameter parsing routines --
   -------------------------------------
   procedure Parse_Par
     (First_Par_Id : out Natural;
      Last_Par_Id  : out Positive;
      First_Str_Id : out Natural;
      Last_Str_Id  : out Positive;
      Par_String   :     String);
   --  This function parses its Par_String parameter that is supposed to be a
   --  slice of the rule parameter obtained by
   --  Gnatcheck.Rules.Rule_Table.Process_Rule_Option (see also the
   --  documentation of Process_Rule_Parameter for Rule_Template type in
   --  Gnatcheck.Rules). If Par_String  contains a '=' character, it sets
   --  First_Par_Id and Last_Par_Id to point to the part of Par_String that
   --  precedes the (leftmost) '=' character (cutting out the leading and
   --  trailing white spaces if any), and First_Str_Id and Last_Str_Id are
   --  set to point to the part of Par_String that follows the (leftmost) '='
   --  character (cutting out the leading and trailing white spaces if any).
   --  If Par_String does not contain a '=' character, First_Str_Id is set to
   --  0 (Last_Str_Id is undefined), and First_Par_Id and Last_Par_Id point to
   --  the leftmost and rightmost non-blank characters of Par_String. If
   --  Par_String does not contain any non-blank character, First_Par_Id and
   --  First_Str_Id are set to 0, Last_Par_Id and Last_Str_Id are indefinite.
   --  If Par_String has '=' as it first (non-blank) character (most probably
   --  this means a bug in the parameter structure), First_Par_Id is set to 0,
   --  Last_Par_Id is indefinite, Last_Str_Id and Par_String are set to point
   --  to (non-blank) part of Par_String after '='.
   -------------------------------------
   -- Rule-specific local subprograms --
   -------------------------------------
   function Is_Access_Suffix (S : String) return Boolean;
   --  For Identifier_Suffixes rule.
   --  S is supposed to be the 'string' part from the +R parameter option, and
   --  it is known that Is_Identifier_Suffix (S) = False. The function checks
   --  if S has the structure Suffix1 (Suffix2), where
   --  Is_Identifier_Suffix (Suffix1) AND Is_Identifier_Suffix (Suffix2) = True
   function Is_Access_To_Access
     (Def  : Asis.Element;
      Arg  : Asis.Element)
      return Boolean;
   function Is_Access_To_Class (Def : Asis.Element) return Boolean;
   --  For Identifier_Prefixes and Identifier_Suffixes rules.
   --  Def is supposed to be of An_Access_Type_Definition kind. Checks if it
   --  defines an access to access type/access to class-wide type.
   --  In case of checking for access-to-access type we need a second argument
   --  to represent the place of the check. Consider:
   --
   --  package Pack1 is
   --     type PT1 is private;
   --     ...
   --  end Pack1;
   --
   --  package Pack2 is
   --     type PT2 is private;
   --  private
   --     type PT2 is access Integer;
   --
   --     type A1 is access Pack1.PT1;
   --     type A2 is access PT2;
   --
   --  A1 is not access-to-access, but A2 is, because at the place where A2 is
   --  defined the full view of PT2 is visible and PT2 is an access type but
   --  not a private type.
   -----------------------------------------------
   -- Bodies of general-purpose local functions --
   -----------------------------------------------
   ---------------
   -- Parse_Par --
   ---------------
   procedure Parse_Par
     (First_Par_Id : out Natural;
      Last_Par_Id  : out Positive;
      First_Str_Id : out Natural;
      Last_Str_Id  : out Positive;
      Par_String   :     String)
   is
      Eq_Pos : Natural := 0;
      Tmp    : Natural;
   begin
      for J in Par_String'Range loop
         if Par_String (J) = '=' then
            Eq_Pos := J;
            exit;
         end if;
      end loop;
      if Eq_Pos = 0 then
         Tmp := Par_String'Last;
      else
         Tmp := Eq_Pos - 1;
      end if;
      First_Par_Id := 0;
      for J in Par_String'First .. Tmp loop
         if not Is_White_Space (Par_String (J)) then
            First_Par_Id := J;
            exit;
         end if;
      end loop;
      if First_Par_Id > 0 then
         for J in reverse First_Par_Id .. Tmp loop
            if not Is_White_Space (Par_String (J)) then
               Last_Par_Id := J;
               exit;
            end if;
         end loop;
      end if;
      First_Str_Id := 0;
      if Eq_Pos > 0 then
         for J in Eq_Pos + 1 .. Par_String'Last loop
            if not Is_White_Space (Par_String (J)) then
               First_Str_Id := J;
               exit;
            end if;
         end loop;
         if First_Str_Id > 0 then
            for J in reverse First_Str_Id .. Par_String'Last loop
               if not Is_White_Space (Par_String (J)) then
                  Last_Str_Id := J;
                  exit;
               end if;
            end loop;
         end if;
      end if;
   end Parse_Par;
   -----------------------------------------------
   -- Bodies of rule-specific local subprograms --
   -----------------------------------------------
   -------------------------
   -- Is_Access_To_Access --
   -------------------------
   function Is_Access_To_Access
     (Def  : Asis.Element;
      Arg  : Asis.Element)
      return Boolean
   is
      Tmp, Tmp1 : Asis.Element;
      Result    : Boolean := False;
   begin
      if Access_Type_Kind (Def) in
        A_Pool_Specific_Access_To_Variable .. An_Access_To_Constant
      then
         Tmp := Asis.Definitions.Access_To_Object_Definition (Def);
         Tmp := Asis.Definitions.Subtype_Mark (Tmp);
         Tmp := Normalize_Reference (Tmp);
         Tmp := Corresponding_Name_Declaration (Tmp);
         if Declaration_Kind (Tmp) in
            An_Incomplete_Type_Declaration ..
            A_Tagged_Incomplete_Type_Declaration
         then
            Tmp1 := Corresponding_Type_Completion (Tmp);
            if not Is_Nil (Tmp1)
              and then
               Is_Equal (Enclosing_Compilation_Unit (Tmp),
                         Enclosing_Compilation_Unit (Tmp1))
            then
               --  For this check, we consider the full declaration instead of
               --  incomplete type declaration only if both of them are in the
               --  same unit.
               Tmp := Tmp1;
            end if;
         else
            Tmp := Corresponding_First_Subtype (Tmp);
         end if;
         if Declaration_Kind (Tmp) = A_Private_Type_Declaration
           and then
            Full_View_Visible (Tmp, At_Place => Arg)
         then
            Tmp := Corresponding_Type_Completion (Tmp);
         end if;
         Tmp := First_Name (Tmp);
         Result := Denotes_Access_Subtype (Tmp);
      end if;
      return Result;
   end Is_Access_To_Access;
   ------------------------
   -- Is_Access_To_Class --
   ------------------------
   function Is_Access_To_Class (Def : Asis.Element) return Boolean is
      Tmp      :          Asis.Element;
      Arg_Kind : constant Flat_Element_Kinds := Flat_Element_Kind (Def);
      Result   :          Boolean            := False;
   begin
      if Arg_Kind = A_Pool_Specific_Access_To_Variable        or else
         Arg_Kind = An_Access_To_Variable                     or else
         Arg_Kind = An_Access_To_Constant                     or else
         Arg_Kind = A_Formal_Pool_Specific_Access_To_Variable or else
         Arg_Kind = A_Formal_Access_To_Variable               or else
         Arg_Kind = A_Formal_Access_To_Constant
      then
         Tmp := Asis.Definitions.Access_To_Object_Definition (Def);
         Tmp := Asis.Definitions.Subtype_Mark (Tmp);
         if Attribute_Kind (Tmp) = A_Class_Attribute then
            Result := True;
         else
            if Expression_Kind (Tmp) = An_Identifier
              or else
               Expression_Kind (Tmp) = A_Selected_Component
            then
               Result := Denotes_Class_Wide_Subtype (Tmp);
            end if;
         end if;
      end if;
      return Result;
   end Is_Access_To_Class;
   ----------------------
   -- Is_Access_Suffix --
   ----------------------
   function Is_Access_Suffix (S : String) return Boolean is
      Parameter           : constant String  := Trim (S, Both);
      First_Idx           : constant Natural := Parameter'First;
      Last_Idx            : constant Natural := Parameter'Last - 1;
      Bracket_Idx         :          Natural;
      Result              :          Boolean := False;
   begin
      if Parameter (Last_Idx + 1) = ')' then
         Bracket_Idx := Index (Parameter, "(");
         if Bracket_Idx > 0 then
            if Is_Identifier_Suffix (To_Wide_String
                 (Trim (Parameter (First_Idx .. Bracket_Idx - 1), Right)))
            then
               Result :=
                 Is_Identifier_Suffix (To_Wide_String
                   (Trim (Parameter (Bracket_Idx + 1 .. Last_Idx), Left)));
            end if;
         end if;
      end if;
      return Result;
   end Is_Access_Suffix;
   --------------------------------------------
   -- Bodies of rule implementation routines --
   --------------------------------------------
   ----------------------
   -- Anonymous_Arrays --
   ----------------------
   ----------------------------------
   -- Init_Rule (Anonymous_Arrays) --
   ----------------------------------
   procedure Init_Rule (Rule : in out Anonymous_Arrays_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Anonymous_Arrays");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("anonymous array types");
      Rule.Diagnosis   := new String'("anonymous array type");
   end Init_Rule;
   ------------------------------------------
   -- Rule_Check_Pre_Op (Anonymous_Arrays) --
   ------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Anonymous_Arrays_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Type_Kind (Element) in
           An_Unconstrained_Array_Definition .. A_Constrained_Array_Definition
        and then
         Declaration_Kind (Get_Enclosing_Element) in
           A_Variable_Declaration .. A_Constant_Declaration
      then
         State.Detected  := True;
      end if;
   end Rule_Check_Pre_Op;
   -------------------------------------------
   -- Enumeration_Ranges_In_CASE_Statements --
   -------------------------------------------
   -------------------------------------------------------
   -- Init_Rule (Enumeration_Ranges_In_CASE_Statements) --
   -------------------------------------------------------
   procedure Init_Rule
     (Rule : in out Enumeration_Ranges_In_CASE_Statements_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Enumeration_Ranges_In_CASE_Statements");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("enumeration ranges as choices in case "
                                    & "statements");
      Rule.Diagnosis   := new String'("enumeration range as a choice in a "
                                    & "case statement");
   end Init_Rule;
   ---------------------------------------------------------------
   -- Rule_Check_Pre_Op (Enumeration_Ranges_In_CASE_Statements) --
   ---------------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Enumeration_Ranges_In_CASE_Statements_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Case_Var : Asis.Element;
   begin
      if Definition_Kind (Element) = A_Discrete_Range
       and then
         Path_Kind (Get_Enclosing_Element) = A_Case_Path
      then
         Case_Var := Case_Expression (Get_Enclosing_Element (Steps_Up => 1));
         if Has_Enumeration_Type (Case_Var) then
            State.Detected := True;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   --------------------------------
   -- Exceptions_As_Control_Flow --
   --------------------------------
   --------------------------------------------
   -- Init_Rule (Exceptions_As_Control_Flow) --
   --------------------------------------------
   procedure Init_Rule (Rule : in out Exceptions_As_Control_Flow_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Exceptions_As_Control_Flow");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("exceptions for control flow");
      Rule.Diagnosis   := new String'("this exception will be handled in " &
                                      "the same body, line%1%");
   end Init_Rule;
   ----------------------------------------------------
   -- Rule_Check_Pre_Op (Exceptions_As_Control_Flow) --
   ----------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Exceptions_As_Control_Flow_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Raised_Exc : Asis.Element;
      Encl_Body  : Asis.Element;
      Next_Frame : Asis.Element := Nil_Element;
      --  Construct that can contain exception handlers
      Step_Up    : Elmt_Idx := 0;
   begin
      if Statement_Kind (Element) = A_Raise_Statement then
         Raised_Exc := Raised_Exception (Element);
         if not Is_Nil (Raised_Exc) then
            --  First, get the enclosing body:
            Encl_Body := Get_Enclosing_Element (Step_Up);
            while Element_Kind (Encl_Body) in A_Statement .. A_Path loop
               Step_Up   := Step_Up + 1;
               Encl_Body := Get_Enclosing_Element (Step_Up);
            end loop;
            if Declaration_Kind (Encl_Body) not in
              A_Procedure_Body_Declaration .. A_Function_Body_Declaration
            then
               return;
            end if;
            Raised_Exc := Get_Name_Definition (Raised_Exc);
            Step_Up    := 0;
            Next_Frame := Get_Enclosing_Element (Step_Up);
            Check_Frames : loop
               --  Computing the next frame
               while not Is_Frame (Next_Frame) loop
                  Step_Up    := Step_Up + 1;
                  Next_Frame := Get_Enclosing_Element (Step_Up);
               end loop;
               --  Processing the next frame
               declare
                  Handlers : constant Asis.Element_List :=
                    Get_Handlers (Next_Frame);
                  Handler     : Asis.Element := Nil_Element;
                  Handled_Exc : Asis.Element;
               begin
                  if Handlers'Length = 0 then
                     return;
                  end if;
                  Check_Handlers : for J in Handlers'Range loop
                     declare
                        Exc_Choices : constant Asis.Element_List :=
                          Exception_Choices (Handlers (J));
                     begin
                        for K in Exc_Choices'Range loop
                           if Definition_Kind (Exc_Choices (K)) =
                              An_Others_Choice
                           then
                              State.Detected := True;
                           else
                              Handled_Exc :=
                                Get_Name_Definition (Exc_Choices (K));
                              State.Detected :=
                                Is_Equal (Raised_Exc, Handled_Exc);
                           end if;
                           if State.Detected then
                              Handler := Handlers (J);
                              State.Diag_Params := Enter_String ("%1%" &
                                 Element_Span (Handler).First_Line'Img);
                              exit Check_Frames;
                           end if;
                        end loop;
                     end;
                  end loop Check_Handlers;
               end;
               exit Check_Frames when Is_Equal (Next_Frame, Encl_Body);
               --  Go to the next frame
               Step_Up    := Step_Up + 1;
               Next_Frame := Get_Enclosing_Element (Step_Up);
            end loop Check_Frames;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   ---------------------------------------
   -- EXIT_Statements_With_No_Loop_Name --
   ---------------------------------------
   ---------------------------------------------------
   -- Init_Rule (EXIT_Statements_With_No_Loop_Name) --
   ---------------------------------------------------
   procedure Init_Rule
     (Rule : in out EXIT_Statements_With_No_Loop_Name_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("EXIT_Statements_With_No_Loop_Name");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("exit statements with no loop name");
      Rule.Diagnosis   := new String'("exit statement with no loop name");
   end Init_Rule;
   ---------------------------------------------------
   -- Init_Rule (EXIT_Statements_With_No_Loop_Name) --
   ---------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out EXIT_Statements_With_No_Loop_Name_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Statement_Kind (Element) = An_Exit_Statement
        and then
         Is_Nil (Exit_Loop_Name (Element))
      then
         State.Detected := True;
      end if;
   end Rule_Check_Pre_Op;
   -----------------------------------
   -- Explicit_Full_Discrete_Ranges --
   -----------------------------------
   ------------------------------------------------
   --  Init_Rule (Explicit_Full_Discrete_Ranges) --
   ------------------------------------------------
   procedure Init_Rule (Rule : in out Explicit_Full_Discrete_Ranges_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Explicit_Full_Discrete_Ranges");
      Rule.Synonym     := new String'("Explicit_Discrete_Ranges");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("explicit discrete ranges");
      Rule.Diagnosis   :=
        new String'("#1#bad discrete range, consider replacement " &
                       "with subtype mark"                         &
                    "#2#bad discrete range, consider replacement " &
                       "with 'Range attribute");
   end Init_Rule;
   --------------------------------------------------------
   --  Rule_Check_Pre_Op (Explicit_Full_Discrete_Ranges) --
   --------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Explicit_Full_Discrete_Ranges_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      L, R : Asis.Element;
   begin
      if Discrete_Range_Kind (Element) =
           A_Discrete_Simple_Expression_Range
      then
         L := Lower_Bound (Element);
         if Attribute_Kind (L) = A_First_Attribute then
            R := Upper_Bound (Element);
            if Attribute_Kind (R) = A_Last_Attribute then
               --  The argument discrete range is to be detected only if
               --  L and R are or ends with the same identifier
               L := Prefix (L);
               R := Prefix (R);
               if Expression_Kind (L) = A_Selected_Component then
                  L := Selector (L);
               end if;
               if Expression_Kind (R) = A_Selected_Component then
                  L := Selector (R);
               end if;
               if Expression_Kind (L) = An_Identifier
                 and then
                  Expression_Kind (R) = An_Identifier
                 and then
                  To_Lower (To_String (Name_Image (L))) =
                  To_Lower (To_String (Name_Image (R)))
               then
                  --  Now we have to check that L (and, therefore R) is
                  --  either a subtype mark of a discrete (sub)type or a
                  --  reference to an array data object
                  L := Corresponding_Name_Declaration (L);
                  case Declaration_Kind (L) is
                     when An_Ordinary_Type_Declaration |
                          A_Subtype_Declaration        =>
                        --  It must be a discrete (sub)type!
                        State.Detected  := True;
                        State.Diagnosis := 1;
                     when A_Variable_Declaration          |
                          A_Constant_Declaration          |
                          A_Component_Declaration         |
                          A_Parameter_Specification       |
                          A_Return_Variable_Specification |
                          A_Return_Constant_Specification |
                          An_Object_Renaming_Declaration  |
                          A_Formal_Object_Declaration     =>
                        --  It must be a declaration of an array object or an
                        --  access object that points to an array object!
                        State.Detected  := True;
                        State.Diagnosis := 2;
                     when others =>
                        null;
                  end case;
               end if;
            end if;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   --------------------------
   -- Forbidden_Attributes --
   --------------------------
   --------------------------------------------------------
   -- Data structures and local subprograms for the rule --
   --------------------------------------------------------
   type Check_Status is (Off, On, Selective);
   --  The values of this type say if a given attribute/pragma should be
   --  detected. The Selective value is used only for
   --  An_Implementation_Defined_Attribute/An_Implementation_Defined_Pragma
   --  kinds, it means that only some of the GNAT-specific attributes/pragmas
   --  should be detected.
   Attribute_Check_Switch :
     array (Asis.Attribute_Kinds'(An_Access_Attribute) ..
             Asis.Attribute_Kinds'(An_Unknown_Attribute)) of Check_Status :=
               (others => Off);
   --  Specifies which pragmas should be detected.
   GNAT_Attribute_Check_Switch :
     array (Snames.Attribute_Id) of Boolean := (others => False);
   --  Specifies which GNAT-specific attributes should be detected. Note, that
   --  the index range covers all the attribute IDs, both standard and
   --  GNAT-specific, but only those components that correspond to
   --  GNAT-specific attributes are referenced
   function Get_Attribute_Kind (S : String) return Attribute_Kinds;
   --  Tries to get from its argument (that is treated as an (an identifier
   --  from) attribute designator and is supposed to be obtained from the rule
   --  parameter) the corresponding ASIS Attribute_Kinds value. If S does not
   --  have a structure of an identifier, returns Not_An_Attribute
   procedure Get_GNAT_Attribute_Id
     (S       :     String;
      Id      : out Snames.Attribute_Id;
      Success : out Boolean);
   --  Supposing that S is a name of a GNAT attribute, computes its
   --  Attribute_Id. Sets Success OFF if the argument is not a name of a
   --  GNAT-specific attribute, otherwise Success is set ON.
   --------------------------------------------------
   -- Activate_In_Test_Mode (Forbidden_Attributes) --
   --------------------------------------------------
   overriding procedure Activate_In_Test_Mode
     (Rule : in out Forbidden_Attributes_Rule_Type)
   is
   begin
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Range",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Access",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Img",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Object_Size",
         Enable => True);
   end Activate_In_Test_Mode;
   --------------------------------------------------
   -- Get_GNAT_Attribute_Id (Forbidden_Attributes) --
   --------------------------------------------------
   procedure Get_GNAT_Attribute_Id
     (S       :     String;
      Id      : out Snames.Attribute_Id;
      Success : out Boolean)
   is
      use Namet;
      Attribute_Name_Id : Namet.Name_Id;
   begin
      if Is_Identifier (To_Wide_String (S)) then
         Name_Len                    := S'Length;
         Name_Buffer (1 .. Name_Len) := To_Lower (S);
         Attribute_Name_Id           := Name_Find;
         if Attribute_Name_Id in
              Snames.First_Attribute_Name .. Snames.Last_Attribute_Name
         then
            Id      := Snames.Get_Attribute_Id (Attribute_Name_Id);
            Success := True;
         else
            Success := False;
         end if;
      end if;
   end Get_GNAT_Attribute_Id;
   -----------------------------------------------
   -- Get_Attribute_Kind (Forbidden_Attributes) --
   -----------------------------------------------
   function Get_Attribute_Kind (S : String) return Attribute_Kinds is
      use  type Snames.Attribute_Id;
      Result  : Attribute_Kinds := Not_An_Attribute;
      Attr_Id : Snames.Attribute_Id;
      pragma Warnings (Off, Attr_Id);
      --  We need Attr_Id only as a placeholder in the call to
      --  Get_GNAT_Attribute_Id
      Success : Boolean;
   begin
      if Is_Identifier (To_Wide_String (S)) then
         begin
            case To_Lower (S (S'First)) is
               when 'a' | 'e' | 'i' | 'o' | 'u'  =>
                  Result := Attribute_Kinds'Value ("an_" & S & "_attribute");
               when others =>
                  Result := Attribute_Kinds'Value ("a_" & S & "_attribute");
            end case;
         exception
            when Constraint_Error =>
               Result := An_Unknown_Attribute;
         end;
      end if;
      if Result = An_Unknown_Attribute then
         --  We can have a GNAT-specific pragma here!
         Get_GNAT_Attribute_Id (S, Attr_Id, Success);
         if Success then
            Result := An_Implementation_Defined_Attribute;
         end if;
      end if;
      return Result;
   end Get_Attribute_Kind;
   --------------------------------------
   -- Init_Rule (Forbidden_Attributes) --
   --------------------------------------
   procedure Init_Rule (Rule : in out Forbidden_Attributes_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Forbidden_Attributes");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("usage of specified attributes");
      Rule.Diagnosis   := new String'("use of attribute %1%");
   end Init_Rule;
   ---------------------------------------
   -- Print_Rule (Forbidden_Attributes) --
   ---------------------------------------
   procedure Print_Rule
     (Rule         : Forbidden_Attributes_Rule_Type;
      Indent_Level : Natural := 0)
   is
      All_On        : Boolean := True;
      First_Param   : Boolean := True;
      Rule_Name_Pad : constant String (1 .. Rule_Name (Rule)'Length + 2) :=
        (others => ' ');
   begin
      Print_Rule (Rule_Template (Rule), Indent_Level);
      --  Special case: all attributes are ON
      for J in Asis.Attribute_Kinds'(An_Access_Attribute) ..
               Asis.Attribute_Kinds'(An_Implementation_Defined_Attribute)
      loop
         if Attribute_Check_Switch (J) /= On then
            All_On := False;
            exit;
         end if;
      end loop;
      if All_On then
         Report_No_EOL (": ALL");
         return;
      end if;
      --  Standard Ada attributes
      for J in Asis.Attribute_Kinds'(An_Access_Attribute) ..
               Asis.Attribute_Kinds'(A_Wide_Wide_Width_Attribute)
      loop
         if Attribute_Check_Switch (J) = On then
            if First_Param then
               Report_No_EOL (": " & Ada_Attribute_Designator (J));
               First_Param := False;
            else
               Report (",");
               Report_No_EOL
                 (Rule_Name_Pad &
                  Ada_Attribute_Designator (J),
                  Indent_Level);
            end if;
         end if;
      end loop;
      case Attribute_Check_Switch (An_Implementation_Defined_Attribute) is
         when Off =>
            null;
         when On =>
            if First_Param then
               Report_No_EOL (": GNAT");
            else
               Report (",");
               Report_No_EOL (Rule_Name_Pad & "GNAT", Indent_Level);
            end if;
         when Selective =>
            for J in GNAT_Attribute_Check_Switch'Range loop
               if GNAT_Attribute_Check_Switch (J) then
                  if First_Param then
                     Report_No_EOL (": " & GNAT_Attribute_Designator (J));
                     First_Param := False;
                  else
                     Report (",");
                     Report_No_EOL
                       (Rule_Name_Pad &
                        GNAT_Attribute_Designator (J),
                        Indent_Level);
                  end if;
               end if;
            end loop;
      end case;
   end Print_Rule;
   -----------------------------------------------
   -- Print_Rule_To_File (Forbidden_Attributes) --
   -----------------------------------------------
   overriding procedure Print_Rule_To_File
     (Rule         : Forbidden_Attributes_Rule_Type;
      Rule_File    : File_Type;
      Indent_Level : Natural := 0)
   is
      All_On        : Boolean := True;
      First_Param   : Boolean := True;
      Rule_Name_Pad : constant String (1 .. Rule_Name (Rule)'Length + 2) :=
        (others => ' ');
   begin
      Print_Rule_To_File (Rule_Template (Rule), Rule_File, Indent_Level);
      --  Special case: all attributes are ON
      for J in Asis.Attribute_Kinds'(An_Access_Attribute) ..
               Asis.Attribute_Kinds'(An_Implementation_Defined_Attribute)
      loop
         if Attribute_Check_Switch (J) /= On then
            All_On := False;
            exit;
         end if;
      end loop;
      if All_On then
         Report_No_EOL (": ALL");
         return;
      end if;
      --  Standard Ada attributes
      for J in Asis.Attribute_Kinds'(An_Access_Attribute) ..
               Asis.Attribute_Kinds'(A_Wide_Wide_Width_Attribute)
      loop
         if Attribute_Check_Switch (J) = On then
            if First_Param then
               Put (Rule_File, ": " & Ada_Attribute_Designator (J));
               First_Param := False;
            else
               Put_Line (Rule_File, ",");
               for J in 1 .. Indent_Level loop
                  Put (Rule_File, Get_Indent_String);
               end loop;
               Put (Rule_File, Rule_Name_Pad & Ada_Attribute_Designator (J));
            end if;
         end if;
      end loop;
      case Attribute_Check_Switch (An_Implementation_Defined_Attribute) is
         when Off =>
            null;
         when On =>
            if First_Param then
               Put (Rule_File, ": GNAT");
            else
               Put_Line (Rule_File, ",");
               for J in 1 .. Indent_Level loop
                  Put (Rule_File, Get_Indent_String);
               end loop;
               Put (Rule_File, Rule_Name_Pad & "GNAT");
            end if;
         when Selective =>
            for J in GNAT_Attribute_Check_Switch'Range loop
               if GNAT_Attribute_Check_Switch (J) then
                  if First_Param then
                     Put (Rule_File, ": " & GNAT_Attribute_Designator (J));
                     First_Param := False;
                  else
                     Put_Line (Rule_File, ",");
                     for J in 1 .. Indent_Level loop
                        Put (Rule_File, Get_Indent_String);
                     end loop;
                     Put (Rule_File,
                          Rule_Name_Pad & GNAT_Attribute_Designator (J));
                  end if;
               end if;
            end loop;
      end case;
   end Print_Rule_To_File;
   ---------------------------------------------------
   -- Process_Rule_Parameter (Forbidden_Attributes) --
   ---------------------------------------------------
   procedure Process_Rule_Parameter
     (Rule    : in out Forbidden_Attributes_Rule_Type;
      Param   :        String;
      Enable  :        Boolean)
   is
      Arg_Kind       : Attribute_Kinds;
      GNAT_Attribute : Snames.Attribute_Id;
      Success        : Boolean;
   begin
      if Param = "" then
         if Enable then
            Rule.Rule_State := Enabled;
         else
            Rule.Rule_State := Disabled;
         end if;
         return;
      end if;
      if To_Lower (Param) = "gnat" then
         if Enable then
            Attribute_Check_Switch (An_Implementation_Defined_Attribute) := On;
            Rule.Rule_State := Enabled;
         else
            Attribute_Check_Switch (An_Implementation_Defined_Attribute) :=
              Off;
         end if;
         return;
      end if;
      if To_Lower (Param) = "all" then
         if Enable then
            Attribute_Check_Switch      := (others => On);
            GNAT_Attribute_Check_Switch := (others => True);
            Rule.Rule_State := Enabled;
            Attribute_Check_Switch (An_Implementation_Defined_Attribute) :=
              Selective;
         else
            Attribute_Check_Switch      := (others => Off);
            GNAT_Attribute_Check_Switch := (others => False);
            Rule.Rule_State             := Disabled;
         end if;
         return;
      end if;
      Arg_Kind := Get_Attribute_Kind (Param);
      case Arg_Kind is
         when Not_An_Attribute =>
            Error ("(" & Rule.Name.all & ") wrong attribute designator : " &
                   Param);
         when An_Implementation_Defined_Attribute =>
            Get_GNAT_Attribute_Id (Param, GNAT_Attribute, Success);
            if Enable then
               if Attribute_Check_Switch (Arg_Kind) = Off then
                  Attribute_Check_Switch (Arg_Kind) := Selective;
               end if;
               if Success then
                  GNAT_Attribute_Check_Switch (GNAT_Attribute) := True;
               end if;
               Rule.Rule_State := Enabled;
            else
               GNAT_Attribute_Check_Switch (GNAT_Attribute) := False;
            end if;
         when others =>
            --  Only specific attribute kinds and An_Unknown_Attribute are
            --  possible
            if Enable then
               Attribute_Check_Switch (Arg_Kind) := On;
               Rule.Rule_State := Enabled;
            else
               Attribute_Check_Switch (Arg_Kind) := Off;
            end if;
      end case;
   end Process_Rule_Parameter;
   ----------------------------------------------
   -- Rule_Check_Pre_Op (Forbidden_Attributes) --
   ----------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Forbidden_Attributes_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      El_Kind : constant Attribute_Kinds := Attribute_Kind (Element);
      pragma Unreferenced (Control);
      pragma Unreferenced (Rule);
   begin
      if Expression_Kind (Element) = An_Attribute_Reference then
         if Attribute_Check_Switch (El_Kind) = On then
            State.Detected := True;
         elsif Attribute_Check_Switch (El_Kind) = Selective then
            declare
               Attr_Designator : constant String :=
                 To_String
                  (Name_Image (Attribute_Designator_Identifier (Element)));
               Attr_Id : Snames.Attribute_Id;
               Success : Boolean;
            begin
               Get_GNAT_Attribute_Id (Attr_Designator, Attr_Id, Success);
               State.Detected :=
                 GNAT_Attribute_Check_Switch (Attr_Id);
            end;
         end if;
         if State.Detected then
            State.Diag_Params := Enter_String ("%1%" &
              To_String (Name_Image (
                Attribute_Designator_Identifier (Element))));
         end if;
      end if;
   end Rule_Check_Pre_Op;
   ------------------------------------------
   -- XML_Rule_Help (Forbidden_Attributes) --
   ------------------------------------------
   procedure XML_Rule_Help
     (Rule  : Forbidden_Attributes_Rule_Type;
      Level : Natural)
   is
   begin
      Info (Level * Ident_String                               &
            "<check  switch=""+R"                              &
            Rule.Name.all                                      &
            ":ALL"""                                           &
            " label="""                                        &
            "detect all attributes except explicitly disabled""/>");
      Info (Level * Ident_String                                &
            "<check  switch=""+R"                               &
            Rule.Name.all                                       &
            ":GNAT"""                                           &
            " label="""                                         &
            "detect all GNAT attributes except explicitly disabled""/>");
      Info (Level * Ident_String                                   &
            "<field switch=""+R"                                   &
            Rule.Name.all                                          &
            """ label="""                                          &
            "detect specified attributes (use ',' as separator)""" &
            " separator="":"""                                     &
            "/>");
      Info (Level * Ident_String                                          &
            "<field switch=""-R"                                          &
            Rule.Name.all                                                 &
            """ label="""                                                 &
            "do not detect specified attributes (use ',' as separator)""" &
            " separator="":"""                                            &
            "/>");
   end XML_Rule_Help;
   -----------------------
   -- Forbidden_Pragmas --
   -----------------------
   --------------------------------------------------------
   -- Data structures and local subprograms for the rule --
   --------------------------------------------------------
   Pragma_Check_Switch :
     array (Asis.Pragma_Kinds'(An_All_Calls_Remote_Pragma) ..
            Asis.Pragma_Kinds'(An_Unknown_Pragma)) of Check_Status :=
              (others => Off);
   --  Specifies which pragma should be detected.
   GNAT_Pragma_Check_Switch :
     array (Snames.Pragma_Id) of Boolean := (others => False);
   --  Specifies which GNAT-specific pragmas should be detected. Note, that
   --  the index range covers all the pragma IDs, both standard and
   --  GNAT-specific, but only those components that correspond to
   --  GNAT-specific pragmas are referenced
   function Get_Pragma_Kind (S : String) return Pragma_Kinds;
   --  Tries to get from its argument (that is treated as a pragma name and is
   --  supposed to be obtained from the rule parameter) the corresponding
   --  ASIS Pragma_Kinds value. If S does not have a structure of an
   --  identifier, returns Not_A_Pragma
   function Get_GNAT_Pragma_Id (S : String) return Snames.Pragma_Id;
   --  Supposing that S is a name of a GNAT pragma, computes its Pragma_Id.
   --  Returns Unknown_Pragma if the argument is not a name of a GNAT-specific
   --  pragma.
   -----------------------------------------------
   -- Activate_In_Test_Mode (Forbidden_Pragmas) --
   -----------------------------------------------
   overriding procedure Activate_In_Test_Mode
     (Rule : in out Forbidden_Pragmas_Rule_Type)
   is
   begin
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Inline",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Suppress",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Initialize_Scalars",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Keep_Names",
         Enable => True);
   end Activate_In_Test_Mode;
   --------------------------------------------
   -- Get_GNAT_Pragma_Id (Forbidden_Pragmas) --
   --------------------------------------------
   function Get_GNAT_Pragma_Id (S : String) return Snames.Pragma_Id is
      use Namet;
      Result : Snames.Pragma_Id := Snames.Unknown_Pragma;
      Pragma_Name_Id : Namet.Name_Id;
   begin
      if Is_Identifier (To_Wide_String (S)) then
         Name_Len                    := S'Length;
         Name_Buffer (1 .. Name_Len) := To_Lower (S);
         Pragma_Name_Id              := Name_Find;
         Result                      := Snames.Get_Pragma_Id (Pragma_Name_Id);
      end if;
      return Result;
   end Get_GNAT_Pragma_Id;
   -----------------------------------------
   -- Get_Pragma_Kind (Forbidden_Pragmas) --
   -----------------------------------------
   function Get_Pragma_Kind (S : String) return Pragma_Kinds is
      use  type Snames.Pragma_Id;
      Result : Pragma_Kinds := Not_A_Pragma;
   begin
      if Is_Identifier (To_Wide_String (S)) then
         begin
            case To_Lower (S (S'First)) is
               when 'a' | 'e' | 'i' | 'o' | 'u'  =>
                  Result := Pragma_Kinds'Value ("an_" & S & "_pragma");
               when others =>
                  Result := Pragma_Kinds'Value ("a_" & S & "_pragma");
            end case;
         exception
            when Constraint_Error =>
               Result := An_Unknown_Pragma;
         end;
      end if;
      if Result = An_Unknown_Pragma then
         --  We can have a GNAT-specific pragma here!
         if Get_GNAT_Pragma_Id (S) /= Snames.Unknown_Pragma then
            Result := An_Implementation_Defined_Pragma;
         end if;
      end if;
      return Result;
   end Get_Pragma_Kind;
   -----------------------------------
   -- Init_Rule (Forbidden_Pragmas) --
   -----------------------------------
   procedure Init_Rule (Rule : in out Forbidden_Pragmas_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Forbidden_Pragmas");
      Rule.Synonym     := new String'("Pragma_Usage");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("usage of specified pragmas");
      Rule.Diagnosis   := new String'("use of pragma %1%");
   end Init_Rule;
   ------------------------------------
   -- Print_Rule (Forbidden_Pragmas) --
   ------------------------------------
   procedure Print_Rule
     (Rule         : Forbidden_Pragmas_Rule_Type;
      Indent_Level : Natural := 0)
   is
      All_On        : Boolean := True;
      First_Param   : Boolean := True;
      Rule_Name_Pad : constant String (1 .. Rule_Name (Rule)'Length + 2) :=
        (others => ' ');
   begin
      Print_Rule (Rule_Template (Rule), Indent_Level);
      --  Special case: all pragmas are ON
      for J in Asis.Pragma_Kinds'(An_All_Calls_Remote_Pragma) ..
               Asis.Pragma_Kinds'(An_Implementation_Defined_Pragma)
      loop
         if Pragma_Check_Switch (J) /= On then
            All_On := False;
            exit;
         end if;
      end loop;
      if All_On then
         Report_No_EOL (": ALL");
         return;
      end if;
      --  Standard Ada pragmas
      for J in Asis.Pragma_Kinds'(An_All_Calls_Remote_Pragma) ..
               Asis.Pragma_Kinds'(An_Unsuppress_Pragma)
      loop
         if Pragma_Check_Switch (J) = On then
            if First_Param then
               Report_No_EOL (": " & Ada_Pragma_Identifier (J));
               First_Param := False;
            else
               Report (",");
               Report_No_EOL
                 (Rule_Name_Pad &
                  Ada_Pragma_Identifier (J),
                  Indent_Level);
            end if;
         end if;
      end loop;
      case Pragma_Check_Switch (An_Implementation_Defined_Pragma) is
         when Off =>
            null;
         when On =>
            if First_Param then
               Report_No_EOL (": GNAT");
            else
               Report (",");
               Report_No_EOL (Rule_Name_Pad & "GNAT", Indent_Level);
            end if;
         when Selective =>
            for J in GNAT_Pragma_Check_Switch'Range loop
               if GNAT_Pragma_Check_Switch (J) then
                  if First_Param then
                     Report_No_EOL (": " & GNAT_Pragma_Identifier (J));
                     First_Param := False;
                  else
                     Report (",");
                     Report_No_EOL
                       (Rule_Name_Pad &
                        GNAT_Pragma_Identifier (J),
                        Indent_Level);
                  end if;
               end if;
            end loop;
      end case;
   end Print_Rule;
   --------------------------------------------
   -- Print_Rule_To_File (Forbidden_Pragmas) --
   --------------------------------------------
   overriding procedure Print_Rule_To_File
     (Rule         : Forbidden_Pragmas_Rule_Type;
      Rule_File    : File_Type;
      Indent_Level : Natural := 0)
   is
      All_On        : Boolean := True;
      First_Param   : Boolean := True;
      Rule_Name_Pad : constant String (1 .. Rule_Name (Rule)'Length + 2) :=
        (others => ' ');
   begin
      Print_Rule_To_File (Rule_Template (Rule), Rule_File, Indent_Level);
      --  Special case: all pragmas are ON
      for J in Asis.Pragma_Kinds'(An_All_Calls_Remote_Pragma) ..
               Asis.Pragma_Kinds'(An_Implementation_Defined_Pragma)
      loop
         if Pragma_Check_Switch (J) /= On then
            All_On := False;
            exit;
         end if;
      end loop;
      if All_On then
         Put (Rule_File, ": ALL");
         return;
      end if;
      --  Standard Ada pragmas
      for J in Asis.Pragma_Kinds'(An_All_Calls_Remote_Pragma) ..
               Asis.Pragma_Kinds'(An_Unsuppress_Pragma)
      loop
         if Pragma_Check_Switch (J) = On then
            if First_Param then
               Put (Rule_File, ": " & Ada_Pragma_Identifier (J));
               First_Param := False;
            else
               Put_Line (Rule_File, ",");
               for J in 1 .. Indent_Level loop
                  Put (Rule_File, Get_Indent_String);
               end loop;
               Put (Rule_File, Rule_Name_Pad & Ada_Pragma_Identifier (J));
            end if;
         end if;
      end loop;
      case Pragma_Check_Switch (An_Implementation_Defined_Pragma) is
         when Off =>
            null;
         when On =>
            if First_Param then
               Put (Rule_File, ": GNAT");
            else
               Put (Rule_File, ",");
               for J in 1 .. Indent_Level loop
                  Put (Rule_File, Get_Indent_String);
               end loop;
               Put (Rule_File, Rule_Name_Pad & "GNAT");
            end if;
         when Selective =>
            for J in GNAT_Pragma_Check_Switch'Range loop
               if GNAT_Pragma_Check_Switch (J) then
                  if First_Param then
                     Put (Rule_File, ": " & GNAT_Pragma_Identifier (J));
                     First_Param := False;
                  else
                     Put_Line (Rule_File, ",");
                     for J in 1 .. Indent_Level loop
                        Put (Rule_File, Get_Indent_String);
                     end loop;
                     Put (Rule_File,
                          Rule_Name_Pad & GNAT_Pragma_Identifier (J));
                  end if;
               end if;
            end loop;
      end case;
   end Print_Rule_To_File;
   ------------------------------------------------
   -- Process_Rule_Parameter (Forbidden_Pragmas) --
   ------------------------------------------------
   procedure Process_Rule_Parameter
     (Rule    : in out Forbidden_Pragmas_Rule_Type;
      Param   :        String;
      Enable  :        Boolean)
   is
      Arg_Kind    : Pragma_Kinds;
      GNAT_Pragma : Snames.Pragma_Id;
   begin
      if Param = "" then
         if Enable then
            Rule.Rule_State := Enabled;
         else
            Rule.Rule_State := Disabled;
         end if;
         return;
      end if;
      if To_Lower (Param) = "gnat" then
         if Enable then
            Pragma_Check_Switch (An_Implementation_Defined_Pragma) := On;
            Rule.Rule_State := Enabled;
         else
            Pragma_Check_Switch (An_Implementation_Defined_Pragma) := Off;
         end if;
         return;
      end if;
      if To_Lower (Param) = "all" then
         if Enable then
            Pragma_Check_Switch      := (others => On);
            GNAT_Pragma_Check_Switch := (others => True);
            Rule.Rule_State          := Enabled;
            Pragma_Check_Switch (An_Implementation_Defined_Pragma) :=
              Selective;
         else
            Pragma_Check_Switch      := (others => Off);
            GNAT_Pragma_Check_Switch := (others => False);
            Rule.Rule_State          := Disabled;
         end if;
         return;
      end if;
      Arg_Kind := Get_Pragma_Kind (Param);
      case Arg_Kind is
         when Not_A_Pragma =>
            Error ("(" & Rule.Name.all & ") wrong pragma name : " & Param);
         when An_Implementation_Defined_Pragma =>
            GNAT_Pragma := Get_GNAT_Pragma_Id (Param);
            if Enable then
               if Pragma_Check_Switch (Arg_Kind) = Off then
                  Pragma_Check_Switch (Arg_Kind) := Selective;
               end if;
               GNAT_Pragma_Check_Switch (GNAT_Pragma) := True;
               Rule.Rule_State                        := Enabled;
            else
               GNAT_Pragma_Check_Switch (GNAT_Pragma) := False;
            end if;
         when others =>
            --  Only specific pragma kinds and An_Unknown_Pragma are possible
            if Enable then
               Pragma_Check_Switch (Arg_Kind) := On;
               Rule.Rule_State := Enabled;
            else
               Pragma_Check_Switch (Arg_Kind) := Off;
            end if;
      end case;
   end Process_Rule_Parameter;
   -------------------------------------------
   -- Rule_Check_Pre_Op (Forbidden_Pragmas) --
   -------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Forbidden_Pragmas_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      El_Kind : constant Pragma_Kinds := Pragma_Kind (Element);
      pragma Unreferenced (Control);
      pragma Unreferenced (Rule);
   begin
      if Element_Kind (Element) = A_Pragma then
         if Pragma_Check_Switch (El_Kind) = On then
            State.Detected := True;
         elsif Pragma_Check_Switch (El_Kind) = Selective then
            State.Detected :=
              GNAT_Pragma_Check_Switch (Get_GNAT_Pragma_Id
                (To_String (Pragma_Name_Image (Element))));
         end if;
         if State.Detected then
            State.Diag_Params :=
              Enter_String ("%1%" & To_String (Pragma_Name_Image (Element)));
         end if;
      end if;
   end Rule_Check_Pre_Op;
   ---------------------------------------
   -- XML_Rule_Help (Forbidden_Pragmas) --
   ---------------------------------------
   procedure XML_Rule_Help
     (Rule  : Forbidden_Pragmas_Rule_Type;
      Level : Natural)
   is
   begin
      Info (Level * Ident_String                               &
            "<check  switch=""+R"                              &
            Rule.Name.all                                      &
            ":ALL"""                                           &
            " label="""                                        &
            "detect all pragmas except explicitly disabled""/>");
      Info (Level * Ident_String                                &
            "<check  switch=""+R"                               &
            Rule.Name.all                                       &
            ":GNAT"""                                           &
            " label="""                                         &
            "detect all GNAT pragmas except explicitly disabled""/>");
      Info (Level * Ident_String                                &
            "<field switch=""+R"                                &
            Rule.Name.all                                       &
            """ label="""                                       &
            "detect specified pragmas (use ',' as separator)""" &
            " separator="":"""                                  &
            "/>");
      Info (Level * Ident_String                                       &
            "<field switch=""-R"                                       &
            Rule.Name.all                                              &
            """ label="""                                              &
            "do not detect specified pragmas (use ',' as separator)""" &
            " separator="":"""                                         &
            "/>");
   end XML_Rule_Help;
   -----------------------------
   -- Function_Style_Procedures --
   -----------------------------
   -------------------------------------------
   -- Init_Rule (Function_Style_Procedures) --
   -------------------------------------------
   procedure Init_Rule (Rule : in out Function_Style_Procedures_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Function_Style_Procedures");
      Rule.Synonym     := new String'("Functionlike_Procedures");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("procedures looking like functions");
      Rule.Diagnosis  := new String'("procedure can be rewritten as function");
   end Init_Rule;
   ---------------------------------------------------
   -- Rule_Check_Pre_Op (Function_Style_Procedures) --
   ---------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Function_Style_Procedures_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Consider_Replacement_With_Function : Boolean := False;
   begin
      case Declaration_Kind (Element) is
         when A_Procedure_Declaration =>
            Consider_Replacement_With_Function :=
              Definition_Kind (Get_Enclosing_Element) /=
                A_Protected_Definition;
         when A_Generic_Procedure_Declaration |
              A_Formal_Procedure_Declaration  =>
            Consider_Replacement_With_Function := True;
         when A_Procedure_Body_Declaration |
              A_Procedure_Body_Stub        =>
            Consider_Replacement_With_Function := Acts_As_Spec (Element);
         when others =>
            null;
      end case;
      if Consider_Replacement_With_Function then
         State.Detected := Can_Be_Replaced_With_Function (Element);
      end if;
   end Rule_Check_Pre_Op;
   -----------------------------
   -- Generics_In_Subprograms --
   -----------------------------
   -----------------------------------------
   -- Init_Rule (Generics_In_Subprograms) --
   -----------------------------------------
   procedure Init_Rule (Rule : in out Generics_In_Subprograms_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Generics_In_Subprograms");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("definitions of generic units in " &
                                      " subprogram bodies");
      Rule.Diagnosis   := new String'("generic definition in subprogram " &
                                      "body starting at line %1%");
   end Init_Rule;
   -------------------------------------------------
   -- Rule_Check_Pre_Op (Generics_In_Subprograms) --
   -------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Generics_In_Subprograms_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Encl_Body : Asis.Element;
      Step_Up   : Elmt_Idx := 0;
   begin
      if Declaration_Kind (Element) in A_Generic_Declaration then
         Encl_Body := Get_Enclosing_Element;
         while not Is_Nil (Encl_Body) loop
            case Declaration_Kind (Encl_Body) is
               when A_Procedure_Body_Declaration |
                    A_Function_Body_Declaration  =>
                  State.Detected := True;
                  exit;
               when A_Generic_Package_Declaration =>
                  exit;
               when others =>
                  Step_Up   := Step_Up + 1;
                  Encl_Body := Get_Enclosing_Element (Step_Up);
            end case;
         end loop;
         if State.Detected then
            State.Diag_Params := Enter_String ("%1%" &
                                 Element_Span (Encl_Body).First_Line'Img);
         end if;
      end if;
   end Rule_Check_Pre_Op;
   -----------------------
   -- Identifier_Casing --
   -----------------------
   --------------------------------------------------------
   -- Data structures and local subprograms for the rule --
   --------------------------------------------------------
   type Identifier_Casing_Parameter_Kinds is
     (Not_A_Parameter,
      Type_Par,
      Constant_Par,
      Exception_Par,
      Enum_Par,
      Others_Par,
      Exclude_Par);
   type Wildcard_Kinds is
     (Not_A_Wildcard,
      Left,    --  ABC*
      Right,   --  *ABC
      Both);   --  *ABC*
   --  ???
   function Get_Pattern (W : String; WK : Wildcard_Kinds) return String;
   --  W is supposed to be a wildcard with '*' stripped away. The function
   --  returns a pattern that is stored for the given wildcard. If 'ABC' is the
   --  actual for W the result is:
   --
   --  WK = Not_A_Wildcard   -> ABC
   --  WK = Left             -> ABC_
   --  WK = Right            -> _ABC
   --  WK = Both             -> _ABC_
   procedure Check_With_Word_Dictionary
     (Name        :        Program_Text_Access;
      Dict        :        String_Access_Sets.Set;
      State       : in out Rule_Traversal_State;
      Not_In_Dict :    out Boolean);
   --  Check Name against dictionary Dict, State is set according to the
   --  results of the check. Dict is the dictionary that contains only whole
   --  words but not wildcards. Not_In_Dict is set to False if Name is found in
   --  Dict and True otherwise
   function Get_Diag_Variant (E : Asis.Element) return Diagnosis_Variant;
   --  Detects the diagnosis variant from the argument.
   function Get_Identifier_Casing_Parameter_Kind
     (S    : String)
      return Identifier_Casing_Parameter_Kinds;
   --  If S denotes one of the rule parameters, returns the corresponding
   --  parameter kind, otherwise Not_A_Parameter is returned
   function Get_Casing_Scheme (S : String) return Casing_Schemes;
   --  If S represents one of the casing schemes, returns the corresponding
   --  literal of Casing_Schemes, and Not_A_Casing_Scheme otherwise.
   procedure Scan_Dictionary_File
     (Stored_Exceptions : in out String_Access_Sets.Set;
      Stored_Wildcards  : in out Wildcard_Sets.Set;
      D_File_Name       :        String_Access);
   --  If D_File_Name is the name of an existing file, scans it as a dictionary
   --  file and places all the valid casing exceptions into Stored_Exceptions.
   procedure Check_Casing
     (Name      : Program_Text_Access;
      Wildcards : Wildcard_Sets.Set;
      Diag_Var  : Diagnosis_Variant;
      Rule      : Identifier_Casing_Rule_Type;
      State     : in out Rule_Traversal_State);
   --  Checks Name against specified casing scheme and the wildcards exceptions
   --  specified. In case if the argument correspond to some wildcard, the
   --  check is made that the parts specified by wildcard have the same casing
   --  as in wildcard, and the rest - casings specified by the Casing parameter
   --  (this check is skipped if Casing is equal to Not_A_Casing_Scheme). State
   --  is set according to the check results
   procedure Find_Next_Pattern
     (Name          :     String;
      Wildcards     :     Wildcard_Sets.Set;
      Success       : out Boolean;
      Pattern_Start : out Natural;
      Pattern       : out String_Access;
      Orig_Wilcard  : out String_Access);
   --  Checks if Name contains any pattern contained in wildcard dictionary.
   --  If it does not, sets Success OFF, and all the other out parameters are
   --  undefined. Otherwise sets Success ON, Pattern_Start is the index of the
   --  start of the pattern in Name, Pattern is the corresponding wildcard with
   --  '*' cut off, and Orig_Wilcard is the corresponding wildcard in the
   --  dictionary file.
   function Follow_Casing_Scheme
     (Str        : Program_Text;
      Casing     : Casing_Schemes;
      Word_Start : Boolean)
      return       Boolean;
   --  Checks if Str that is treated as a part of an identifier satisfies the
   --  Casing. If Word_Start is ON Str is considered as the start of the name
   --  or a part of the name immediately following the underscore (important
   --  for mixed case scheme)
   function Required_Casing_Scheme
     (Diag_Var : Diagnosis_Variant;
      Rule     : Identifier_Casing_Rule_Type)
      return     Casing_Schemes;
   --  Using the variant of the diagnosis as the way to detect the
   --  corresponding kind of the entities to check, gets from Rule the
   --  corresponding casing scheme. If for the entity kind that corresponds to
   --  Diag_Var no casing scheme is set, tries the casing defined for others
   --  entities.
   -----------------------------
   -- "<" (Identifier_Casing) --
   -----------------------------
   function "<" (Left, Right : Wildcard_Rec) return Boolean is
   begin
      return Left.Img < Right.Img;
   end "<";
   -----------------------------------------------
   -- Activate_In_Test_Mode (Identifier_Casing) --
   -----------------------------------------------
   overriding procedure Activate_In_Test_Mode
     (Rule : in out Identifier_Casing_Rule_Type)
   is
   begin
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Type=upper",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Enum=mixed",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Constant=lower",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Exception=upper",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Others=mixed",
         Enable => True);
      --  Now manually define some exceptions:
      String_Access_Sets.Insert (Rule.Exclude,  new String'("UNIT"));
      String_Access_Sets.Insert (Rule.Exclude,  new String'("ASIS"));
      String_Access_Sets.Insert (Rule.Exclude,  new String'("bits1"));
      Wildcard_Sets.Insert
        (Rule.Wilcards,
         (Img      => new String'(Get_Pattern ("_IO", Right)),
          Orig_Img => new String'("*_IO")));
      Wildcard_Sets.Insert
        (Rule.Wilcards,
         (Img      => new String'(Get_Pattern ("_IO", Not_A_Wildcard)),
          Orig_Img => new String'("*_IO")));
   end Activate_In_Test_Mode;
   ---------------------------------------
   -- Annotate_Rule (Identifier_Casing) --
   ---------------------------------------
   overriding function Annotate_Rule
     (Rule : Identifier_Casing_Rule_Type;
      Var  : Diagnosis_Variant := 0)
      return String
   is
   begin
      if not Gnatcheck.Options.Mapping_Mode then
         return "";
      else
         return " [" & Rule_Name (Rule) & ':' &
                (case Var is
                    when 1 => "Type",
                    when 2 => "Constant",
                    when 3 => "Enum",
                    when 4 => "Exception",
                    when 5 => "Others",
                    when 6 => "Exclude",
                    when others => "")
                & "]";
      end if;
   end Annotate_Rule;
   --------------------------------------
   -- Check_Casing (Identifier_Casing) --
   --------------------------------------
   procedure Check_Casing
     (Name      : Program_Text_Access;
      Wildcards : Wildcard_Sets.Set;
      Diag_Var  : Diagnosis_Variant;
      Rule      : Identifier_Casing_Rule_Type;
      State     : in out Rule_Traversal_State)
   is
      Success                 : Boolean;
      Tmp                     : String_Access;
      Tmp_Lowercase           : String_Access;
      Wildcard                : String_Access;
      Orig_Wildcard           : String_Access;
      First_N_Idx             : Natural;
      Name_Last               : Natural;
      Casing                  : constant Casing_Schemes :=
        Required_Casing_Scheme (Diag_Var, Rule);
      Pattern_Start : Natural;
      Pattern_End   : Natural;
   begin
      Tmp := new String'(To_String (Name.all));
      if Wildcard_Sets.Is_Empty (Wildcards) then
         --  A simple case, no wildcard involved
         if not Follow_Casing_Scheme
                  (Name.all, Casing, Word_Start => True)
         then
            State.Detected    := True;
            State.Diagnosis   := Diag_Var;
            State.Diag_Params :=
               Enter_String
                ("%1%" & Tmp.all
                 &
                 "%2%" & To_Lower
                    (Required_Casing_Scheme (Diag_Var, Rule)'Img));
         end if;
         Free (Tmp);
         return;
      end if;
      Tmp_Lowercase := new String'(To_Lower (To_String (Name.all)));
      First_N_Idx := Tmp_Lowercase'First;
      Name_Last   := Tmp_Lowercase'Last;
      Traverse_Name : while First_N_Idx <= Tmp'Last loop
         Find_Next_Pattern
           (Name          => Tmp_Lowercase (First_N_Idx .. Name_Last),
            Wildcards     => Wildcards,
            Success       => Success,
            Pattern_Start => Pattern_Start,
            Pattern       => Wildcard,
            Orig_Wilcard  => Orig_Wildcard);
         if Success then
            --  Check if the part of the name before pattern follows the casing
            --  scheme:
            if not Follow_Casing_Scheme
                     (Str        => Name (First_N_Idx .. Pattern_Start - 1),
                      Casing     => Casing,
                      Word_Start => True)
            then
               State.Detected    := True;
               State.Diagnosis   := Diag_Var;
               State.Diag_Params :=
                  Enter_String
                   ("%1%" & Tmp.all
                    &
                    "%2%" & To_Lower (Required_Casing_Scheme
                       (Diag_Var, Rule)'Img));
               exit Traverse_Name;
            end if;
            --  Check if the pattern has the correct casing
            Pattern_End :=
              Pattern_Start + Wildcard.all'Length - 1;
            if Tmp (Pattern_Start .. Pattern_End) /= Wildcard.all then
               State.Detected    := True;
               State.Diagnosis   := 6;
               State.Diag_Params :=
                  Enter_String
                   ("%1%" & Tmp.all
                    &
                    "%2%" & Orig_Wildcard.all);
               exit Traverse_Name;
            end if;
            --  Corner case of 'A' or abcd_D
            exit Traverse_Name when Pattern_End = Name_Last;
            First_N_Idx := Pattern_End;
         else
            --  Check if the rest of the word follows the casing scheme.
            if Name (First_N_Idx) = '_' then
               First_N_Idx := First_N_Idx + 1;
            end if;
            if not Follow_Casing_Scheme
                     (Str        => Name (First_N_Idx .. Name_Last),
                      Casing     => Casing,
                      Word_Start => True)
            then
               State.Detected    := True;
               State.Diagnosis   := Diag_Var;
               State.Diag_Params :=
                  Enter_String
                   ("%1%" & Tmp.all
                    &
                    "%2%" & To_Lower (Required_Casing_Scheme
                       (Diag_Var, Rule)'Img));
            end if;
            exit Traverse_Name;
         end if;
      end loop Traverse_Name;
      Free (Tmp);
      Free (Tmp_Lowercase);
   end Check_Casing;
   ----------------------------------------------------
   -- Check_With_Word_Dictionary (Identifier_Casing) --
   ----------------------------------------------------
   procedure Check_With_Word_Dictionary
     (Name        :        Program_Text_Access;
      Dict        :        String_Access_Sets.Set;
      State       : in out Rule_Traversal_State;
      Not_In_Dict :    out Boolean)
   is
      C   : String_Access_Sets.Cursor;
      Tmp : String_Access;
   begin
      Not_In_Dict := True;
      Tmp := new String'(To_String (Name.all));
      if not String_Access_Sets.Is_Empty (Dict) then
         C := String_Access_Sets.Find (Container => Dict, Item => Tmp);
         if String_Access_Sets.Has_Element (C) then
            Not_In_Dict := False;
            if String_Access_Sets.Element (C).all /= Tmp.all then
               State.Detected  := True;
               State.Diagnosis := 6;
               State.Diag_Params :=
                 Enter_String
                   ("%1%" & Tmp.all
                    &
                    "%2%" & String_Access_Sets.Element (C).all);
            end if;
         end if;
      end if;
      Free (Tmp);
   end Check_With_Word_Dictionary;
   --------
   -- Eq --
   --------
   function Eq  (Left, Right : Wildcard_Rec) return Boolean is
   begin
      return Left.Img = Right.Img;
   end Eq;
   -------------------------------------------
   -- Find_Next_Pattern (Identifier_Casing) --
   -------------------------------------------
   procedure Find_Next_Pattern
     (Name          :     String;
      Wildcards     :     Wildcard_Sets.Set;
      Success       : out Boolean;
      Pattern_Start : out Natural;
      Pattern       : out String_Access;
      Orig_Wilcard  : out String_Access)
   is
      Pattern_C     :          Wildcard_Sets.Cursor;
      Pattern_W     :          Wildcard_Rec;
      Pattern_End   :          Natural;
      Name_End      : constant Natural := Name'Last;
   begin
      Success       := False;
      Pattern_Start := Name'First;
      Traverse_Name : while Pattern_Start <= Name_End loop
         Pattern_End := 0;
         Find_Subword_End : for J in Pattern_Start + 1 .. Name_End loop
            if Name (J) = '_' then
               Pattern_End := J;
               exit Find_Subword_End;
            end if;
         end loop Find_Subword_End;
         if Pattern_End = 0 then
            Pattern_End := Name_End;
         end if;
         Pattern_W.Img := new String'(Name (Pattern_Start .. Pattern_End));
         Pattern_C     := Wildcard_Sets.Find (Wildcards, Pattern_W);
         Free (Pattern_W.Img);
         if Wildcard_Sets.Has_Element (Pattern_C) then
            Success       := True;
            Pattern       := Wildcard_Sets.Element (Pattern_C).Img;
            Orig_Wilcard  := Wildcard_Sets.Element (Pattern_C).Orig_Img;
            exit Traverse_Name;
         else
            --  Corner case of 'A' or abcd_D
            exit Traverse_Name when Pattern_Start = Pattern_End;
            Pattern_Start := Pattern_End;
         end if;
      end loop Traverse_Name;
   end Find_Next_Pattern;
   ----------------------------------------------
   -- Follow_Casing_Scheme (Identifier_Casing) --
   ----------------------------------------------
   function Follow_Casing_Scheme
     (Str        : Program_Text;
      Casing     : Casing_Schemes;
      Word_Start : Boolean)
      return       Boolean
   is
      Result         : Boolean := True;
      Word_Start_Tmp : Boolean := Word_Start;
   begin
      case Casing is
         when Lower =>
            if Str /= To_Lower_Case (Str) then
               Result := False;
            end if;
         when Upper =>
            if Str /= To_Upper_Case (Str) then
               Result :=  False;
            end if;
         when Mixed =>
            for J in Str'Range loop
               if Word_Start_Tmp then
                  if Ada.Wide_Characters.Unicode.Is_Letter (Str (J))
                    and then
                     Str (J) /=
                     Ada.Wide_Characters.Unicode.To_Upper_Case (Str (J))
                  then
                     Result := False;
                     exit;
                  elsif Str (J) /= '_' then
                     Word_Start_Tmp := False;
                  end if;
               elsif Str (J) = '_' then
                  Word_Start_Tmp := True;
               else
                  if Ada.Wide_Characters.Unicode.Is_Letter (Str (J))
                    and then
                     Str (J) /=
                     Ada.Wide_Characters.Unicode.To_Lower_Case (Str (J))
                  then
                     Result := False;
                     exit;
                  end if;
               end if;
            end loop;
         when Not_A_Casing_Scheme => null;
      end case;
      return Result;
   end Follow_Casing_Scheme;
   -------------------------------------------
   -- Get_Casing_Scheme (Identifier_Casing) --
   -------------------------------------------
   function Get_Casing_Scheme (S : String) return Casing_Schemes is
   begin
      return Casing_Schemes'Value (S);
   exception
      when Constraint_Error =>
         return Not_A_Casing_Scheme;
   end Get_Casing_Scheme;
   ------------------------------------------
   -- Get_Diag_Variant (Identifier_Casing) --
   ------------------------------------------
   function Get_Diag_Variant (E : Asis.Element) return Diagnosis_Variant is
      Result : Diagnosis_Variant;
      Tmp    : Asis.Element;
   begin
      case Flat_Element_Kind (E) is
         when A_Defining_Enumeration_Literal =>
            Result := 3;
         when A_Constant_Declaration          |
              A_Deferred_Constant_Declaration |
              An_Integer_Number_Declaration   |
              A_Real_Number_Declaration       =>
            Result := 2;
         when An_Exception_Declaration          |
              An_Exception_Renaming_Declaration =>
            Result := 4;
         when An_Ordinary_Type_Declaration         |
              A_Task_Type_Declaration              |
              A_Protected_Type_Declaration         |
              A_Private_Type_Declaration           |
              A_Private_Extension_Declaration      |
              A_Formal_Type_Declaration            |
              An_Incomplete_Type_Declaration       |
              A_Tagged_Incomplete_Type_Declaration |
              A_Subtype_Declaration                =>
            Result := 1;
         when A_Task_Body_Declaration      |
              A_Protected_Body_Declaration =>
            if Is_Subunit (E) then
               Tmp := Corresponding_Body_Stub (E);
            else
               Tmp := E;
            end if;
            if Declaration_Kind (Corresponding_Declaration (Tmp)) in
               A_Task_Type_Declaration .. A_Protected_Type_Declaration
            then
               Result := 1;
            else
               Result := 5;
            end if;
         when A_Task_Body_Stub      |
              A_Protected_Body_Stub =>
            if Declaration_Kind (Corresponding_Declaration (E)) in
               A_Task_Type_Declaration .. A_Protected_Type_Declaration
            then
               Result := 1;
            else
               Result := 5;
            end if;
         when An_Object_Renaming_Declaration =>
            if Is_Constant (First_Name (E)) then
               Result := 2;
            else
               Result := 5;
            end if;
         when A_Function_Renaming_Declaration =>
            Tmp := Corresponding_Base_Entity (E);
            if Expression_Kind (Tmp) = A_Selected_Component then
               Tmp := Selector (Tmp);
            end if;
            if Expression_Kind (Tmp) = An_Enumeration_Literal then
               Result := 3;
            else
               Result := 5;
            end if;
         when others =>
            Result := 5;
      end case;
      return Result;
   end Get_Diag_Variant;
   --------------------------------------------------------------
   -- Get_Identifier_Casing_Parameter_Kind (Identifier_Casing) --
   --------------------------------------------------------------
   function Get_Identifier_Casing_Parameter_Kind
     (S    : String)
      return Identifier_Casing_Parameter_Kinds
   is
   begin
      return Identifier_Casing_Parameter_Kinds'Value (S & "_Par");
   exception
      when Constraint_Error =>
         return Not_A_Parameter;
   end Get_Identifier_Casing_Parameter_Kind;
   --------------------------------------
   -- Get_Pattern (Identifier_Casing) --
   --------------------------------------
   function Get_Pattern (W : String; WK : Wildcard_Kinds) return String is
   begin
      case WK is
         when Not_A_Wildcard =>
            return W;
         when Left =>
            return W & '_';
         when Right =>
            return '_' &  W;
         when Both =>
            return '_' & W & '_';
      end case;
   end Get_Pattern;
   -----------------------------------
   -- Init_Rule (Identifier_Casing) --
   -----------------------------------
   overriding procedure Init_Rule
     (Rule : in out Identifier_Casing_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name             := new String'("Identifier_Casing");
      Rule.Rule_Status      := Fully_Implemented;
      Rule.Help_Info        := new String'("casing of defining names");
      Rule.Type_Casing      := Not_A_Casing_Scheme;
      Rule.Enum_Casing      := Not_A_Casing_Scheme;
      Rule.Constant_Casing  := Not_A_Casing_Scheme;
      Rule.Exception_Casing := Not_A_Casing_Scheme;
      Rule.Others_Casing    := Not_A_Casing_Scheme;
      Rule.Exclude          := String_Access_Sets.Empty_Set;
      Rule.Dictionaries     := String_Access_Sets.Empty_Set;
      Rule.Diagnosis :=
        new String'("#1#%1% does not have casing specified for subtype "     &
                    "names (%2%)"                                            &
                    "#2#%1% does not have casing specified for constant "    &
                    "names (%2%)"                                            &
                    "#3#%1% does not have casing specified for enumeration " &
                    "literals (%2%)"                                         &
                    "#4#%1% does not have casing specified for exception "   &
                    "names  (%2%)"                                           &
                    "#5#%1% does not have casing specified (%2%)"            &
                    "#6#%1% does not have casing specified in the "         &
                    "dictionary (%2%)");
   end Init_Rule;
   ------------------------------------
   -- Print_Rule (Identifier_Casing) --
   ------------------------------------
   overriding procedure Print_Rule
     (Rule         : Identifier_Casing_Rule_Type;
      Indent_Level : Natural := 0)
   is
      First_Param       : Boolean         := True;
      Rule_Name_Padding : constant String :=
        (1 .. Rule.Name'Length + 2 => ' ');
      C : String_Access_Sets.Cursor;
   begin
      Print_Rule (Rule_Template (Rule), Indent_Level);
      if Rule.Type_Casing /= Not_A_Casing_Scheme then
         Report_No_EOL (": Type = " & To_Lower (Rule.Type_Casing'Img));
         First_Param := False;
      end if;
      if Rule.Enum_Casing /= Not_A_Casing_Scheme then
         if First_Param then
            Report_No_EOL (": Enum = " & To_Lower (Rule.Enum_Casing'Img));
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Enum = " & To_Lower (Rule.Enum_Casing'Img),
              Indent_Level);
         end if;
      end if;
      if Rule.Constant_Casing /= Not_A_Casing_Scheme then
         if First_Param then
            Report_No_EOL (": Constant = " &
                           To_Lower (Rule.Constant_Casing'Img));
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Constant = " & To_Lower (Rule.Constant_Casing'Img),
              Indent_Level);
         end if;
      end if;
      if Rule.Exception_Casing /= Not_A_Casing_Scheme then
         if First_Param then
            Report_No_EOL (": Exception = " &
                           To_Lower (Rule.Exception_Casing'Img));
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Exception = " & To_Lower (Rule.Exception_Casing'Img),
              Indent_Level);
         end if;
      end if;
      if Rule.Others_Casing /= Not_A_Casing_Scheme then
         if First_Param then
            Report_No_EOL (": Others = " &
                           To_Lower (Rule.Others_Casing'Img));
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Others = " & To_Lower (Rule.Others_Casing'Img),
              Indent_Level);
         end if;
      end if;
      if not String_Access_Sets.Is_Empty (Rule.Dictionaries) then
         C := String_Access_Sets.First (Rule.Dictionaries);
         while C /= String_Access_Sets.No_Element loop
            if First_Param then
               Report_No_EOL (": Exclude  = " &
                              String_Access_Sets.Element (C).all);
               First_Param := False;
            else
               Report (", ");
               Report_No_EOL
                 (Rule_Name_Padding &
                  "Exclude  = " & String_Access_Sets.Element (C).all,
                 Indent_Level);
            end if;
            C := Next (C);
         end loop;
      end if;
   end Print_Rule;
   --------------------------------------------
   -- Print_Rule_To_File (Identifier_Casing) --
   --------------------------------------------
   overriding procedure Print_Rule_To_File
     (Rule         : Identifier_Casing_Rule_Type;
      Rule_File    : File_Type;
      Indent_Level : Natural := 0)
   is
      First_Param       : Boolean         := True;
      Rule_Name_Padding : constant String :=
        (1 .. Rule.Name'Length + 4 => ' ');
      C : String_Access_Sets.Cursor;
   begin
      Print_Rule_To_File (Rule_Template (Rule), Rule_File, Indent_Level);
      if Rule.Type_Casing /= Not_A_Casing_Scheme then
         Put (Rule_File, ": Type = " & To_Lower (Rule.Type_Casing'Img));
         First_Param := False;
      end if;
      if Rule.Enum_Casing /= Not_A_Casing_Scheme then
         if First_Param then
            Put (Rule_File, ": Enum = " & To_Lower (Rule.Enum_Casing'Img));
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Enum = " & To_Lower (Rule.Enum_Casing'Img));
         end if;
      end if;
      if Rule.Constant_Casing /= Not_A_Casing_Scheme then
         if First_Param then
            Put (Rule_File, ": Constant = " &
                            To_Lower (Rule.Constant_Casing'Img));
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Constant = " & To_Lower (Rule.Constant_Casing'Img));
         end if;
      end if;
      if Rule.Exception_Casing /= Not_A_Casing_Scheme then
         if First_Param then
            Put (Rule_File, ": Exception = " &
                            To_Lower (Rule.Exception_Casing'Img));
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Exception = " & To_Lower (Rule.Exception_Casing'Img));
         end if;
      end if;
      if Rule.Others_Casing /= Not_A_Casing_Scheme then
         if First_Param then
            Put (Rule_File, ": Others = " &
                           To_Lower (Rule.Others_Casing'Img));
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Others = " & To_Lower (Rule.Others_Casing'Img));
         end if;
      end if;
      if not String_Access_Sets.Is_Empty (Rule.Dictionaries) then
         C := String_Access_Sets.First (Rule.Dictionaries);
         while C /= String_Access_Sets.No_Element loop
            if First_Param then
               Put (Rule_File, ": Exclude  = " &
                              String_Access_Sets.Element (C).all);
               First_Param := False;
            else
               Put_Line (Rule_File, ", ");
               for J in 1 .. Indent_Level loop
                  Put (Rule_File, Get_Indent_String);
               end loop;
               Put (Rule_File,
                    Rule_Name_Padding &
                    "Exclude  = " & String_Access_Sets.Element (C).all);
            end if;
            C := Next (C);
         end loop;
      end if;
   end Print_Rule_To_File;
   ------------------------------------------------
   -- Process_Rule_Parameter (Identifier_Casing) --
   ------------------------------------------------
   overriding procedure Process_Rule_Parameter
     (Rule    : in out Identifier_Casing_Rule_Type;
      Param   :        String;
      Enable  :        Boolean)
   is
      First_Str_Idx, Last_Str_Idx : Natural;
      --  Beginning and end of the 'string' part of the parameter, see the
      --  rule parameter description in the spec. First_Str_Idx is set to 0 if
      --  the parameter does not contain a '=' character.
      First_Par_Idx, Last_Par_Idx : Natural;
      --  If the parameter contains a '=' character, set to point to the
      --  beginning and the end of the part of the parameter that precedes '='.
      --  Otherwise First_Par_Idx points to the first, and Last_Par_Idx - to
      --  the last non-blank character in Param (First_Idx .. Last_Idx)
      Parameter_Kind : Identifier_Casing_Parameter_Kinds;
      Casing_Scheme  : Casing_Schemes;
      C        : String_Access_Sets.Cursor;
      Inserted : Boolean := False;
      Tmp_Str  : String_Access;
   begin
      if Param = "" then
         if Enable then
            Error ("(" & Rule.Name.all & ") +R option must have a parameter");
         else
            Rule.Rule_State := Disabled;
         end if;
         return;
      elsif not Enable then
         Error ("(" & Rule.Name.all & ") -R option should not " &
                "have a parameter");
      end if;
      Parse_Par
        (First_Par_Idx, Last_Par_Idx, First_Str_Idx, Last_Str_Idx, Param);
      Parameter_Kind :=
        Get_Identifier_Casing_Parameter_Kind
          (Param (First_Par_Idx .. Last_Par_Idx));
      if Parameter_Kind = Not_A_Parameter or else First_Str_Idx = 0 then
         Error ("(" & Rule.Name.all & ") wrong parameter: " &
                Param & ", ignored");
         return;
      end if;
      --  If we are here, we have "+R<valid_par>=string"
      if Parameter_Kind in Type_Par .. Others_Par then
         Casing_Scheme :=
           Get_Casing_Scheme (Param (First_Str_Idx .. Last_Str_Idx));
         if Casing_Scheme = Not_A_Casing_Scheme then
            Error ("(" & Rule.Name.all & ") wrong casing scheme: " &
                   Param & ", ignored");
            return;
         end if;
      end if;
      case Parameter_Kind is
         when Type_Par =>
            Rule.Type_Casing := Casing_Scheme;
         when Constant_Par =>
            Rule.Constant_Casing := Casing_Scheme;
         when Exception_Par =>
            Rule.Exception_Casing := Casing_Scheme;
         when Enum_Par =>
            Rule.Enum_Casing := Casing_Scheme;
         when Others_Par =>
            Rule.Others_Casing := Casing_Scheme;
         when Exclude_Par =>
            Tmp_Str := new String'(Param (First_Str_Idx .. Last_Str_Idx));
            String_Access_Sets.Insert
              (Container => Rule.Dictionaries,
               New_Item  => Tmp_Str,
               Position  => C,
               Inserted  => Inserted);
            if not Inserted then
               Error ("(" & Rule.Name.all & ") dictionary " &
                      Tmp_Str.all & ", specified more than once, " &
                      "all but first ignored");
               Free (Tmp_Str);
               return;
            end if;
            if not Is_Regular_File  (Tmp_Str.all) then
               Error ("(" & Rule.Name.all & ") dictionary " &
                      Tmp_Str.all & " does not exist");
               return;
            end if;
            Scan_Dictionary_File (Rule.Exclude, Rule.Wilcards, Tmp_Str);
         when Not_A_Parameter => null;
      end case;
      Rule.Rule_State := Enabled;
   end Process_Rule_Parameter;
   ------------------------------------------------
   -- Required_Casing_Scheme (Identifier_Casing) --
   ------------------------------------------------
   function Required_Casing_Scheme
     (Diag_Var : Diagnosis_Variant;
      Rule     : Identifier_Casing_Rule_Type)
      return     Casing_Schemes
   is
      Result : Casing_Schemes := Not_A_Casing_Scheme;
   begin
      case Diag_Var is
         when 1 =>
            Result := Rule.Type_Casing;
         when 2 =>
            Result := Rule.Constant_Casing;
         when 3 =>
            Result := Rule.Enum_Casing;
         when 4 =>
            Result := Rule.Exception_Casing;
         when 5 =>
            Result := Rule.Others_Casing;
         when others =>
            pragma Assert (False);
            null;
      end case;
      if Result = Not_A_Casing_Scheme then
         Result := Rule.Others_Casing;
      end if;
      return Result;
   end Required_Casing_Scheme;
   -------------------------------------------
   -- Rule_Check_Pre_Op (Identifier_Casing) --
   -------------------------------------------
   overriding procedure Rule_Check_Pre_Op
     (Rule    : in out Identifier_Casing_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Control);
      Tmp                    : Asis.Element := Element;
      Name_Img               : Program_Text_Access;
      Not_In_Word_Dictionary : Boolean;
   begin
      case Defining_Name_Kind (Element) is
         when A_Defining_Identifier =>
            Tmp := Get_Enclosing_Element;
         when A_Defining_Enumeration_Literal =>
            null;
         when others =>
            return;
      end case;
      Name_Img := new Program_Text'(Defining_Name_Image (Element));
      Check_With_Word_Dictionary
        (Name        => Name_Img,
         Dict        => Rule.Exclude,
         State       => State,
         Not_In_Dict => Not_In_Word_Dictionary);
      if Not_In_Word_Dictionary then
         Check_Casing
           (Name      => Name_Img,
            Wildcards => Rule.Wilcards,
            Diag_Var  => Get_Diag_Variant (Tmp),
            Rule      => Rule,
            State     => State);
      end if;
      Free (Name_Img);
   end Rule_Check_Pre_Op;
   ----------------------------------------------
   -- Scan_Dictionary_File (Identifier_Casing) --
   ----------------------------------------------
   procedure Scan_Dictionary_File
     (Stored_Exceptions : in out String_Access_Sets.Set;
      Stored_Wildcards  : in out Wildcard_Sets.Set;
      D_File_Name       :        String_Access)
   is
      Dictionary_File : File_Type;
      String_Buffer_Max_Len : constant Natural := 1024;
      --  Should be enough, I hope...
      String_Buffer : String (1 .. String_Buffer_Max_Len);
      Len : Natural range 0 .. String_Buffer_Max_Len := 0;
      --  The length of the dictionary file line which is being processed
      Line_Num : Natural := 0;
      --  The number of the currently processed line
      Start_Word : Natural := 0;
      End_Word   : Natural := 0;
      Start_Wildcard : Natural := 0;
      End_Wildcard   : Natural := 0;
      Wildcard_Kind  : Wildcard_Kinds;
      C       : String_Access_Sets.Cursor;
      C_W     : Wildcard_Sets.Cursor;
      Tmp_Str : String_Access;
      New_Wildcard : Wildcard_Rec;
   begin
      begin
         Open (File => Dictionary_File,
               Mode => In_File,
               Name => D_File_Name.all);
      exception
         when others =>
            Error ("cannot open dictionary file " & D_File_Name.all);
            return;
      end;
      while not End_Of_File (Dictionary_File) loop
         Line_Num := Line_Num + 1;
         Get_Line (Dictionary_File, String_Buffer, Len);
         Start_Word := 1;
         Scan_Line : while Start_Word <= Len loop
            while Is_White_Space (String_Buffer (Start_Word)) loop
               Start_Word := Start_Word + 1;
               exit Scan_Line when Start_Word > Len;
            end loop;
            if Start_Word < Len
              and then
               String_Buffer (Start_Word .. Start_Word + 1) = "--"
            then
               --  Skip comment
               exit Scan_Line;
            end if;
            End_Word := Len;
            for J in Start_Word + 1 .. Len loop
               if Is_White_Space (String_Buffer (J)) then
                  End_Word := J - 1;
                  exit;
               end if;
            end loop;
            if Is_Identifier (To_Wide_String
                 (String_Buffer (Start_Word .. End_Word)))
            then
               Tmp_Str := new String'(String_Buffer (Start_Word .. End_Word));
               C       := String_Access_Sets.Find (Stored_Exceptions, Tmp_Str);
               if Has_Element (C) then
                  if String_Access_Sets.Element (C).all /= Tmp_Str.all then
                     String_Access_Sets.Replace_Element
                       (Container => Stored_Exceptions,
                        Position  => C,
                        New_Item  => Tmp_Str);
                  else
                     Free (Tmp_Str);
                  end if;
               else
                  String_Access_Sets.Insert (Stored_Exceptions, Tmp_Str);
               end if;
            else
               --  In case of a correctly formatted wildcard we do the
               --  following. For each wildcard we store a set of patterns that
               --  can be moved onto this wildcard. Then, when analyzing a
               --  defining name, we select subwords in it and check if a
               --  subword can be mapped onto some pattern. For each pattern
               --  we store the original wildcard to be used in the diagnosis.
               --
               --  For *ABC* we store ABC, _ABC, _ABC_ and ABC_,
               --  for *ABC  we store ABC and _ABC
               --  for ABC*  we store ABC and ABC_
               Wildcard_Kind := Both;
               if String_Buffer (Start_Word) = '*' then
                  Start_Wildcard := Start_Word + 1;
               else
                  Start_Wildcard := Start_Word;
                  Wildcard_Kind  := Left;
               end if;
               if String_Buffer (End_Word) = '*' then
                  End_Wildcard := End_Word - 1;
               else
                  if Wildcard_Kind = Both then
                     Wildcard_Kind := Right;
                     End_Wildcard  := End_Word;
                  else
                     Wildcard_Kind := Not_A_Wildcard;
                  end if;
               end if;
               if Wildcard_Kind = Not_A_Wildcard
                 or else
                  not Is_Identifier (To_Wide_String
                        (String_Buffer (Start_Wildcard .. End_Wildcard)))
                 or else
                  Index (String_Buffer (Start_Wildcard .. End_Wildcard), "_")
                  /= 0
               then
                  Error (D_File_Name.all & ':' & Image (Line_Num) & ':' &
                         Image (Start_Word) &
                         ": wrong syntax of a casing exception");
               else
                  New_Wildcard.Orig_Img :=
                    new String'(String_Buffer (Start_Word .. End_Word));
                  for W_Kind in Wildcard_Kinds loop
                     if W_Kind = Not_A_Wildcard
                       or else
                        Wildcard_Kind = Both
                       or else
                        Wildcard_Kind = W_Kind
                     then
                        New_Wildcard.Img := new String'(Get_Pattern
                          (String_Buffer (Start_Wildcard .. End_Wildcard),
                           W_Kind));
                        C_W := Wildcard_Sets.Find
                                 (Stored_Wildcards, New_Wildcard);
                        if Wildcard_Sets.Has_Element (C_W) then
                           if Wildcard_Sets.Element (C_W).Img.all /=
                              New_Wildcard.Img.all
                           then
                              Wildcard_Sets.Replace_Element
                                (Container => Stored_Wildcards,
                                 Position  => C_W,
                                 New_Item  => New_Wildcard);
                           else
                              Free (New_Wildcard.Img);
                           end if;
                        else
                           Wildcard_Sets.Insert
                             (Stored_Wildcards, New_Wildcard);
                        end if;
                     end if;
                  end loop;
               end if;
            end if;
            Start_Word := End_Word + 2;
         end loop Scan_Line;
      end loop;
      if Is_Open (Dictionary_File) then
         Close (Dictionary_File);
      end if;
   end Scan_Dictionary_File;
   ---------------------------------------
   -- XML_Rule_Help (Identifier_Casing) --
   ---------------------------------------
   overriding procedure XML_Rule_Help
     (Rule  : Identifier_Casing_Rule_Type;
      Level : Natural)
   is
   begin
      Info (Level * Ident_String                &
            "<field switch=""+R"                &
            Rule.Name.all                       &
            ":Type"""                           &
            " label="""                         &
            "type name casing"""                &
            " separator=""="""                  &
            "/>");
      Info (Level * Ident_String                &
            "<field switch=""+R"                &
            Rule.Name.all                       &
            ":Enum"""                           &
            " label="""                         &
            "enumeration literal casing"""      &
            " separator=""="""                  &
            "/>");
      Info (Level * Ident_String                &
            "<field switch=""+R"                &
            Rule.Name.all                       &
            ":Constant"""                       &
            " label="""                         &
            "constant name casing"""            &
            " separator=""="""                  &
            "/>");
      Info (Level * Ident_String                &
            "<field switch=""+R"                &
            Rule.Name.all                       &
            ":Exception"""                      &
            " label="""                         &
            "exception name casing"""           &
            " separator=""="""                  &
            "/>");
      Info (Level * Ident_String                &
            "<field switch=""+R"                &
            Rule.Name.all                       &
            ":Others"""                         &
            " label="""                         &
            "other name casing"""               &
            " separator=""="""                  &
            "/>");
      Info (Level * Ident_String                &
            "<field switch=""+R"                &
            Rule.Name.all                       &
            ":Exclude"""                        &
            " label="""                         &
            "dictionary of casing exceptions""" &
            " separator=""="""                  &
            "/>");
   end XML_Rule_Help;
   -------------------------
   -- Identifier_Suffixes --
   -------------------------
   --------------------------------------------------------
   -- Data structures and local subprograms for the rule --
   --------------------------------------------------------
   procedure Free_All_Suffixes (Rule : in out Identifier_Suffixes_Rule_Type);
   --  Cleans all the name suffixes to check
   function Has_Suffix
     (El     : Asis.Element;
      Suffix : Wide_String)
      return   Boolean;
   --  Checks if the string image of El ends with Suffix.
   -------------------------------------------------
   -- Activate_In_Test_Mode (Identifier_Suffixes) --
   -------------------------------------------------
   overriding procedure Activate_In_Test_Mode
     (Rule : in out Identifier_Suffixes_Rule_Type)
   is
   begin
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Type_Suffix=_T",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Access_Suffix=_Access(_Access)",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Class_Access_Suffix=_Class_Access",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Class_Subtype_Suffix=_Class",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Constant_Suffix=_C",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Renaming_Suffix=_R",
         Enable => True);
   end Activate_In_Test_Mode;
   -----------------------------------------
   -- Annotate_Rule (Identifier_Suffixes) --
   -----------------------------------------
   overriding function Annotate_Rule
     (Rule : Identifier_Suffixes_Rule_Type;
      Var  : Diagnosis_Variant := 0)
      return String
   is
   begin
      if not Gnatcheck.Options.Mapping_Mode then
         return "";
      else
         return " [" & Rule_Name (Rule) & ':' &
                (case Var is
                    when 1     => "Type_Suffix",
                    when 2 | 5 => "Access_Suffix",
                    when 3     => "Constant_Suffix",
                    when 4     => "Renaming_Suffix",
                    when 6     => "Class_Subtype_Suffix",
                    when 7     => "Class_Access_Suffix",
                    when others => "")
                & "]";
      end if;
   end Annotate_Rule;
   ---------------------------------------------
   -- Free_All_Suffixes (Identifier_Suffixes) --
   ---------------------------------------------
   procedure Free_All_Suffixes
     (Rule : in out Identifier_Suffixes_Rule_Type)
   is
   begin
      Free (Rule.Type_Suffix);
      Free (Rule.Access_Suffix);
      Free (Rule.Access_To_Access_Suffix);
      Free (Rule.Class_Subtype_Suffix);
      Free (Rule.Class_Access_Suffix);
      Free (Rule.Constant_Suffix);
      Free (Rule.Renaming_Suffix);
   end Free_All_Suffixes;
   --------------------------------------
   -- Has_Suffix (Identifier_Suffixes) --
   --------------------------------------
   function Has_Suffix
     (El     : Asis.Element;
      Suffix : Wide_String)
      return   Boolean
   is
      Result : Boolean := False;
   begin
      --  At the moment this function works with A_Defining_Identifier Elements
      --  only
      Result :=
        Suffix =
        Tail (Source => Defining_Name_Image (El), Count  => Suffix'Length);
      return Result;
   end Has_Suffix;
   -------------------------------------
   -- Init_Rule (Identifier_Suffixes) --
   -------------------------------------
   procedure Init_Rule (Rule : in out Identifier_Suffixes_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Identifier_Suffixes");
      Rule.Synonym     := new String'("Misnamed_Identifiers");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("suffixes in defining names");
      Rule.Diagnosis   :=
        new String'("#1#wrong suffix in type name"                  &
                    "#2#wrong suffix in access type name"           &
                    "#3#wrong suffix in constant name"              &
                    "#4#wrong suffix in package renaming"           &
                    "#5#wrong suffix in access-to-access type name" &
                    "#6#wrong suffix in class-wide subtype name"    &
                    "#7#wrong suffix in access-to-class type name");
   end Init_Rule;
   --------------------------------------
   -- Print_Rule (Identifier_Suffixes) --
   --------------------------------------
   procedure Print_Rule
     (Rule         : Identifier_Suffixes_Rule_Type;
      Indent_Level : Natural := 0)
   is
      First_Param       : Boolean         := True;
      Rule_Name_Padding : constant String :=
        (1 .. Rule.Name'Length + 2 => ' ');
   begin
      Print_Rule (Rule_Template (Rule), Indent_Level);
      if Rule.Type_Suffix /= null then
         Report_No_EOL (": Type_Suffix = " & Rule.Type_Suffix.all);
         First_Param := False;
      end if;
      if Rule.Access_Suffix /= null then
         if First_Param then
            Report_No_EOL (": Access_Suffix = " & Rule.Access_Suffix.all);
            First_Param := False;
         else
            Report (",");
            Report_No_EOL
              (Rule_Name_Padding &
               "Access_Suffix = " & Rule.Access_Suffix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Access_To_Access_Suffix /= null then
         if First_Param then
            Report_No_EOL
              (": Access_To_Access_Suffix = " &
               Rule.Access_To_Access_Suffix.all);
            First_Param := False;
         else
            Report (",");
            Report_No_EOL
              (Rule_Name_Padding &
               "Access_To_Access_Suffix = " & Rule.Access_To_Access_Suffix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Class_Subtype_Suffix /= null then
         if First_Param then
            Report_No_EOL
              (": Class_Subtype_Suffix = " & Rule.Class_Subtype_Suffix.all);
            First_Param := False;
         else
            Report (",");
            Report_No_EOL
              (Rule_Name_Padding &
               "Class_Subtype_Suffix = " & Rule.Class_Subtype_Suffix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Class_Access_Suffix /= null then
         if First_Param then
            Report_No_EOL
              (": Class_Access_Suffix = " & Rule.Class_Access_Suffix.all);
            First_Param := False;
         else
            Report (",");
            Report_No_EOL
              (Rule_Name_Padding &
               "Class_Access_Suffix = " & Rule.Class_Access_Suffix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Constant_Suffix /= null then
         if First_Param then
            Report_No_EOL (":  = " & Rule.Constant_Suffix.all);
            First_Param := False;
         else
            Report (",");
            Report_No_EOL
              (Rule_Name_Padding &
               "Constant_Suffix = " & Rule.Constant_Suffix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Renaming_Suffix /= null then
         if First_Param then
            Report_No_EOL (": Renaming_Suffix = " & Rule.Renaming_Suffix.all);
            First_Param := False;
         else
            Report (",");
            Report_No_EOL
              (Rule_Name_Padding &
               "Renaming_Suffix = " & Rule.Renaming_Suffix.all,
              Indent_Level);
         end if;
      end if;
   end Print_Rule;
   ----------------------------------------------
   -- Print_Rule_To_File (Identifier_Suffixes) --
   ----------------------------------------------
   procedure Print_Rule_To_File
     (Rule         : Identifier_Suffixes_Rule_Type;
      Rule_File    : File_Type;
      Indent_Level : Natural := 0)
   is
      First_Param       : Boolean         := True;
      Rule_Name_Padding : constant String :=
        (1 .. Rule.Name'Length + 4 => ' ');
   begin
      Print_Rule_To_File (Rule_Template (Rule), Rule_File, Indent_Level);
      if Rule.Type_Suffix /= null then
         Put (Rule_File, ": Type_Suffix = " & Rule.Type_Suffix.all);
         First_Param := False;
      end if;
      if Rule.Access_Suffix /= null then
         if First_Param then
            Put (Rule_File, ": Access_Suffix = " & Rule.Access_Suffix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ",");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Access_Suffix = " & Rule.Access_Suffix.all);
         end if;
         if Rule.Access_To_Access_Suffix /= null then
            Put (Rule_File, "(" & Rule.Access_To_Access_Suffix.all & ")");
         end if;
      end if;
      if Rule.Class_Subtype_Suffix /= null then
         if First_Param then
            Put (Rule_File,
                 ": Class_Subtype_Suffix = " & Rule.Class_Subtype_Suffix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ",");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                "Class_Subtype_Suffix = " & Rule.Class_Subtype_Suffix.all);
         end if;
      end if;
      if Rule.Class_Access_Suffix /= null then
         if First_Param then
            Put (Rule_File,
                 ": Class_Access_Suffix = " & Rule.Class_Access_Suffix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ",");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Class_Access_Suffix = " & Rule.Class_Access_Suffix.all);
         end if;
      end if;
      if Rule.Constant_Suffix /= null then
         if First_Param then
            Put (Rule_File, ":  = " & Rule.Constant_Suffix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ",");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Constant_Suffix = " & Rule.Constant_Suffix.all);
         end if;
      end if;
      if Rule.Renaming_Suffix /= null then
         if First_Param then
            Put (Rule_File, ": Renaming_Suffix = " & Rule.Renaming_Suffix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ",");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Renaming_Suffix = " & Rule.Renaming_Suffix.all);
         end if;
      end if;
   end Print_Rule_To_File;
   --------------------------------------------------
   -- Process_Rule_Parameter (Identifier_Suffixes) --
   --------------------------------------------------
   procedure Process_Rule_Parameter
     (Rule    : in out Identifier_Suffixes_Rule_Type;
      Param   :        String;
      Enable  :        Boolean)
   is
      First_Str_Idx, Last_Str_Idx : Natural;
      --  Beginning and end of the 'string' part of the parameter, see the
      --  rule parameter description in the spec. First_Str_Idx is set to 0 if
      --  the parameter does not contain a '=' character.
      Last_Str_Idx_Original : Natural;
      First_Par_Idx, Last_Par_Idx : Natural;
      --  If the parameter contains a '=' character, set to point to the
      --  beginning and the end of the part of the parameter that precedes '='.
      --  Otherwise First_Par_Idx points to the first, and Last_Par_Idx - to
      --  the last non-blank character in Param (First_Idx .. Last_Idx)
      Is_Legal_Suffix        : Boolean := False;
      Is_Legal_Access_Suffix : Boolean := False;
   begin
      if Param = "" then
         if Enable then
            Rule.Rule_State := Enabled;
         else
            Rule.Rule_State := Disabled;
         end if;
         return;
      end if;
      Parse_Par
        (First_Par_Idx, Last_Par_Idx, First_Str_Idx, Last_Str_Idx, Param);
      if First_Str_Idx = 0 then
         if Enable then
            if To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
               "default"
            then
               Set_Rule_Defaults (Rule);
               Rule.Rule_State := Enabled;
            else
               Error
                ("(" & Rule.Name.all & ") wrong parameter : " &
                 Param & ", ignored");
            end if;
         else
            if To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
               "all_suffixes"
            then
               Free_All_Suffixes (Rule);
               Rule.Rule_State := Disabled;
            elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
               "type_suffix"
            then
               Free (Rule.Type_Suffix);
            elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
               "access_suffix"
            then
               Free (Rule.Access_Suffix);
               Free (Rule.Access_To_Access_Suffix);
            elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
               "constant_suffix"
            then
               Free (Rule.Constant_Suffix);
            elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
               "class_subtype_suffix"
            then
               Free (Rule.Class_Subtype_Suffix);
            elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
               "class_access_suffix"
            then
               Free (Rule.Class_Access_Suffix);
            elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
               "renaming_suffix"
            then
               Free (Rule.Renaming_Suffix);
            else
               Error
                ("(" & Rule.Name.all & ") wrong parameter : " &
                 Param & ", ignored");
            end if;
         end if;
      else
         if Enable then
            Is_Legal_Suffix := Is_Identifier_Suffix
              (To_Wide_String (Param (First_Str_Idx .. Last_Str_Idx)));
            if not Is_Legal_Suffix
              and then
               To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
                  "access_suffix"
            then
               Is_Legal_Access_Suffix :=
                 Is_Access_Suffix (Param (First_Str_Idx .. Last_Str_Idx));
            end if;
            if Is_Legal_Suffix then
               if To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
                  "type_suffix"
               then
                  Rule.Type_Suffix :=
                    new String'(Param (First_Str_Idx .. Last_Str_Idx));
                  Rule.Rule_State := Enabled;
               elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
                  "access_suffix"
               then
                  Rule.Access_Suffix :=
                    new String'(Param (First_Str_Idx .. Last_Str_Idx));
                  Rule.Access_To_Access_Suffix := null;
                  Rule.Rule_State := Enabled;
               elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
                  "class_subtype_suffix"
               then
                  Rule.Class_Subtype_Suffix :=
                    new String'(Param (First_Str_Idx .. Last_Str_Idx));
                  Rule.Rule_State := Enabled;
               elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
                 "class_access_suffix"
               then
                  Rule.Class_Access_Suffix :=
                    new String'(Param (First_Str_Idx .. Last_Str_Idx));
                  Rule.Rule_State := Enabled;
               elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
                  "constant_suffix"
               then
                  Rule.Constant_Suffix :=
                    new String'(Param (First_Str_Idx .. Last_Str_Idx));
                  Rule.Rule_State := Enabled;
               elsif To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
                  "renaming_suffix"
               then
                  Rule.Renaming_Suffix :=
                    new String'(Param (First_Str_Idx .. Last_Str_Idx));
                  Rule.Rule_State := Enabled;
               else
                  Error
                   ("(" & Rule.Name.all & ") wrong parameter name : " &
                    Param & ", ignored");
               end if;
            elsif Is_Legal_Access_Suffix then
               --  In this case we already know that
               --    To_Lower (Param (First_Par_Idx .. Last_Par_Idx)) =
               --      "access_suffix"
               Last_Str_Idx_Original := Last_Str_Idx;
               Last_Str_Idx :=
                 Index (Param (First_Str_Idx .. Last_Str_Idx), "(") - 1;
               Rule.Access_Suffix := new String'(Trim
                 (Param (First_Str_Idx .. Last_Str_Idx), Right));
               First_Str_Idx := Last_Str_Idx + 2;
               Last_Str_Idx  := Last_Str_Idx_Original - 1;
               Rule.Access_To_Access_Suffix := new String'(Trim
                 (Param (First_Str_Idx .. Last_Str_Idx), Both));
               Rule.Rule_State := Enabled;
            else
               Error
                ("(" & Rule.Name.all & ") " &
                 Param (First_Str_Idx .. Last_Str_Idx) &
                 " is not a legal name suffix, ignored");
            end if;
         else
            Error
             ("(" & Rule.Name.all & ") wrong parameter : " &
              Param & ", ignored");
         end if;
      end if;
   end Process_Rule_Parameter;
   ---------------------------------------------
   -- Rule_Check_Pre_Op (Identifier_Suffixes) --
   ---------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Identifier_Suffixes_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Control);
      pragma Unmodified  (Rule);
      Tmp            : Asis.Element;
   begin
      if Defining_Name_Kind (Element) = A_Defining_Identifier then
         Tmp := Get_Enclosing_Element;
         if Defining_Name_Kind (Tmp) = A_Defining_Expanded_Name then
            Tmp := Get_Enclosing_Element (Steps_Up => 1);
         end if;
         case Declaration_Kind (Tmp) is
            when An_Ordinary_Type_Declaration ..
                 A_Protected_Type_Declaration =>
               case Declaration_Kind (Corresponding_Type_Declaration (Tmp)) is
                  when Not_A_Declaration                    |
                       An_Incomplete_Type_Declaration       |
                       A_Tagged_Incomplete_Type_Declaration =>
                     if Rule.Type_Suffix /= null
                       or else
                        Rule.Access_Suffix /= null
                       or else
                        Rule.Class_Access_Suffix /= null
                     then
                        --  Here we have to make the difference between access
                        --  and non-access types
                        Tmp := Type_Declaration_View (Tmp);
                        if Type_Kind (Tmp) = An_Access_Type_Definition then
                           --  First, case of access-to-class type
                           if Rule.Class_Access_Suffix /= null
                             and then
                              Is_Access_To_Class (Tmp)
                           then
                              if not Has_Suffix
                                       (Element,
                                        To_Wide_String
                                          (Rule.Class_Access_Suffix.all))
                              then
                                 State.Detected  := True;
                                 State.Diagnosis := 7;
                              end if;
                              return;
                           end if;
                           if Rule.Access_Suffix /= null then
                              if Rule.Access_To_Access_Suffix = null then
                                 if not Has_Suffix
                                          (Element,
                                           To_Wide_String
                                             (Rule.Access_Suffix.all))
                                 then
                                    State.Detected  := True;
                                    State.Diagnosis := 2;
                                 end if;
                              else
                                 if Is_Access_To_Access (Tmp, Element) then
                                    if not Has_Suffix
                                             (Element,
                                              To_Wide_String
                                               (Rule.Access_Suffix.all &
                                                Rule.Access_To_Access_Suffix.
                                                  all))
                                    then
                                       State.Detected  := True;
                                       State.Diagnosis := 5;
                                    end if;
                                 else
                                    if not Has_Suffix
                                             (Element,
                                              To_Wide_String
                                                (Rule.Access_Suffix.all))
                                    then
                                       State.Detected  := True;
                                       State.Diagnosis := 2;
                                    end if;
                                 end if;
                              end if;
                           elsif Rule.Access_Suffix = null
                             and then
                                 Rule.Type_Suffix /= null
                             and then
                                 not Has_Suffix
                                       (Element,
                                       To_Wide_String (Rule.Type_Suffix.all))
                           then
                              --  If the suffix for access types is not set,
                              --  but the suffix for type defining name is set,
                              --  treat the name as an ordinary type name.
                              State.Detected  := True;
                              State.Diagnosis := 1;
                           end if;
                        else
                           if Rule.Type_Suffix /= null
                             and then
                              not Has_Suffix
                                    (Element,
                                     To_Wide_String (Rule.Type_Suffix.all))
                           then
                              State.Detected  := True;
                              State.Diagnosis := 1;
                           end if;
                        end if;
                     end if;
                  when others =>
                     --  The only real possibility is
                     --  A_Private_Type_Declaration or
                     --  A_Private_Extension_Declaration. In both cases we
                     --  do not check the defining identifier of the
                     --  corresponding type declaration
                     null;
               end case;
            when A_Private_Type_Declaration ..
                 A_Private_Extension_Declaration =>
               if Rule.Type_Suffix /= null
                 and then
                  not Has_Suffix
                       (Element, To_Wide_String (Rule.Type_Suffix.all))
               then
                  State.Detected  := True;
                  State.Diagnosis := 1;
               end if;
            when An_Incomplete_Type_Declaration ..
                 A_Tagged_Incomplete_Type_Declaration =>
               null;
            when A_Subtype_Declaration =>
               if Rule.Class_Subtype_Suffix /= null then
                  Tmp := Type_Declaration_View (Tmp);
                  Tmp := Asis.Definitions.Subtype_Mark (Tmp);
                  if (Attribute_Kind (Tmp) = A_Class_Attribute
                     or else
                      Denotes_Class_Wide_Subtype (Tmp))
                    and then
                     not Has_Suffix
                          (Element,
                           To_Wide_String (Rule.Class_Subtype_Suffix.all))
                  then
                     State.Detected  := True;
                     State.Diagnosis := 6;
                  end if;
               end if;
            when A_Constant_Declaration =>
               if Rule.Constant_Suffix /= null
                 and then
                  Is_Nil (Corresponding_Constant_Declaration (Element))
                 and then
                  not Has_Suffix
                       (Element, To_Wide_String (Rule.Constant_Suffix.all))
               then
                  State.Detected  := True;
                  State.Diagnosis := 3;
               end if;
            when A_Deferred_Constant_Declaration =>
               if Rule.Constant_Suffix /= null
                 and then
                  not Has_Suffix
                       (Element, To_Wide_String (Rule.Constant_Suffix.all))
               then
                  State.Detected  := True;
                  State.Diagnosis := 3;
               end if;
            when A_Package_Renaming_Declaration =>
               if Rule.Renaming_Suffix /= null
                 and then
                  not Has_Suffix
                       (Element, To_Wide_String (Rule.Renaming_Suffix.all))
               then
                  State.Detected  := True;
                  State.Diagnosis := 4;
               end if;
            when others =>
               null;
         end case;
      end if;
   end Rule_Check_Pre_Op;
   ---------------------------------------------
   -- Set_Rule_Defaults (Identifier_Suffixes) --
   ---------------------------------------------
   procedure Set_Rule_Defaults
     (Rule : in out Identifier_Suffixes_Rule_Type)
   is
   begin
      Free_All_Suffixes (Rule);
      Rule.Type_Suffix             := new String'("_T");
      Rule.Access_Suffix           := new String'("_A");
      Rule.Access_To_Access_Suffix := null;
      Rule.Class_Subtype_Suffix    := null;
      Rule.Class_Access_Suffix     := null;
      Rule.Constant_Suffix         := new String'("_C");
      Rule.Renaming_Suffix         := new String'("_R");
   end Set_Rule_Defaults;
   ----------------------------------------------------
   -- XML_Rule_Parameters_Help (Identifier_Suffixes) --
   ----------------------------------------------------
   procedure XML_Rule_Help
     (Rule  : Identifier_Suffixes_Rule_Type;
      Level : Natural)
   is
   begin
      Info (Level * Ident_String                  &
            "<check switch=""+R"                  &
            Rule.Name.all                         &
            ":Default"""                          &
            " label="""                           &
            "identifiers use standard suffixes""" &
            "/>");
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            ":Type_Suffix"""                   &
            " label="""                        &
            "suffix for type names"            &
            " (empty string disables check)""" &
            " separator=""="""                 &
            " switch-off=""-R"                 &
            Rule.Name.all                      &
            ":Type_Suffix"""                   &
            "/>");
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            ":Access_Suffix"""                 &
            " label="""                        &
            "suffix for access type names "    &
            " (empty string disables check)""" &
            " separator=""="""                 &
            " switch-off=""-R"                 &
            Rule.Name.all                      &
            ":Access_Suffix"""                 &
            "/>");
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            ":Constant_Suffix"""               &
            " label="""                        &
            "suffix for constant names"        &
            " (empty string disables check)""" &
            " separator=""="""                 &
            " switch-off=""-R"                 &
            Rule.Name.all                      &
            ":Constant_Suffix"""               &
            "/>");
      Info (Level * Ident_String                   &
            "<field switch=""+R"                   &
            Rule.Name.all                          &
            ":Renaming_Suffix"""                   &
            " label="""                            &
            "suffix for package renaming names"    &
            " (empty string disables check)"""     &
            " separator=""="""                     &
            " switch-off=""-R"                     &
            Rule.Name.all                          &
            ":Renaming_Suffix"""                   &
            "/>");
      --  Specifying the dependencies between the default suffixes and the
      --  content of the fields for specific suffixes
      Info (Level * Ident_String                          &
           "<default-value-dependency master-switch=""+R" &
            Rule.Name.all                                 &
            ":Default"""                                  &
            " slave-switch=""+R"                          &
            Rule.Name.all                                 &
            ":Type_Suffix=_T""/>");
      Info (Level * Ident_String                          &
           "<default-value-dependency master-switch=""+R" &
            Rule.Name.all                                 &
            ":Default"""                                  &
            " slave-switch=""+R"                          &
            Rule.Name.all                                 &
            ":Access_Suffix=_A""/>");
      Info (Level * Ident_String                          &
           "<default-value-dependency master-switch=""+R" &
            Rule.Name.all                                 &
            ":Default"""                                  &
            " slave-switch=""+R"                          &
            Rule.Name.all                                 &
            ":Constant_Suffix=_C""/>");
      Info (Level * Ident_String                          &
           "<default-value-dependency master-switch=""+R" &
            Rule.Name.all                                 &
            ":Default"""                                  &
            " slave-switch=""+R"                          &
            Rule.Name.all                                 &
            ":Renaming_Suffix=_R""/>");
   end XML_Rule_Help;
   -------------------------
   -- Identifier_Prefixes --
   -------------------------
   --------------------------------------------------------
   -- Data structures and local subprograms for the rule --
   --------------------------------------------------------
   type Identifier_Prefixes_Parameter_Kinds is
     (Not_A_Parameter,
      All_Prefixes_Par,
      Type_Par,
      Concurrent_Par,
      Access_Par,
      Class_Access_Par,
      Subprogram_Access_Par,
      Derived_Par,
      Constant_Par,
      Exception_Par,
      Enum_Par,
      Exclusive_Par);
   function Get_Identifier_Prefixes_Parameter_Kind
     (S    : String)
      return Identifier_Prefixes_Parameter_Kinds;
   --  If S denotes one of the rule parameters, returns the corresponding
   --  parameter kind, otherwise Not_A_Parameter is returned
   procedure Free_All_Prefixes (Rule : in out Identifier_Prefixes_Rule_Type);
   --  Cleans all the name suffixes to check
   function At_Least_One_Prefix_Set
     (R    : Identifier_Prefixes_Rule_Type)
      return Boolean;
   --  Checks if at least one prefix is specified
   function Has_Prefix
     (El     : Asis.Element;
      Prefix : Wide_String)
      return   Boolean;
   --  Checks if the string image of El ends with Prefix.
   function Get_Full_Parent_Name (Def : Asis.Element) return Program_Text;
   --  Provided that Def is a derived type definition, private extension
   --  definition or the definition of a formal derived type, gives the full
   --  expanded Ada name of its ancestor type (not including the very top
   --  Standard package). See ASIS_UL.Utilities.Full_Expanded_Name_Image
   --  query.
   function Is_Derived_Type_Par (S : String) return Boolean;
   --  Checks if S has the format 'full_expaned_type_name:prefix' where
   --  full_expaned_type_name has the syntax of full expanded type name, and
   --  prefix is a valid identifier prefix. It can be any number of spaces
   --  around ':'
   function Derived_Pref (C : Derived_Prefixes.Cursor) return String;
   --  Returns the parameter of "+RDerived=" option stored under C in the
   --  format "full_expanded_name_of_parent_type:prefix"
   All_Prefixes : String_Access_Sets.Set;
   function Has_Specific_Prefix (E : Asis.Element) return Boolean;
   --  Checks if E has one of the prefixes specified for specific kinds of
   --  entities. (Assumes that E is either of A_Defining_Identifier or
   --  A_Defining_Enumeration_Literal kind). All the prefixes defined for the
   --  names of specific entities are supposed to be stored in the All_Prefixes
   --  set container. When this function is called for the first time, it fills
   --  in this container with the prefixes defined by rule parameters
   --------------------------------
   -- "="  (Identifier_Prefixes) --
   --------------------------------
   function "=" (Left, Right : Derived_Pref_Record) return Boolean is
   begin
      if Left.Parent_Name = null or else Right.Parent_Name = null then
         return True;
      else
         return To_Lower (Left.Parent_Name.all) =
                To_Lower (Right.Parent_Name.all);
      end if;
   end "=";
   -------------------------------
   -- "<" (Identifier_Prefixes) --
   -------------------------------
   function "<" (Left, Right : Derived_Pref_Record) return Boolean is
   begin
      if Left.Parent_Name = null or else Right.Parent_Name = null then
         return True;
      else
         return To_Lower (Left.Parent_Name.all) <
                To_Lower (Right.Parent_Name.all);
      end if;
   end "<";
   function "<" (Left, Right : String_Access) return Boolean is
   begin
      if Left = null or else Right = null then
         return True;
      else
         return To_Lower (Left.all) < To_Lower (Right.all);
      end if;
   end "<";
   -------------------------------------------------
   -- Activate_In_Test_Mode (Identifier_Prefixes) --
   -------------------------------------------------
   overriding procedure Activate_In_Test_Mode
     (Rule : in out Identifier_Prefixes_Rule_Type)
   is
   begin
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Type=T_",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Concurrent=J_",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Access=P_",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Class_Access=CP_",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Subprogram_Access=F_",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Derived=Ada.Finalization.Controlled:CTRL_",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Enum=E_",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Constant=C_",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Exception= X_",
         Enable => True);
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "Exclusive",
         Enable => True);
   end Activate_In_Test_Mode;
   -----------------------------------------
   -- Annotate_Rule (Identifier_Prefixes) --
   -----------------------------------------
   overriding function Annotate_Rule
     (Rule : Identifier_Prefixes_Rule_Type;
      Var  : Diagnosis_Variant := 0)
      return String
   is
   begin
      if not Gnatcheck.Options.Mapping_Mode then
         return "";
      else
         return " [" & Rule_Name (Rule) & ':' &
                (case Var is
                    when  1     => "Type",
                    when  2 | 3 => "Concurrent",
                    when  4     => "Access",
                    when  5     => "Class_Acces",
                    when  6     => "Subprogram_Access",
                    when  7     => "Derived",
                    when  8     => "Constant",
                    when  9     => "Enum",
                    when 10     => "Exclusive",
                    when 11     => "Exception",
                    when others => "")
                & "]";
      end if;
   end Annotate_Rule;
   ---------------------------------------------------
   -- At_Least_One_Prefix_Set (Identifier_Prefixes) --
   ---------------------------------------------------
   function At_Least_One_Prefix_Set
     (R    : Identifier_Prefixes_Rule_Type)
      return Boolean
   is
   begin
      return
        R.Type_Prefix              /= null or else
        R.Concurrent_Prefix        /= null or else
        R.Access_Prefix            /= null or else
        R.Class_Access_Prefix      /= null or else
        R.Subprogram_Access_Prefix /= null or else
        R.Constant_Prefix          /= null or else
        R.Exception_Prefix         /= null or else
        R.Enum_Prefix              /= null or else
        not Is_Empty (R.Derived_Prefix);
   end At_Least_One_Prefix_Set;
   -------------------------------
   -- Eq  (Identifier_Prefixes) --
   -------------------------------
   function Eq (Left, Right : String_Access) return Boolean is
   begin
      if Left = null or else Right = null then
         return True;
      else
         return To_Lower (Left.all) = To_Lower (Right.all);
      end if;
   end Eq;
   ----------------------------------------
   -- Derived_Pref (Identifier_Prefixes) --
   ----------------------------------------
   function Derived_Pref (C : Derived_Prefixes.Cursor) return String is
      Def_Pref_Rec : constant Derived_Pref_Record :=
        Derived_Prefixes.Element (C);
   begin
      return Def_Pref_Rec.Parent_Name.all & ':' & Def_Pref_Rec.Prefix.all;
   end Derived_Pref;
   ---------------------------------------------
   -- Free_All_Prefixes (Identifier_Prefixes) --
   ---------------------------------------------
   procedure Free_All_Prefixes (Rule : in out Identifier_Prefixes_Rule_Type) is
   begin
      Free (Rule.Type_Prefix);
      Free (Rule.Concurrent_Prefix);
      Free (Rule.Access_Prefix);
      Free (Rule.Class_Access_Prefix);
      Free (Rule.Subprogram_Access_Prefix);
      Free (Rule.Constant_Prefix);
      Free (Rule.Exception_Prefix);
      Free (Rule.Enum_Prefix);
      --  Some memory leak here - we do not free memory for strings.
      Derived_Prefixes.Clear (Rule.Derived_Prefix);
   end Free_All_Prefixes;
   ------------------------------------------------
   -- Get_Full_Parent_Name (Identifier_Prefixes) --
   ------------------------------------------------
   function Get_Full_Parent_Name (Def : Asis.Element) return Program_Text is
      Parent_Name : Asis.Element := Def;
   begin
      case Flat_Element_Kind (Def) is
         when A_Derived_Type_Definition |
              A_Derived_Record_Extension_Definition =>
            Parent_Name := Parent_Subtype_Indication (Parent_Name);
         when A_Private_Extension_Definition =>
            Parent_Name := Ancestor_Subtype_Indication (Parent_Name);
         when others => null;
      end case;
      Parent_Name := Asis.Definitions.Subtype_Mark (Parent_Name);
      Parent_Name := Normalize_Reference (Parent_Name);
      Parent_Name := Corresponding_Name_Declaration (Parent_Name);
      Parent_Name := Corresponding_First_Subtype (Parent_Name);
      Parent_Name := First_Name (Parent_Name);
      return Full_Expanded_Name_Image (Parent_Name);
   end Get_Full_Parent_Name;
   ------------------------------------------------------------------
   -- Get_Identifier_Prefixes_Parameter_Kind (Identifier_Prefixes) --
   ------------------------------------------------------------------
   function Get_Identifier_Prefixes_Parameter_Kind
     (S    : String)
      return Identifier_Prefixes_Parameter_Kinds
   is
   begin
      return Identifier_Prefixes_Parameter_Kinds'Value (S & "_Par");
   exception
      when Constraint_Error =>
         return Not_A_Parameter;
   end Get_Identifier_Prefixes_Parameter_Kind;
   --------------------------------------
   -- Has_Prefix (Identifier_Prefixes) --
   --------------------------------------
   function Has_Prefix
     (El     : Asis.Element;
      Prefix : Wide_String)
      return   Boolean
   is
      Result : Boolean := False;
   begin
      --  At the moment this function works with A_Defining_Identifier Elements
      --  only
      Result :=
        Prefix =
        Head (Source => Defining_Name_Image (El), Count  => Prefix'Length);
      return Result;
   end Has_Prefix;
   -----------------------------------------------
   -- Has_Specific_Prefix (Identifier_Prefixes) --
   -----------------------------------------------
   function Has_Specific_Prefix (E : Asis.Element) return Boolean is
      Name_Img  : constant Program_Text := Defining_Name_Image (E);
      C_All     : String_Access_Sets.Cursor;
      C_Derived : Derived_Prefixes.Cursor;
      Result    : Boolean;
   begin
      if String_Access_Sets.Is_Empty (All_Prefixes) then
         if Identifier_Prefixes_Rule.Type_Prefix /= null then
            String_Access_Sets.Insert
              (Container => All_Prefixes,
               New_Item  =>
                 new String'(Identifier_Prefixes_Rule.Type_Prefix.all),
               Position  => C_All,
               Inserted  => Result);
         end if;
         if Identifier_Prefixes_Rule.Concurrent_Prefix /= null then
            String_Access_Sets.Insert
              (Container => All_Prefixes,
               New_Item  =>
                 new String'(Identifier_Prefixes_Rule.Concurrent_Prefix.all),
               Position  => C_All,
               Inserted  => Result);
         end if;
         if Identifier_Prefixes_Rule.Access_Prefix /= null then
            String_Access_Sets.Insert
              (Container => All_Prefixes,
               New_Item  =>
                 new String'(Identifier_Prefixes_Rule.Access_Prefix.all),
               Position  => C_All,
               Inserted  => Result);
         end if;
         if Identifier_Prefixes_Rule.Class_Access_Prefix /= null then
            String_Access_Sets.Insert
              (Container => All_Prefixes,
               New_Item  =>
                 new String'(Identifier_Prefixes_Rule.Class_Access_Prefix.all),
               Position  => C_All,
               Inserted  => Result);
         end if;
         if Identifier_Prefixes_Rule.Subprogram_Access_Prefix /= null then
            String_Access_Sets.Insert
              (Container => All_Prefixes,
               New_Item  =>
                 new String'
                   (Identifier_Prefixes_Rule.Subprogram_Access_Prefix.all),
               Position  => C_All,
               Inserted  => Result);
         end if;
         if Identifier_Prefixes_Rule.Constant_Prefix /= null then
            String_Access_Sets.Insert
              (Container => All_Prefixes,
               New_Item  =>
                 new String'(Identifier_Prefixes_Rule.Constant_Prefix.all),
               Position  => C_All,
               Inserted  => Result);
         end if;
         if Identifier_Prefixes_Rule.Exception_Prefix /= null then
            String_Access_Sets.Insert
              (Container => All_Prefixes,
               New_Item  =>
                 new String'(Identifier_Prefixes_Rule.Exception_Prefix.all),
               Position  => C_All,
               Inserted  => Result);
         end if;
         if Identifier_Prefixes_Rule.Enum_Prefix /= null then
            String_Access_Sets.Insert
              (Container => All_Prefixes,
               New_Item  =>
                 new String'(Identifier_Prefixes_Rule.Enum_Prefix.all),
               Position  => C_All,
               Inserted  => Result);
         end if;
         if not Derived_Prefixes.Is_Empty
           (Identifier_Prefixes_Rule.Derived_Prefix)
         then
            C_Derived :=
              Derived_Prefixes.First (Identifier_Prefixes_Rule.Derived_Prefix);
            while C_Derived /= Derived_Prefixes.No_Element loop
               String_Access_Sets.Insert
                 (Container => All_Prefixes,
                  New_Item  => new String'(Derived_Prefixes.Element
                                 (C_Derived).Prefix.all),
                  Position  => C_All,
                  Inserted  => Result);
               C_Derived := Next (C_Derived);
            end loop;
         end if;
      end if;
      Result := False;
      C_All := String_Access_Sets.First (All_Prefixes);
      while C_All /= String_Access_Sets.No_Element loop
         if To_Wide_String (String_Access_Sets.Element (C_All).all) =
            Head (Name_Img, String_Access_Sets.Element (C_All)'Length)
         then
            Result := True;
            exit;
         end if;
         C_All := Next (C_All);
      end loop;
      return Result;
   end Has_Specific_Prefix;
   -------------------------------------
   -- Init_Rule (Identifier_Prefixes) --
   -------------------------------------
   overriding procedure Init_Rule
     (Rule : in out Identifier_Prefixes_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Identifier_Prefixes");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("prefixes in defining names");
      Rule.Exclusive   := True;
      Rule.Diagnosis   :=
        new String'("#1#%1% does not start with prefix %2% "       &
                    "required for subtypes"                         &
                    "#2#%1% does not start with prefix %2% "       &
                    "required for task subtypes"                    &
                    "#3#%1% does not start with prefix %2% "       &
                    "required for protected subtypes"               &
                    "#4#%1% does not start with prefix %2% "       &
                    "required for access subtypes"                  &
                    "#5#%1% does not start with prefix %2% "       &
                    "required for access-to-class subtypes"         &
                    "#6#%1% does not start with prefix %2% "       &
                    "required for access-to-subprogram subtypes"    &
                    "#7#%1% does not start with prefix %2% "       &
                    "required for types derived from %3%"           &
                    "#8#%1% does not start with prefix %2% "       &
                    "required for constants"                        &
                    "#9#%1% does not start with prefix %2% "       &
                    "required for enumeration literals"             &
                    "#10#%1% has prefix reserved for a different " &
                    "identifier kind"                              &
                    "#11#%1% does not start with prefix %2% "      &
                    "required for exceptions");
   end Init_Rule;
   -----------------------------------------------
   -- Is_Derived_Type_Par (Identifier_Prefixes) --
   -----------------------------------------------
   function Is_Derived_Type_Par (S : String) return Boolean is
      Result    : Boolean;
      First_Idx : constant Natural := S'First;
      Last_Idx  : constant Natural := S'Last;
      Colon_Idx : constant Natural := Index (S, ":");
   begin
      Result :=
        Is_Ada_Name
          (To_Wide_String (Trim (S (First_Idx .. Colon_Idx - 1), Both)));
      if Result then
         Result :=
           Is_Identifier_Prefix
             (To_Wide_String (Trim (S (Colon_Idx + 1 .. Last_Idx), Both)));
      end if;
      return Result;
   end Is_Derived_Type_Par;
   --------------------------------------
   -- Print_Rule (Identifier_Prefixes) --
   --------------------------------------
   overriding procedure Print_Rule
     (Rule         : Identifier_Prefixes_Rule_Type;
      Indent_Level : Natural := 0)
   is
      First_Param       : Boolean         := True;
      Rule_Name_Padding : constant String :=
        (1 .. Rule.Name'Length + 2 => ' ');
      C : Derived_Prefixes.Cursor;
   begin
      Print_Rule (Rule_Template (Rule), Indent_Level);
      if Rule.Type_Prefix /= null then
         Report_No_EOL (": Type = " & Rule.Type_Prefix.all);
         First_Param := False;
      end if;
      if Rule.Concurrent_Prefix /= null then
         if First_Param then
            Report_No_EOL (": Concurrent = " & Rule.Concurrent_Prefix.all);
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Concurrent = " & Rule.Concurrent_Prefix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Access_Prefix /= null then
         if First_Param then
            Report_No_EOL (": Access = " & Rule.Access_Prefix.all);
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Access = " & Rule.Access_Prefix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Class_Access_Prefix /= null then
         if First_Param then
            Report_No_EOL (": Class_Access = " & Rule.Class_Access_Prefix.all);
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Class_Access = " & Rule.Class_Access_Prefix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Subprogram_Access_Prefix /= null then
         if First_Param then
            Report_No_EOL (": Subprogram_Access = " &
                           Rule.Subprogram_Access_Prefix.all);
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Subprogram_Access = " & Rule.Subprogram_Access_Prefix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Constant_Prefix /= null then
         if First_Param then
            Report_No_EOL (": Constant = " & Rule.Constant_Prefix.all);
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Constant = " & Rule.Constant_Prefix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Exception_Prefix /= null then
         if First_Param then
            Report_No_EOL (": Exception = " & Rule.Exception_Prefix.all);
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Exception = " & Rule.Exception_Prefix.all,
              Indent_Level);
         end if;
      end if;
      if Rule.Enum_Prefix /= null then
         if First_Param then
            Report_No_EOL (": Enum = " & Rule.Enum_Prefix.all);
            First_Param := False;
         else
            Report (", ");
            Report_No_EOL
              (Rule_Name_Padding &
               "Enum = " & Rule.Enum_Prefix.all,
              Indent_Level);
         end if;
      end if;
      if not Derived_Prefixes.Is_Empty (Rule.Derived_Prefix) then
         C := Derived_Prefixes.First (Rule.Derived_Prefix);
         while C /= Derived_Prefixes.No_Element loop
            if First_Param then
               Report_No_EOL (": Derived  = " & Derived_Pref (C));
               First_Param := False;
            else
               Report (", ");
               Report_No_EOL
                 (Rule_Name_Padding &
                  "Derived = " & Derived_Pref (C),
                 Indent_Level);
            end if;
            C := Next (C);
         end loop;
      end if;
      --  We have to print out Exclusive parameter, but this would make sense
      --  only if at least one prefix is specified
      if not First_Param and then Rule.Exclusive then
         Report (", ");
         Report_No_EOL
           (Rule_Name_Padding & "Exclusive");
      end if;
   end Print_Rule;
   ----------------------------------------------
   -- Print_Rule_To_File (Identifier_Prefixes) --
   ----------------------------------------------
   overriding procedure Print_Rule_To_File
     (Rule         : Identifier_Prefixes_Rule_Type;
      Rule_File    : File_Type;
      Indent_Level : Natural := 0)
   is
      First_Param       : Boolean         := True;
      Rule_Name_Padding : constant String :=
        (1 .. Rule.Name'Length + 4 => ' ');
      C : Derived_Prefixes.Cursor;
   begin
      Print_Rule_To_File (Rule_Template (Rule), Rule_File, Indent_Level);
      if Rule.Type_Prefix /= null then
         Put (Rule_File, ": Type = " & Rule.Type_Prefix.all);
         First_Param := False;
      end if;
      if Rule.Concurrent_Prefix /= null then
         if First_Param then
            Put (Rule_File, ": Concurrent = " & Rule.Concurrent_Prefix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Concurrent = " & Rule.Concurrent_Prefix.all);
         end if;
      end if;
      if Rule.Access_Prefix /= null then
         if First_Param then
            Put (Rule_File, ": Access = " & Rule.Access_Prefix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding & "Access = " & Rule.Access_Prefix.all);
         end if;
      end if;
      if Rule.Class_Access_Prefix /= null then
         if First_Param then
            Put
              (Rule_File, ": Class_Access = " & Rule.Class_Access_Prefix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Class_Access = " & Rule.Class_Access_Prefix.all);
         end if;
      end if;
      if Rule.Subprogram_Access_Prefix /= null then
         if First_Param then
            Put (Rule_File,
                ": Subprogram_Access = " & Rule.Subprogram_Access_Prefix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding &
                 "Subprogram_Access = " & Rule.Subprogram_Access_Prefix.all);
         end if;
      end if;
      if Rule.Constant_Prefix /= null then
         if First_Param then
            Put (Rule_File, ": Constant = " & Rule.Constant_Prefix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding & "Constant = " & Rule.Constant_Prefix.all);
         end if;
      end if;
      if Rule.Exception_Prefix /= null then
         if First_Param then
            Put (Rule_File, ": Exception = " & Rule.Exception_Prefix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding & "Exception = " &
                 Rule.Exception_Prefix.all);
         end if;
      end if;
      if Rule.Enum_Prefix /= null then
         if First_Param then
            Put (Rule_File, ": Enum = " & Rule.Enum_Prefix.all);
            First_Param := False;
         else
            Put_Line (Rule_File, ", ");
            for J in 1 .. Indent_Level loop
               Put (Rule_File, Get_Indent_String);
            end loop;
            Put (Rule_File,
                 Rule_Name_Padding & "Enum = " & Rule.Enum_Prefix.all);
         end if;
      end if;
      if not Derived_Prefixes.Is_Empty (Rule.Derived_Prefix) then
         C := Derived_Prefixes.First (Rule.Derived_Prefix);
         while C /= Derived_Prefixes.No_Element loop
            if First_Param then
               Put (Rule_File, ": Derived  = " & Derived_Pref (C));
               First_Param := False;
            else
               Put_Line (Rule_File, ", ");
               for J in 1 .. Indent_Level loop
                  Put (Rule_File, Get_Indent_String);
               end loop;
               Put (Rule_File,
                    Rule_Name_Padding & "Derived = " & Derived_Pref (C));
            end if;
            C := Next (C);
         end loop;
      end if;
      --  We have to print out Exclusive parameter, but this would make sense
      --  only if at least one prefix is specified
      if not First_Param and then Rule.Exclusive then
         Put_Line (Rule_File, ", ");
         Put (Rule_File, Rule_Name_Padding & "Exclusive");
      end if;
   end Print_Rule_To_File;
   --------------------------------------------------
   -- Process_Rule_Parameter (Identifier_Prefixes) --
   --------------------------------------------------
   overriding procedure Process_Rule_Parameter
     (Rule    : in out Identifier_Prefixes_Rule_Type;
      Param   :        String;
      Enable  :        Boolean)
   is
      First_Str_Idx, Last_Str_Idx : Natural;
      --  Beginning and end of the 'string' part of the parameter, see the
      --  rule parameter description in the spec. First_Str_Idx is set to 0 if
      --  the parameter does not contain a '=' character.
      First_Par_Idx, Last_Par_Idx : Natural;
      --  If the parameter contains a '=' character, set to point to the
      --  beginning and the end of the part of the parameter that precedes '='.
      --  Otherwise First_Par_Idx points to the first, and Last_Par_Idx - to
      --  the last non-blank character in Param (First_Idx .. Last_Idx)
      Is_Legal_Prefix       : Boolean := False;
      Is_Legal_Der_Type_Par : Boolean := False;
      Parameter_Kind : Identifier_Prefixes_Parameter_Kinds;
   begin
      if Param = "" then
         if Enable then
            Rule.Rule_State := Enabled;
         else
            Rule.Rule_State := Disabled;
         end if;
         return;
      end if;
      Parse_Par
        (First_Par_Idx, Last_Par_Idx, First_Str_Idx, Last_Str_Idx, Param);
      Parameter_Kind :=
        Get_Identifier_Prefixes_Parameter_Kind
          (Param (First_Par_Idx .. Last_Par_Idx));
      if Parameter_Kind = Not_A_Parameter then
         Error ("(" & Rule.Name.all & ") wrong parameter : " &
                Param & ", ignored");
         return;
      end if;
      if First_Str_Idx = 0 then
         if Enable then  --  +R
            if Parameter_Kind =  Exclusive_Par then
               Rule.Exclusive := True;
               if At_Least_One_Prefix_Set (Rule) then
                  Rule.Rule_State := Enabled;
               end if;
            else
               Error
                ("(" & Rule.Name.all & ") wrong parameter : " &
                 Param & ", ignored");
            end if;
         else    --  -R
            case Parameter_Kind is
               when All_Prefixes_Par =>
                  Free_All_Prefixes (Rule);
                  Rule.Rule_State := Disabled;
               when Type_Par =>
                  Free (Rule.Type_Prefix);
               when Concurrent_Par =>
                  Free (Rule.Concurrent_Prefix);
               when Access_Par =>
                  Free (Rule.Access_Prefix);
               when Class_Access_Par =>
                  Free (Rule.Class_Access_Prefix);
               when Subprogram_Access_Par =>
                  Free (Rule.Subprogram_Access_Prefix);
               when Derived_Par =>
                  Free_All_Prefixes (Rule);
               when Constant_Par =>
                  Free (Rule.Constant_Prefix);
               when Exception_Par =>
                  Free (Rule.Exception_Prefix);
               when Enum_Par =>
                  Free (Rule.Enum_Prefix);
               when Exclusive_Par =>
                  Rule.Exclusive := False;
               when others =>
                  pragma Assert (False);
                  return;
            end case;
            if not At_Least_One_Prefix_Set (Rule) then
               Rule.Rule_State := Disabled;
            end if;
         end if;
      else
         if not Enable
           or else Parameter_Kind = Exclusive_Par
         then
            Error
             ("(" & Rule.Name.all & ") wrong parameter : " &
              Param & ", ignored");
            return;
         end if;
         if Parameter_Kind = Derived_Par then
            Is_Legal_Der_Type_Par :=
              Is_Derived_Type_Par (Param (First_Str_Idx .. Last_Str_Idx));
         else
            Is_Legal_Prefix :=
              Is_Identifier_Prefix
                (To_Wide_String (Param (First_Str_Idx .. Last_Str_Idx)));
         end if;
         if not (Is_Legal_Prefix or else Is_Legal_Der_Type_Par) then
            Error
             ("(" & Rule.Name.all & ") wrong parameter : " &
              Param & ", ignored");
            return;
         end if;
         case Parameter_Kind is
            when Type_Par =>
               Rule.Type_Prefix :=
                 new String'(Param (First_Str_Idx .. Last_Str_Idx));
            when Concurrent_Par =>
               Rule.Concurrent_Prefix :=
                 new String'(Param (First_Str_Idx .. Last_Str_Idx));
            when Access_Par =>
               Rule.Access_Prefix :=
                 new String'(Param (First_Str_Idx .. Last_Str_Idx));
            when Class_Access_Par =>
               Rule.Class_Access_Prefix :=
                 new String'(Param (First_Str_Idx .. Last_Str_Idx));
            when Subprogram_Access_Par =>
               Rule.Subprogram_Access_Prefix :=
                 new String'(Param (First_Str_Idx .. Last_Str_Idx));
            when Derived_Par =>
               declare
                  Colon_Idx : constant Natural :=
                    Index (Param (First_Str_Idx .. Last_Str_Idx), ":");
                  New_Pref : Derived_Pref_Record;
                  C        : Derived_Prefixes.Cursor;
                  Inserted : Boolean;
               begin
                  New_Pref.Parent_Name := new String'
                    (Trim (Param (First_Str_Idx .. Colon_Idx - 1), Right));
                  New_Pref.Prefix := new String'
                    (Trim (Param (Colon_Idx + 1 .. Last_Str_Idx), Left));
                  Derived_Prefixes.Insert
                    (Container => Rule.Derived_Prefix,
                     New_Item  => New_Pref,
                     Position  => C,
                     Inserted  => Inserted);
                  if not Inserted then
                     Derived_Prefixes.Replace_Element
                       (Container => Rule.Derived_Prefix,
                        Position  => C,
                        New_Item  => New_Pref);
                  end if;
               end;
            when Constant_Par =>
               Rule.Constant_Prefix :=
                 new String'(Param (First_Str_Idx .. Last_Str_Idx));
            when Exception_Par =>
               Rule.Exception_Prefix :=
                 new String'(Param (First_Str_Idx .. Last_Str_Idx));
            when Enum_Par =>
               Rule.Enum_Prefix :=
                 new String'(Param (First_Str_Idx .. Last_Str_Idx));
            when others =>
               pragma Assert (False);
               return;
         end case;
         Rule.Rule_State := Enabled;
      end if;
   end Process_Rule_Parameter;
   ---------------------------------------------
   -- Rule_Check_Pre_Op (Identifier_Prefixes) --
   ---------------------------------------------
   overriding procedure Rule_Check_Pre_Op
     (Rule    : in out Identifier_Prefixes_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Control);
      Tmp             : Asis.Element;
      Check_Exclusive : Boolean := False;
      Derived_Check   : Derived_Pref_Record;
      C_Pref_To_Check : Derived_Prefixes.Cursor;
   begin
      case Defining_Name_Kind (Element) is
         when A_Defining_Identifier =>
            Tmp := Get_Enclosing_Element;
            if Declaration_Kind (Tmp) = A_Subtype_Declaration then
               Tmp := Corresponding_First_Subtype (Tmp);
            end if;
         when A_Defining_Enumeration_Literal =>
            Tmp := Element;
         when others =>
            return;
      end case;
      case Flat_Element_Kind (Tmp) is
         when A_Defining_Enumeration_Literal =>
            if Rule.Enum_Prefix /= null then
               if not Has_Prefix
                 (Element, To_Wide_String (Rule.Enum_Prefix.all))
               then
                  State.Detected    := True;
                  State.Diagnosis   := 9;
                  State.Diag_Params :=
                    Enter_String
                      ("%1%" & To_String (Defining_Name_Image (Element))
                       &
                       "%2%" & Rule.Enum_Prefix.all);
               end if;
               return;
            else
               Check_Exclusive := True;
            end if;
         when A_Function_Renaming_Declaration =>
            if not Is_Equal (Corresponding_Declaration (Tmp), Tmp) then
               --  Renaming-as-body, completion of another declaration, so
               return;
            end if;
            Tmp := Corresponding_Base_Entity (Tmp);
            if Expression_Kind (Tmp) = A_Selected_Component then
               Tmp := Selector (Tmp);
            end if;
            if Expression_Kind (Tmp) = An_Enumeration_Literal then
               if Rule.Enum_Prefix /= null then
                  if not Has_Prefix
                    (Element, To_Wide_String (Rule.Enum_Prefix.all))
                  then
                     State.Detected    := True;
                     State.Diagnosis   := 9;
                     State.Diag_Params :=
                       Enter_String
                         ("%1%" & To_String (Defining_Name_Image (Element))
                          &
                          "%2%" & Rule.Enum_Prefix.all);
                  end if;
                  return;
               else
                  Check_Exclusive := True;
               end if;
            else
               Check_Exclusive := True;
            end if;
         when A_Procedure_Renaming_Declaration =>
            if not Is_Equal (Corresponding_Declaration (Tmp), Tmp) then
               --  Renaming-as-body, completion of another declaration, so
               return;
            end if;
         when A_Constant_Declaration          |
              A_Deferred_Constant_Declaration |
              An_Integer_Number_Declaration   |
              A_Real_Number_Declaration       |
              An_Object_Renaming_Declaration  =>
            if Flat_Element_Kind (Tmp) = A_Constant_Declaration
             and then
               not Is_Nil (Corresponding_Constant_Declaration (Element))
            then
               --  No check for names from full declarations that correspond to
               --  deferred constants
               return;
            end if;
            if Flat_Element_Kind (Tmp) /= An_Object_Renaming_Declaration
              or else
               Is_Constant (First_Name (Tmp))
            then
               if Rule.Constant_Prefix /= null then
                  if not Has_Prefix
                    (Element, To_Wide_String (Rule.Constant_Prefix.all))
                  then
                     State.Detected    := True;
                     State.Diagnosis   := 8;
                     State.Diag_Params :=
                       Enter_String
                         ("%1%" & To_String (Defining_Name_Image (Element))
                          &
                          "%2%" & Rule.Constant_Prefix.all);
                  end if;
                  return;
               end if;
            end if;
            Check_Exclusive := True;
         when An_Exception_Declaration          |
              An_Exception_Renaming_Declaration =>
            if Rule.Exception_Prefix /= null then
               if not Has_Prefix
                 (Element, To_Wide_String (Rule.Exception_Prefix.all))
               then
                  State.Detected    := True;
                  State.Diagnosis   := 11;
                  State.Diag_Params :=
                    Enter_String
                      ("%1%" & To_String (Defining_Name_Image (Element))
                       &
                       "%2%" & Rule.Exception_Prefix.all);
               end if;
               return;
            else
               Check_Exclusive := True;
            end if;
         when An_Ordinary_Type_Declaration    |
              A_Task_Type_Declaration         |
              A_Protected_Type_Declaration    |
              A_Private_Type_Declaration      |
              A_Private_Extension_Declaration |
              A_Formal_Type_Declaration       =>
            if Flat_Element_Kind (Tmp) in
               An_Ordinary_Type_Declaration .. A_Protected_Type_Declaration
              and then
               Declaration_Kind (Corresponding_Type_Declaration (Tmp)) in
               A_Private_Type_Declaration .. A_Private_Extension_Declaration
            then
               --  No check for full type declarations corresponding to
               --  private types
               return;
            end if;
            if Flat_Element_Kind (Tmp) in
               A_Task_Type_Declaration .. A_Protected_Type_Declaration
              and then
               Rule.Concurrent_Prefix /= null
            then
               if not Has_Prefix
                 (Element, To_Wide_String (Rule.Concurrent_Prefix.all))
               then
                  State.Detected := True;
                  if Flat_Element_Kind (Tmp) = A_Task_Type_Declaration then
                     State.Diagnosis := 2;
                  else
                     State.Diagnosis := 3;
                  end if;
                  State.Diag_Params :=
                    Enter_String
                      ("%1%" & To_String (Defining_Name_Image (Element))
                       &
                       "%2%" & Rule.Concurrent_Prefix.all);
               end if;
               return;
            end if;
            Tmp := Type_Declaration_View (Tmp);
            if Type_Kind (Tmp) = An_Access_Type_Definition
              or else
               Formal_Type_Kind (Tmp) = A_Formal_Access_Type_Definition
            then
               if Access_Type_Kind (Tmp) in
                  An_Access_To_Procedure .. An_Access_To_Protected_Function
                 and then
                   Rule.Subprogram_Access_Prefix /= null
               then
                  if not Has_Prefix
                    (Element,
                     To_Wide_String (Rule.Subprogram_Access_Prefix.all))
                  then
                     State.Detected    := True;
                     State.Diagnosis   := 6;
                     State.Diag_Params :=
                       Enter_String
                         ("%1%" & To_String (Defining_Name_Image (Element))
                          &
                          "%2%" & Rule.Subprogram_Access_Prefix.all);
                  end if;
                  return;
               end if;
               if Is_Access_To_Class (Tmp) and then
                  Rule.Class_Access_Prefix /= null
               then
                  if not Has_Prefix
                    (Element,
                     To_Wide_String (Rule.Class_Access_Prefix.all))
                  then
                     State.Detected    := True;
                     State.Diagnosis   := 5;
                     State.Diag_Params :=
                       Enter_String
                         ("%1%" & To_String (Defining_Name_Image (Element))
                          &
                          "%2%" & Rule.Class_Access_Prefix.all);
                  end if;
                  return;
               end if;
               if Rule.Access_Prefix /= null then
                  if not Has_Prefix
                    (Element, To_Wide_String (Rule.Access_Prefix.all))
                  then
                     State.Detected    := True;
                     State.Diagnosis   := 4;
                     State.Diag_Params :=
                       Enter_String
                         ("%1%" & To_String (Defining_Name_Image (Element))
                          &
                          "%2%" & Rule.Access_Prefix.all);
                  end if;
                  return;
               end if;
            end if;
            if Type_Kind (Tmp) in
               A_Derived_Type_Definition ..
                 A_Derived_Record_Extension_Definition
              or else
               Formal_Type_Kind (Tmp) = A_Formal_Derived_Type_Definition
              or else
               Declaration_Kind (Get_Enclosing_Element) =
                 A_Private_Extension_Declaration
            then
               Derived_Check.Parent_Name :=
                 new String'(To_String (Get_Full_Parent_Name (Tmp)));
               if Derived_Check.Parent_Name.all /= "" then
                  C_Pref_To_Check :=
                    Find (Rule.Derived_Prefix, Derived_Check);
                  if C_Pref_To_Check /= Derived_Prefixes.No_Element then
                     if not Has_Prefix
                       (Element,
                        To_Wide_String
                          (Derived_Prefixes.Element
                             (C_Pref_To_Check).Prefix.all))
                     then
                        State.Detected    := True;
                        State.Diagnosis   := 7;
                        State.Diag_Params :=
                          Enter_String
                            ("%1%" & To_String (Defining_Name_Image (Element))
                             &
                             "%2%" & Derived_Prefixes.Element
                                       (C_Pref_To_Check).Prefix.all
                             &
                             "%3%" & Derived_Check.Parent_Name.all);
                     end if;
                     return;
                  end if;
               end if;
            end if;
            if Rule.Type_Prefix /= null then
               if not Has_Prefix
                 (Element, To_Wide_String (Rule.Type_Prefix.all))
               then
                  State.Detected  := True;
                  State.Diagnosis := 1;
                  State.Diag_Params :=
                    Enter_String
                      ("%1%" & To_String (Defining_Name_Image (Element))
                       &
                       "%2%" & Rule.Type_Prefix.all);
               end if;
               return;
            else
               Check_Exclusive := True;
            end if;
         when An_Incomplete_Type_Declaration       |
              A_Tagged_Incomplete_Type_Declaration |
              A_Formal_Incomplete_Type_Declaration =>
            --  These names are never checked
            return;
         when A_Procedure_Body_Stub .. A_Function_Body_Stub =>
            if Is_Nil (Corresponding_Declaration (Tmp)) then
               Check_Exclusive := True;
            else
               --  Completion of another declaration
               return;
            end if;
         when A_Procedure_Body_Declaration |
              A_Function_Body_Declaration  =>
            if Is_Subunit (Tmp) or else
               not Is_Nil (Corresponding_Declaration (Tmp))
            then
               --  Completion of another declaration
               return;
            else
               Check_Exclusive := True;
            end if;
         when A_Package_Body_Declaration   |
              A_Task_Body_Declaration      |
              A_Protected_Body_Declaration |
              An_Entry_Body_Declaration    |
              A_Package_Body_Stub          |
              A_Task_Body_Stub             |
              A_Protected_Body_Stub        =>
            --  Completion of another declaration
            return;
         when others =>
            Check_Exclusive := True;
      end case;
      if Check_Exclusive
       and then
         Rule.Exclusive
       and then
         Has_Specific_Prefix (Element)
      then
         State.Detected    := True;
         State.Diagnosis   := 10;
         State.Diag_Params :=
           Enter_String ("%1%" & To_String (Defining_Name_Image (Element)));
      end if;
   end Rule_Check_Pre_Op;
   -----------------------------------------
   -- XML_Rule_Help (Identifier_Prefixes) --
   -----------------------------------------
   overriding procedure XML_Rule_Help
     (Rule  : Identifier_Prefixes_Rule_Type;
      Level : Natural)
   is
   begin
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            ":Type"""                          &
            " label="""                        &
            "prefix for type names"            &
            " (empty string disables check)""" &
            " separator=""="""                 &
            " switch-off=""-R"                 &
            Rule.Name.all                      &
            ":Type"""                          &
            "/>");
      Info (Level * Ident_String                       &
            "<field switch=""+R"                       &
            Rule.Name.all                              &
            ":Concurrent"""                            &
            " label="""                                &
            "prefix for task and protected type names" &
            " (empty string disables check)"""         &
            " separator=""="""                         &
            " switch-off=""-R"                         &
            Rule.Name.all                              &
            ":Concurrent"""                            &
            "/>");
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            ":Access"""                        &
            " label="""                        &
            "prefix for access type names"     &
            " (empty string disables check)""" &
            " separator=""="""                 &
            " switch-off=""-R"                 &
            Rule.Name.all                      &
            ":Access"""                        &
            "/>");
      Info (Level * Ident_String                 &
            "<field switch=""+R"                 &
            Rule.Name.all                        &
            ":Class_Access"""                    &
            " label="""                          &
            "prefix for class access type names" &
            " (empty string disables check)"""   &
            " separator=""="""                   &
            " switch-off=""-R"                   &
            Rule.Name.all                        &
            ":Class_Access"""                    &
            "/>");
      Info (Level * Ident_String                         &
            "<field switch=""+R"                         &
            Rule.Name.all                                &
            ":Subprogram_Access"""                       &
            " label="""                                  &
            "prefix for access-to-subprogram type names" &
            " (empty string disables check)"""           &
            " separator=""="""                           &
            " switch-off=""-R"                           &
            Rule.Name.all                                &
            ":Subprogram_Access"""                       &
            "/>");
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            ":Derived"""                       &
            " label="""                        &
            "prefix for derived type names"    &
            " (empty string disables check)""" &
            " separator=""="""                 &
            " switch-off=""-R"                 &
            Rule.Name.all                      &
            ":Derived"""                       &
            "/>");
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            ":Constant"""                      &
            " label="""                        &
            "prefix for constant names"        &
            " (empty string disables check)""" &
            " separator=""="""                 &
            " switch-off=""-R"                 &
            Rule.Name.all                      &
            ":Constant"""                      &
            "/>");
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            ":Exception"""                     &
            " label="""                        &
            "prefix for exception names"       &
            " (empty string disables check)""" &
            " separator=""="""                 &
            " switch-off=""-R"                 &
            Rule.Name.all                      &
            ":Exception"""                     &
            "/>");
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            ":Enum"""                          &
            " label="""                        &
            "prefix for enumeration literals"  &
            " (empty string disables check)""" &
            " separator=""="""                 &
            " switch-off=""-R"                 &
            Rule.Name.all                      &
            ":Enum"""                          &
            "/>");
      Info (Level * Ident_String               &
            "<check  switch=""+R"              &
            Rule.Name.all                      &
            ":Exclusive"""                     &
            " label="""                        &
            "strong check mode""/>");
   end XML_Rule_Help;
   ---------------------------------
   -- Implicit_IN_Mode_Parameters --
   ---------------------------------
   ---------------------------------------------
   -- Init_Rule (Implicit_IN_Mode_Parameters) --
   ---------------------------------------------
   procedure Init_Rule (Rule : in out Implicit_IN_Mode_Parameters_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Implicit_IN_Mode_Parameters");
      Rule.Synonym     := new String'("Implicit_IN_Parameter_Mode");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("implicit IN mode in parameter " &
                                      "specifications");
      Rule.Diagnosis   := new String'("implicit IN mode in parameter " &
                                      "specification");
   end Init_Rule;
   -----------------------------------------------------
   -- Rule_Check_Pre_Op (Implicit_IN_Mode_Parameters) --
   -----------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Implicit_IN_Mode_Parameters_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Declaration_Kind (Element) = A_Parameter_Specification
       and then
         Mode_Kind (Element) = A_Default_In_Mode
       and then
         Definition_Kind (Object_Declaration_View (Element)) /=
           An_Access_Definition
      then
         State.Detected := True;
      end if;
   end Rule_Check_Pre_Op;
   ------------------------------------------
   -- Implicit_SMALL_For_Fixed_Point_Types --
   ------------------------------------------
   ------------------------------------------------------
   -- Init_Rule (Implicit_SMALL_For_Fixed_Point_Types) --
   ------------------------------------------------------
   procedure Init_Rule
     (Rule : in out Implicit_SMALL_For_Fixed_Point_Types_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Implicit_SMALL_For_Fixed_Point_Types");
      Rule.Synonym     := new String'("Missing_Small_For_Fixed_Point_Type");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("fixed point type declarations with no "
                                    & "'Small clause");
      Rule.Diagnosis   := new String'("fixed point type declaration with no "
                                    & "'Small clause");
   end Init_Rule;
   --------------------------------------------------------------
   -- Rule_Check_Pre_Op (Implicit_SMALL_For_Fixed_Point_Types) --
   --------------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Implicit_SMALL_For_Fixed_Point_Types_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Type_Kind (Element) = An_Ordinary_Fixed_Point_Definition then
         State.Detected := True;
         declare
            Rep_Clauses : constant Asis.Element_List :=
              Corresponding_Representation_Clauses (Get_Enclosing_Element);
         begin
            for J in Rep_Clauses'Range loop
               if Representation_Clause_Kind (Rep_Clauses (J)) =
                    An_Attribute_Definition_Clause
                 and then
                  Attribute_Kind
                    (Representation_Clause_Name (Rep_Clauses (J))) =
                      A_Small_Attribute
               then
                  State.Detected := False;
                  exit;
               end if;
            end loop;
         end;
      end if;
   end Rule_Check_Pre_Op;
   ---------------------------------------
   -- Improperly_Located_Instantiations --
   ---------------------------------------
   ---------------------------------------------------
   -- Init_Rule (Improperly_Located_Instantiations) --
   ---------------------------------------------------
   procedure Init_Rule
     (Rule : in out Improperly_Located_Instantiations_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Improperly_Located_Instantiations");
      Rule.Synonym    := new String'("Unreasonable_Places_For_Instantiations");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info  := new String'("instantiations that can cause problems");
      Rule.Diagnosis   :=
        new String'("#1#instantiation in a subprogram body" &
                    "#2#instantiation in a library package spec" &
                    "#3#instantiation in a generic library package spec");
   end Init_Rule;
   -----------------------------------------------------------
   -- Rule_Check_Pre_Op (Improperly_Located_Instantiations) --
   -----------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Improperly_Located_Instantiations_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Encl_CU   : Asis.Compilation_Unit;
      Encl_Body : Asis.Element;
      Step_Up   : Elmt_Idx := 0;
   begin
      if Declaration_Kind (Element) in A_Generic_Instantiation then
         Encl_CU := Enclosing_Compilation_Unit (Element);
         case Unit_Kind (Encl_CU) is
            when A_Package =>
               State.Detected := True;
               State.Diagnosis := 2;
            when A_Generic_Package =>
               State.Detected := True;
               State.Diagnosis := 3;
            when A_Subprogram_Body        |
                 A_Procedure_Body_Subunit |
                 A_Function_Body_Subunit  =>
               State.Detected := True;
               State.Diagnosis := 1;
            when A_Package_Body           |
                 A_Protected_Body_Subunit =>
               Encl_Body := Get_Enclosing_Element;
               while not Is_Nil (Encl_Body) loop
                  if Declaration_Kind (Encl_Body) in
                    A_Procedure_Body_Declaration ..
                    A_Function_Body_Declaration
                  then
                     State.Detected := True;
                     State.Diagnosis := 1;
                     exit;
                  elsif Declaration_Kind (Encl_Body) = A_Task_Body_Declaration
                    or else
                        Declaration_Kind (Encl_Body) =
                          An_Entry_Body_Declaration
                  then
                     exit;
                  else
                     Step_Up := Step_Up + 1;
                     Encl_Body := Get_Enclosing_Element (Step_Up);
                  end if;
               end loop;
            when A_Subprogram_Declaration    |
                 A_Generic_Procedure         |
                 A_Generic_Function          |
                 A_Renaming                  |
                 A_Generic_Unit_Instance     |
                 A_Package_Body_Subunit      |
                 A_Task_Body_Subunit         |
                 A_Nonexistent_Declaration   |
                 A_Nonexistent_Body          |
                 A_Configuration_Compilation |
                 An_Unknown_Unit             |
                 Not_A_Unit                  =>
               null;
         end case;
      end if;
   end Rule_Check_Pre_Op;
   ---------------------------------
   -- Non_Short_Circuit_Operators --
   ---------------------------------
   ---------------------------------------------
   -- Init_Rule (Non_Short_Circuit_Operators) --
   ---------------------------------------------
   procedure Init_Rule (Rule : in out Non_Short_Circuit_Operators_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Non_Short_Circuit_Operators");
      Rule.Synonym     := new String'("Use_Of_Non_Short_Circuit");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("use of predefined AND and OR for " &
                                      "boolean types");
      Rule.Diagnosis   :=
        new String'("#1#use of predefined AND for boolean type" &
                    "#2#use of predefined OR for boolean type");
   end Init_Rule;
   -----------------------------------------------------
   -- Rule_Check_Pre_Op (Non_Short_Circuit_Operators) --
   -----------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Non_Short_Circuit_Operators_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Call : Asis.Element;
   begin
      if Operator_Kind (Element) in An_And_Operator .. An_Or_Operator then
         Call := Get_Enclosing_Element;
         if Expression_Kind (Call) = A_Selected_Component then
            Call := Get_Enclosing_Element (Steps_Up => 1);
         end if;
         if Expression_Kind (Call) = A_Function_Call
           and then
            Is_Predefined_Operator (Element)
           and then
            Is_Boolean_Logical_Op (Element)
         then
            State.Detected := True;
            if Operator_Kind (Element) = An_And_Operator then
               State.Diagnosis := 1;
            else
               State.Diagnosis := 2;
            end if;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   ----------------------------
   -- Non_Visible_Exceptions --
   ----------------------------
   --------------------------------------
   -- Has_Tip (Non_Visible_Exceptions) --
   --------------------------------------
   function Has_Tip (Rule : Non_Visible_Exceptions_Rule_Type) return Boolean is
      pragma Unreferenced (Rule);
   begin
      return True;
   end Has_Tip;
   ----------------------------------------
   -- Init_Rule (Non_Visible_Exceptions) --
   ----------------------------------------
   procedure Init_Rule (Rule : in out Non_Visible_Exceptions_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Non_Visible_Exceptions");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("potential propagations of " &
                                      "non-visible exceptions");
      Rule.Diagnosis   :=
        new String'("#1#no handler for this exception in enclosing body" &
                    "#2#no handler for this exception in enclosing block" &
                    "#3#propagates the local exception " &
                    "declared at line %1% outside its visibility");
   end Init_Rule;
   ------------------------------------------------
   -- Rule_Check_Pre_Op (Non_Visible_Exceptions) --
   ------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Non_Visible_Exceptions_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Handler     : Asis.Element;
      Handled_Exc : Asis.Element;
      Raised_Exc  : Asis.Element;
      Frame       : Asis.Element;
      Step_Up     : Elmt_Idx := 0;
   begin
      --  First part of the rule - declarations of local non-handled
      --  exceptions:
      if Defining_Name_Kind (Element) = A_Defining_Identifier
        and then
         Declaration_Kind (Get_Enclosing_Element) = An_Exception_Declaration
        and then
         (Declaration_Kind (Get_Enclosing_Element (Steps_Up => 1)) in
            A_Procedure_Body_Declaration .. A_Function_Body_Declaration
         or else
          Declaration_Kind (Get_Enclosing_Element (Steps_Up => 1)) =
             A_Task_Body_Declaration
         or else
          Statement_Kind (Get_Enclosing_Element (Steps_Up => 1)) =
             A_Block_Statement)
      then
         State.Detected := not
           Is_Handled
             (Exc => Element,
              By  => Get_Handlers (Get_Enclosing_Element (Steps_Up => 1)));
         if Statement_Kind (Get_Enclosing_Element (Steps_Up => 1)) =
              A_Block_Statement
         then
            State.Diagnosis := 2;
         else
            State.Diagnosis := 1;
         end if;
      end if;
      --  Second part of the rule - potential propagation of a local exception
      --  outside its visibility
      if Statement_Kind (Element) = A_Raise_Statement then
         Handler := Get_Enclosing_Element (Step_Up);
         while Element_Kind (Handler) in A_Statement .. A_Path loop
            Step_Up := Step_Up + 1;
            Handler := Get_Enclosing_Element (Step_Up);
         end loop;
         Frame := Get_Enclosing_Element (Steps_Up => Step_Up + 1);
         if Element_Kind (Handler) = An_Exception_Handler
           and then
            (Declaration_Kind (Frame) in
             A_Procedure_Body_Declaration .. A_Function_Body_Declaration
            or else
             Declaration_Kind (Frame) = A_Task_Body_Declaration
            or else
             Statement_Kind (Frame) = A_Block_Statement)
         then
            --  Two different cases, depending if the raise statement contains
            --  an exception name
            Raised_Exc := Raised_Exception (Element);
            if Is_Nil (Raised_Exc) then
               declare
                  Handled_Excs : constant Asis.Element_List :=
                    Exception_Choices (Handler);
               begin
                  for J in Handled_Excs'Range loop
                     if Definition_Kind (Handled_Excs (J)) =
                        An_Others_Choice
                     then
                        exit;
                     end if;
                     Handled_Exc :=
                       Enclosing_Element
                         (Get_Name_Definition (Handled_Excs (J)));
                     if Is_Equal
                          (Enclosing_Element (Handled_Exc), Frame)
                     then
                        State.Detected  := True;
                        State.Diagnosis := 3;
                        State.Diag_Params := Enter_String
                          ("%1%" & Element_Span (Handled_Exc).First_Line'Img);
                        exit;
                     end if;
                  end loop;
               end;
            else
               Raised_Exc :=
                 Enclosing_Element (Get_Name_Definition (Raised_Exc));
               if Is_Equal
                    (Enclosing_Element (Raised_Exc), Frame)
               then
                  State.Detected  := True;
                  State.Diagnosis := 3;
                  State.Diag_Params := Enter_String
                    ("%1%" & Element_Span (Raised_Exc).First_Line'Img);
               end if;
            end if;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   ------------------------------------------------
   -- XML_Rule_Help_Tip (Non_Visible_Exceptions) --
   ------------------------------------------------
   procedure XML_Rule_Help_Tip
     (Rule  : Non_Visible_Exceptions_Rule_Type;
      Level : Natural)
   is
      pragma Unreferenced (Rule);
   begin
      Info_No_EOL (Level * Ident_String & "<tip>");
      Info ("Flag constructs leading to the possibility of propagating an");
      Info ("exception out of the scope in which the exception is declared.");
      Info ("Two cases are detected:");
      Info ("* An exception declaration in a subprogram body, task body");
      Info ("or block statement is flagged if the body or statement does not");
      Info ("contain a handler for that exception or a handler with an ");
      Info ("others choice.");
      Info ("* A raise statement in an exception handler of a subprogram");
      Info ("body, task body or block statement is flagged if it (re)raises");
      Info ("a locally declared exception. This may occur under the");
      Info ("following circumstances:");
      Info (" - it explicitly raises a locally declared exception, or");
      Info (" - it does not specify an exception name (i.e., it is simply");
      Info ("raise;) and the enclosing handler contains a locally declared");
      Info ("exception in its exception choices.");
      Info ("Renamings of local exceptions are not flagged.</tip>");
   end XML_Rule_Help_Tip;
   ----------------------
   -- Numeric_Literals --
   ----------------------
   --------------------------------------
   -- Annotate_Rule (Numeric_Literals) --
   --------------------------------------
   overriding function Annotate_Rule
     (Rule : Numeric_Literals_Rule_Type;
      Var  : Diagnosis_Variant := 0)
      return String
   is
      pragma Unreferenced (Var);
      Result : String_Access;
      Tmp    : String_Access;
      Is_First_Par : Boolean := True;
   begin
      if not Gnatcheck.Options.Mapping_Mode then
         return "";
      end if;
      Result := new String'(" [" & Rule_Name (Rule));
      case Rule.Up_To is
         when -1 =>
            Tmp := new String'(Result.all);
            Free (Result);
            Result := new String'(Tmp.all & ":All");
            Is_First_Par := False;
         when 1 =>
            null;
         when others =>
            Tmp := new String'(Result.all);
            Free (Result);
            Result := new String'(Tmp.all & ":" & Image (Rule.Up_To));
            Is_First_Par := False;
      end case;
      Free (Tmp);
      if Rule.Statements_Only then
         Tmp := new String'(Result.all);
         Free (Result);
         Result := new String'(
           Tmp.all &
           (if Is_First_Par then ':' else ',') &
           "Statements_Only");
         Free (Tmp);
      end if;
      declare
         Final_Res : constant String := Result.all & "]";
      begin
         Free (Result);
         return Final_Res;
      end;
   end Annotate_Rule;
   ----------------------------------
   -- Init_Rule (Numeric_Literals) --
   ----------------------------------
   procedure Init_Rule (Rule : in out Numeric_Literals_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Numeric_Literals");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("numeric literals");
      Rule.Diagnosis   := new String'("numeric literal (%1%) outside a "
                                    & "constant declaration");
   end Init_Rule;
   -----------------------------------------------
   -- Process_Rule_Parameter (Numeric_Literals) --
   -----------------------------------------------
   procedure Process_Rule_Parameter
     (Rule    : in out Numeric_Literals_Rule_Type;
      Param   :        String;
      Enable  :        Boolean)
   is
   begin
      if Param = "" then
         if Enable then
            Rule.Rule_State := Enabled;
         else
            Rule.Rule_State := Disabled;
            --  Restore defaults:
            Rule.Up_To           := 1;
            Rule.Statements_Only := False;
         end if;
         return;
      end if;
      if Enable then
         Rule.Rule_State := Enabled;
         if To_Lower (Param) = "all" then
            Rule.Up_To := -1;
         elsif To_Lower (Param) = "statements_only" then
            Rule.Statements_Only := True;
         else
            begin
               Rule.Up_To := Natural'Value (Param);
            exception
               when Constraint_Error =>
                  Error ("(" & Rule.Name.all & ") wrong parameter: " & Param);
            end;
         end if;
      else
         Error ("(" & Rule.Name.all & ") no parameter allowed for -R");
      end if;
   end Process_Rule_Parameter;
   ------------------------------------------
   -- Rule_Check_Pre_Op (Numeric_Literals) --
   ------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Numeric_Literals_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Control);
      pragma Unmodified  (Rule);
      Arg_Kind : constant Expression_Kinds := Expression_Kind (Element);
      Integer_Literal_Value : Natural;
   begin
      if Arg_Kind in An_Integer_Literal .. A_Real_Literal then
         if Arg_Kind = An_Integer_Literal then
            begin
               Integer_Literal_Value :=
                 Natural'Value (To_String (Value_Image (Element)));
            exception
               when Constraint_Error =>
                  --  The value is definitely too big to be an exception for
                  --  this rule!
                  return;
            end;
         end if;
         declare
            Encl_El     : Asis.Element := Get_Enclosing_Element;
            Old_Encl_El : Asis.Element := Element;
            Step_Up     : Elmt_Idx     := 0;
         begin
            if Arg_Kind = An_Integer_Literal
              and then
               Integer_Literal_Value <= Rule.Up_To
            then
               if Expression_Kind (Encl_El) = An_Indexed_Component then
                  State.Detected := True;
               end if;
            else
               while Element_Kind (Encl_El) = An_Expression
                   or else
                     Path_Kind (Encl_El) in
                       A_Case_Expression_Path .. An_Else_Expression_Path
                   or else
                     (Element_Kind (Encl_El) = An_Association
                     and then
                      Association_Kind (Encl_El) /=
                        An_Array_Component_Association)
                   or else
                      (Association_Kind (Encl_El) =
                        An_Array_Component_Association
                      and then
                        Is_Equal (Old_Encl_El, Component_Expression (Encl_El)))
                   or else
                     (Definition_Kind (Encl_El) = A_Discrete_Subtype_Definition
                    and then
                      Declaration_Kind (Get_Enclosing_Element (Step_Up + 1)) =
                        A_Loop_Parameter_Specification)
               loop
                  Step_Up     := Step_Up + 1;
                  Old_Encl_El := Encl_El;
                  Encl_El     := Get_Enclosing_Element (Step_Up);
               end loop;
               if not (Declaration_Kind (Encl_El) = A_Constant_Declaration
                     or else
                      Declaration_Kind (Encl_El) in
                        An_Integer_Number_Declaration ..
                        A_Real_Number_Declaration
                     or else
                      Clause_Kind (Encl_El)  in
                        A_Representation_Clause | A_Component_Clause
                     or else
                      Definition_Kind (Encl_El) = An_Aspect_Specification
                     or else
                      (Discrete_Range_Kind (Encl_El) =
                         A_Discrete_Simple_Expression_Range
                      and then
                       Clause_Kind (Get_Enclosing_Element (Step_Up + 1)) =
                         A_Component_Clause))
               then
                  if Rule.Statements_Only then
                     State.Detected :=
                       Element_Kind (Encl_El) in A_Statement .. A_Path
                         or else
                       Declaration_Kind (Encl_El) =
                         A_Loop_Parameter_Specification;
                  else
                     State.Detected := True;
                  end if;
               end if;
            end if;
         end;
         if State.Detected then
            State.Diag_Params := Enter_String ("%1%" &
              To_String (Value_Image (Element)));
         end if;
      end if;
   end Rule_Check_Pre_Op;
   -------------------------------------------------
   -- XML_Rule_Parameters_Help (Numeric_Literals) --
   -------------------------------------------------
   procedure XML_Rule_Help
     (Rule  : Numeric_Literals_Rule_Type;
      Level : Natural)
   is
   begin
--      Info (Level * Ident_String              &
--            "<check switch=""+R"              &
--            Rule.Name.all                     &
--            ":ALL"                            &
--            """ label="""                     &
--            "all integer literals"""          &
--            "/>");
      Info (Level * Ident_String               &
            "<field switch=""+R"               &
            Rule.Name.all                      &
            """ separator="":"""               &
            " label="""                        &
            "Checks that no numeric literal "  &
            "is greater than the entered "     &
            "number, or set ALL to check all " &
            "numeric literals"""               &
            "/>");
      Info (Level * Ident_String               &
            "<check switch=""+R"               &
            Rule.Name.all                      &
            ":Statements_Only"                 &
            """ label="""                      &
            "check numeric literals "          &
            "on statements only"""             &
            "/>");
--      Info (Level * Ident_String              &
--            "<spin switch=""+R"               &
--            Rule.Name.all                     &
--            """ label="""                     &
--            "integer literals greater than"   &
--            """ min=""1"                      &
--            """ max=""99999"""                &
--            " default=""0"                    &
--            """ separator="":"""              &
--            "/>");
   end XML_Rule_Help;
   --------------------------
   -- OTHERS_In_Aggregates --
   --------------------------
   --------------------------------------
   -- Init_Rule (OTHERS_In_Aggregates) --
   --------------------------------------
   procedure Init_Rule (Rule : in out OTHERS_In_Aggregates_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("OTHERS_In_Aggregates");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("OTHERS choices in aggregates");
      Rule.Diagnosis   := new String'("OTHERS choice in aggregate");
   end Init_Rule;
   ----------------------------------------------
   -- Rule_Check_Pre_Op (OTHERS_In_Aggregates) --
   ----------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out OTHERS_In_Aggregates_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Aggregate : Asis.Element;
   begin
      if Definition_Kind (Element) = An_Others_Choice then
         Aggregate := Get_Enclosing_Element (Steps_Up => 1);
         case Expression_Kind (Aggregate) is
            when An_Extension_Aggregate =>
               State.Detected := True;
            when A_Record_Aggregate           |
                 A_Positional_Array_Aggregate |
                 A_Named_Array_Aggregate      =>
               declare
                  Associations : constant Asis.Element_List :=
                    Get_Associations (Aggregate);
               begin
                  if Associations'Length >= 3 then
                     State.Detected := True;
                  elsif Associations'Length = 2 then
                     declare
                        Choices : constant Asis.Element_List :=
                          Get_Choices (Associations (Associations'First));
                     begin
                        if Choices'Length >= 2 then
                           State.Detected := True;
                        elsif Choices'Length = 1 then
                           if Definition_Kind (Choices (Choices'First)) =
                             A_Discrete_Range
                           then
                              State.Detected := True;
                           end if;
                        end if;
                     end;
                  end if;
               end;
            when others =>
               null;
         end case;
      end if;
   end Rule_Check_Pre_Op;
   -------------------------------
   -- OTHERS_In_CASE_Statements --
   -------------------------------
   -------------------------------------------
   -- Init_Rule (OTHERS_In_CASE_Statements) --
   -------------------------------------------
   procedure Init_Rule (Rule : in out OTHERS_In_CASE_Statements_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("OTHERS_In_CASE_Statements");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("OTHERS choices in case statements");
      Rule.Diagnosis   := new String'("OTHERS choice in case statement");
   end Init_Rule;
   ---------------------------------------------------
   -- Rule_Check_Pre_Op (OTHERS_In_CASE_Statements) --
   ---------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out OTHERS_In_CASE_Statements_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Definition_Kind (Element) = An_Others_Choice
       and then
         Path_Kind (Get_Enclosing_Element) = A_Case_Path
      then
         State.Detected := True;
      end if;
   end Rule_Check_Pre_Op;
   ----------------------------------
   -- OTHERS_In_Exception_Handlers --
   ----------------------------------
   ----------------------------------------------
   -- Init_Rule (OTHERS_In_Exception_Handlers) --
   ----------------------------------------------
   procedure Init_Rule
     (Rule : in out OTHERS_In_Exception_Handlers_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("OTHERS_In_Exception_Handlers");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("OTHERS choices in exception handlers");
      Rule.Diagnosis   := new String'("OTHERS choice in exception handler");
   end Init_Rule;
   ------------------------------------------------------
   -- Rule_Check_Pre_Op (OTHERS_In_Exception_Handlers) --
   ------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out OTHERS_In_Exception_Handlers_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Definition_Kind (Element) = An_Others_Choice
       and then
         Element_Kind (Get_Enclosing_Element) = An_Exception_Handler
      then
         State.Detected := True;
      end if;
   end Rule_Check_Pre_Op;
   --------------------------------------
   -- Overly_Nested_Control_Structures --
   --------------------------------------
   --------------------------------------------------
   -- Init_Rule (Overly_Nested_Control_Structures) --
   --------------------------------------------------
   procedure Init_Rule
     (Rule : in out Overly_Nested_Control_Structures_Rule_Type)
   is
   begin
      Init_Rule (One_Integer_Parameter_Rule_Template (Rule));
      Rule.Name        := new String'("Overly_Nested_Control_Structures");
      Rule.Synonym     := new String'("Control_Structure_Nesting");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("deep nesting level of " &
                                      "control structures");
      Rule.Diagnosis   := new String'("nesting level of control structures " &
                                      "too deep");
   end Init_Rule;
   ----------------------------------------------------------
   -- Rule_Check_Pre_Op (Overly_Nested_Control_Structures) --
   ----------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Overly_Nested_Control_Structures_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Control);
      pragma Unmodified  (Rule);
      Nesting_Level : Natural  := 0;
      Step_Up       : Elmt_Idx := 0;
      Encl_El       : Asis.Element;
   begin
      if Is_Control_Structure (Element) then
         Encl_El := Get_Enclosing_Element (Step_Up);
         while Element_Kind (Encl_El) in A_Statement .. A_Path loop
            if Is_Control_Structure (Encl_El) then
               Nesting_Level := Nesting_Level + 1;
               if Nesting_Level > Rule.Rule_Limit then
                  State.Detected := True;
                  exit;
               end if;
            end if;
            Step_Up := Step_Up + 1;
            Encl_El := Get_Enclosing_Element (Step_Up);
         end loop;
      end if;
   end Rule_Check_Pre_Op;
   -----------------------------
   -- Parameters_Out_Of_Order --
   -----------------------------
   -----------------------------------------
   -- Init_Rule (Parameters_Out_Of_Order) --
   -----------------------------------------
   procedure Init_Rule (Rule : in out Parameters_Out_Of_Order_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Parameters_Out_Of_Order");
      Rule.Synonym     := new String'("Parameter_Mode_Ordering");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("formal parameters ordering");
      Rule.Diagnosis   := new String'(
        "#1#parameter %1% of mode %2% precedes parameter %3% of mode %4%"  &
        "#2#parameter %1% with default initialization precedes " &
        "parameter %2% without it");
   end Init_Rule;
   -------------------------------------------------
   -- Rule_Check_Pre_Op (Parameters_Out_Of_Order) --
   -------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Parameters_Out_Of_Order_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Arg_Kind      : constant Declaration_Kinds := Declaration_Kind (Element);
      Check_Profile : Boolean := False;
   begin
      case Arg_Kind is
         when A_Procedure_Declaration         |
              A_Function_Declaration          |
              A_Null_Procedure_Declaration    |
              An_Entry_Declaration            |
              A_Generic_Procedure_Declaration |
              A_Generic_Function_Declaration  |
              A_Formal_Procedure_Declaration  |
              A_Formal_Function_Declaration   =>
            Check_Profile := True;
         when A_Procedure_Body_Declaration |
              A_Function_Body_Declaration  |
              A_Procedure_Body_Stub        |
              A_Function_Body_Stub         =>
            Check_Profile := Acts_As_Spec (Element);
         when others =>
            null;
      end case;
      if Check_Profile then
         declare
            Params : constant Asis.Element_List := Parameter_Profile (Element);
            Prev_Mode : Mode_Kinds;
            Succ_Mode : Mode_Kinds;
            Prev_Name : Asis.Element;
            Succ_Name : Asis.Element;
            Prev_Par_Has_Default_Expr : Boolean;
         begin
            if Params'Length > 1 then
               Prev_Mode := Mode_Kind (Params (Params'First));
               Prev_Par_Has_Default_Expr :=
                 not Is_Nil
                   (Initialization_Expression (Params (Params'First)));
               for J in Params'First + 1 .. Params'Last loop
                  --  First, check if the mode ordering is right, that is
                  --  IN -> IN OUT -> OUT
                  --  This check does not make sense for functions:
                  if not (Arg_Kind = A_Function_Declaration
                       or else
                          Arg_Kind = A_Generic_Function_Declaration
                       or else
                          Arg_Kind = A_Formal_Function_Declaration
                       or else
                          Arg_Kind = A_Function_Body_Stub)
                  then
                     Succ_Mode := Mode_Kind (Params (J));
                     case Prev_Mode is
                        when An_In_Out_Mode =>
                           --  IN OUT -> IN is a violation:
                           if Succ_Mode in A_Default_In_Mode .. An_In_Mode then
                              Prev_Name := First_Name (Params (J - 1));
                              Succ_Name := First_Name (Params (J));
                              State.Detected    := True;
                              State.Diagnosis   := 1;
                              State.Diag_Params := Enter_String (
                                "%1%"                                       &
                                To_String (Defining_Name_Image (Prev_Name)) &
                                "%2%" & "IN OUT"                            &
                                "%3%"                                       &
                                To_String (Defining_Name_Image (Succ_Name)) &
                                "%4%" & "IN");
                              exit;
                           end if;
                        when An_Out_Mode =>
                           if Succ_Mode in A_Default_In_Mode .. An_In_Mode then
                              --  OUT -> IN is a violation:
                              Prev_Name := First_Name (Params (J - 1));
                              Succ_Name := First_Name (Params (J));
                              State.Detected    := True;
                              State.Diagnosis   := 1;
                              State.Diag_Params := Enter_String (
                                "%1%"                                       &
                                To_String (Defining_Name_Image (Prev_Name)) &
                                "%2%" & "OUT"                               &
                                "%3%"                                       &
                                To_String (Defining_Name_Image (Succ_Name)) &
                                "%4%" & "IN");
                              exit;
                           elsif Succ_Mode = An_In_Out_Mode then
                              --  OUT -> IN OUT is a violation:
                              Prev_Name := First_Name (Params (J - 1));
                              Succ_Name := First_Name (Params (J));
                              State.Detected    := True;
                              State.Diagnosis   := 1;
                              State.Diag_Params := Enter_String (
                                "%1%"                                       &
                                To_String (Defining_Name_Image (Prev_Name)) &
                                "%2%" & "OUT"                               &
                                "%3%"                                       &
                                To_String (Defining_Name_Image (Succ_Name)) &
                                "%4%" & "IN OUT");
                              exit;
                           end if;
                        when A_Default_In_Mode .. An_In_Mode =>
                           --  Any mode can follow IN mode
                           null;
                        when others =>
                           pragma Assert (False);
                           null;
                     end case;
                  end if;
                  --  Now check that IN parameters with default initialization
                  --  go last in the group of IN parameters:
                  if Succ_Mode in A_Default_In_Mode .. An_In_Mode
                    and then
                     Prev_Mode in A_Default_In_Mode .. An_In_Mode
                  then
                     if Prev_Par_Has_Default_Expr then
                        if Is_Nil (Initialization_Expression (Params (J))) then
                           Prev_Name := First_Name (Params (J - 1));
                           Succ_Name := First_Name (Params (J));
                           State.Detected    := True;
                           State.Diagnosis   := 2;
                           State.Diag_Params := Enter_String (
                             "%1%"                                       &
                             To_String (Defining_Name_Image (Prev_Name)) &
                             "%2%"                                       &
                             To_String (Defining_Name_Image (Succ_Name)));
                           exit;
                        end if;
                     else
                        Prev_Par_Has_Default_Expr :=
                          not Is_Nil (Initialization_Expression (Params (J)));
                     end if;
                  end if;
                  Prev_Mode := Succ_Mode;
               end loop;
            end if;
         end;
      end if;
   end Rule_Check_Pre_Op;
   ---------------------------------------------------------
   -- Positional_Actuals_For_Defaulted_Generic_Parameters --
   ---------------------------------------------------------
   ---------------------------------------------------------------------
   -- Init_Rule (Positional_Actuals_For_Defaulted_Generic_Parameters) --
   ---------------------------------------------------------------------
   procedure Init_Rule (Rule : in out
     Positional_Actuals_For_Defaulted_Generic_Parameters_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        :=
        new String'("Positional_Actuals_For_Defaulted_Generic_Parameters");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("positional generic actuals for " &
                                      "defaulted generic parameters");
      Rule.Diagnosis   := new String'("use named notation when passing " &
        "actual to defaulted generic parameter");
   end Init_Rule;
   ----------------------------------------------------------------------------
   -- Rule_Check_Pre_Op(Positional_Actuals_For_Defaulted_Generic_Parameters) --
   ----------------------------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out
        Positional_Actuals_For_Defaulted_Generic_Parameters_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Gen_Decl : Asis.Element;
   begin
      if Association_Kind (Element) = A_Generic_Association
        and then
         Is_Nil (Formal_Parameter (Element))
      then
         --  Compute the corresponding generic declaration.
         Gen_Decl := Generic_Unit_Name (Get_Enclosing_Element);
         Gen_Decl := Normalize_Reference (Gen_Decl);
         Gen_Decl := Corresponding_Name_Declaration (Gen_Decl);
         if Declaration_Kind (Gen_Decl) in
           A_Generic_Package_Renaming_Declaration ..
             A_Generic_Function_Renaming_Declaration
         then
            Gen_Decl := Corresponding_Base_Entity (Gen_Decl);
            Gen_Decl := Normalize_Reference (Gen_Decl);
            Gen_Decl := Corresponding_Name_Declaration (Gen_Decl);
         end if;
         declare
            Formal_Params : constant Asis.Element_List :=
              Generic_Formal_Part (Gen_Decl);
            Actuals : constant Asis.Element_List :=
              Generic_Actual_Part (Get_Enclosing_Element);
            Move_Act  : Natural  := 0;
            Move_Form : Natural  := 0;
            Form_Idx  : Natural  := 0;
         begin
            for J in Actuals'Range loop
               if Is_Equal (Actuals (J), Element) then
                  exit;
               end if;
               Move_Act := Move_Act + 1;
            end loop;
            --  Now Move_Act gives us a number of the actual parameter in
            --  question in the call minus 1. This parameter is in positional
            --  association, so we have to count to the corresponding generic
            --  formal. The problem here is that we can have more than one
            --  formal parameter declared in one parameter specification.
            for J in Formal_Params'Range loop
               if Element_Kind (Formal_Params (J)) /= A_Clause then
                  Move_Form := Move_Form + Names (Formal_Params (J))'Length;
                  if Move_Form > Move_Act then
                     Form_Idx := J;
                     exit;
                  end if;
               end if;
            end loop;
            case Declaration_Kind (Formal_Params (Form_Idx)) is
               when A_Formal_Object_Declaration =>
                  State.Detected :=
                    not Is_Nil (Initialization_Expression
                      (Formal_Params (Form_Idx)));
               when A_Formal_Procedure_Declaration |
                    A_Formal_Function_Declaration =>
                  State.Detected :=
                    Default_Kind (Formal_Params (Form_Idx)) /= A_Nil_Default;
               when others =>
                  null;
            end case;
         end;
      end if;
   end Rule_Check_Pre_Op;
   -------------------------------------------------
   -- Positional_Actuals_For_Defaulted_Parameters --
   -------------------------------------------------
   -------------------------------------------------------------
   -- Init_Rule (Positional_Actuals_For_Defaulted_Parameters) --
   -------------------------------------------------------------
   procedure Init_Rule
     (Rule : in out Positional_Actuals_For_Defaulted_Parameters_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        :=
        new String'("Positional_Actuals_For_Defaulted_Parameters");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("positional actuals for " &
                                      "defaulted parameters");
      Rule.Diagnosis   := new String'("use named notation when passing " &
        "actual to defaulted parameter");
   end Init_Rule;
   ---------------------------------------------------------------------
   -- Rule_Check_Pre_Op (Positional_Actuals_For_Defaulted_Parameters) --
   ---------------------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Positional_Actuals_For_Defaulted_Parameters_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Association_Kind (Element) = A_Parameter_Association
        and then
         Is_Nil (Formal_Parameter (Element))
        and then
         not Is_Call_To_Operator_Function (Get_Enclosing_Element)
        and then
         not Is_Call_To_Attribute_Subprogram (Get_Enclosing_Element)
      then
         if not Is_Nil (Initialization_Expression
                          (Get_Parameter_Declaration (Element)))
         then
            State.Detected := True;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   ---------------------------
   -- Positional_Components --
   ---------------------------
   ---------------------------------------
   -- Init_Rule (Positional_Components) --
   ---------------------------------------
   procedure Init_Rule
     (Rule : in out Positional_Components_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Positional_Components");
      Rule.Synonym     := new String'("Positional_Component_Associations");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("positional components associations " &
                                     "in aggregates");
      Rule.Diagnosis   := new String'("aggregate with a positional " &
                                     "component association");
   end Init_Rule;
   -----------------------------------------------
   -- Rule_Check_Pre_Op (Positional_Components) --
   -----------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Positional_Components_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      case Expression_Kind (Element) is
         when A_Record_Aggregate      |
              An_Extension_Aggregate  =>
            State.Detected := Has_Positional_Association (Element);
         when  A_Positional_Array_Aggregate =>
            State.Detected := True;
         when others =>
            null;
      end case;
   end Rule_Check_Pre_Op;
   -----------------------------------
   -- Positional_Generic_Parameters --
   -----------------------------------
   -----------------------------------------------
   -- Init_Rule (Positional_Generic_Parameters) --
   -----------------------------------------------
   procedure Init_Rule
     (Rule : in out Positional_Generic_Parameters_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Positional_Generic_Parameters");
      Rule.Synonym     := new String'("Positional_Generic_Associations");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("positional generic associations");
      Rule.Diagnosis   := new String'("positional generic association");
   end Init_Rule;
   -------------------------------------------------------
   -- Rule_Check_Pre_Op (Positional_Generic_Parameters) --
   -------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Positional_Generic_Parameters_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Association_Kind (Element) = A_Generic_Association
        and then
         Is_Nil (Formal_Parameter (Element))
      then
         if not Has_One_Parameter (Get_Enclosing_Element) then
            State.Detected := True;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   ---------------------------
   -- Positional_Parameters --
   ---------------------------
   ---------------------------------------------------------
   -- Activate_In_Test_Mode (Unconstrained_Array_Returns) --
   ---------------------------------------------------------
   overriding procedure Activate_In_Test_Mode
     (Rule : in out Positional_Parameters_Rule_Type)
   is
   begin
      Process_Rule_Parameter
        (Rule   => Rule,
         Param  => "All",
         Enable => True);
   end Activate_In_Test_Mode;
   --------------------------------------------------
   -- Exception_Name (Unconstrained_Array_Returns) --
   --------------------------------------------------
   function Exception_Name
     (Rule      : Positional_Parameters_Rule_Type;
      Exc_Index : Exception_Index)
      return      String
   is
      pragma Unreferenced (Rule);
   begin
      case Exc_Index is
         when 1 =>
            return "All";
         when others =>
            return "";
      end case;
   end Exception_Name;
   ----------------------------------------------------
   -- Exception_Number (Unconstrained_Array_Returns) --
   ----------------------------------------------------
   function Exception_Number
     (Rule     : Positional_Parameters_Rule_Type;
      Exc_Name : String)
      return     Exception_Numbers
   is
      pragma Unreferenced (Rule);
      Result : Exception_Numbers := Not_An_Exception;
      Normalized_Exc_Name : constant String := To_Lower (Exc_Name);
   begin
      if Normalized_Exc_Name = "all" then
         Result := 1;
      end if;
      return Result;
   end Exception_Number;
   ---------------------------------------
   -- Init_Rule (Positional_Parameters) --
   ---------------------------------------
   overriding procedure Init_Rule
     (Rule : in out Positional_Parameters_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Positional_Parameters");
      Rule.Synonym     := new String'("Positional_Parameter_Associations");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("positional associations in " &
                                      "subprogram and entry calls");
      Rule.Diagnosis   := new String'("positional parameter association");
   end Init_Rule;
   -----------------------------------------------
   -- Rule_Check_Pre_Op (Positional_Parameters) --
   -----------------------------------------------
   overriding procedure Rule_Check_Pre_Op
     (Rule    : in out Positional_Parameters_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Control);
   begin
      if Association_Kind (Element) = A_Parameter_Association
        and then
         Is_Nil (Formal_Parameter (Element))
      then
         --  Now - check for exceptions:
         if not (
           --  unconditional exceptions
           Is_Call_To_Operator_Function (Get_Enclosing_Element)
           or else
             Is_Call_To_Attribute_Subprogram (Get_Enclosing_Element)
           --  exceptions that depends on parameter value
           or else
             (not Rule.Exceptions (1)
             and then
              Has_One_Parameter (Get_Enclosing_Element))
           or else
            (Is_Prefix_Notation (Get_Enclosing_Element)
            and then
             Is_Prefix_Notation_Exception (Element, not Rule.Exceptions (1))))
         then
            State.Detected := True;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   -----------------------------------
   -- Predefined_Numeric_Types_Rule --
   -----------------------------------
   -----------------------------------------
   -- Init_Rule (Predefined_Numeric_Types --
   -----------------------------------------
   procedure Init_Rule (Rule : in out Predefined_Numeric_Types_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Predefined_Numeric_Types");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("explicit references to predefined " &
                                      "numeric subtypes");
      Rule.Diagnosis   := new String'("explicit reference to predefined " &
                                      "numeric subtype");
   end Init_Rule;
   -------------------------------------------------
   -- Rule_Check_Pre_Op (Predefined_Numeric_Types --
   -------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Predefined_Numeric_Types_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Expression_Kind (Element) = An_Identifier
        and then
         Is_Ref_To_Standard_Num_Subtype (Element)
      then
         State.Detected := True;
      end if;
   end Rule_Check_Pre_Op;
   ---------------------------------
   -- Raising_External_Exceptions --
   ---------------------------------
   ---------------------------------------------
   -- Init_Rule (Raising_External_Exceptions) --
   ---------------------------------------------
   procedure Init_Rule (Rule : in out Raising_External_Exceptions_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Raising_External_Exceptions");
      Rule.Synonym     := new String'("Visible_Exceptions");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("visibility of exceptions raised by " &
                                      "routines declared in library package");
      Rule.Diagnosis   := new String'("raised exception is not declared in " &
                                      "visible part of enclosing library " &
                                      "package");
   end Init_Rule;
   -----------------------------------------------------
   -- Rule_Check_Pre_Op (Raising_External_Exceptions) --
   -----------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Raising_External_Exceptions_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Raised_Exc : Asis.Element;
      Encl_CU    : Asis.Compilation_Unit :=
        Enclosing_Compilation_Unit (Element);
   begin
      if Statement_Kind (Element) = A_Raise_Statement
        and then
         (Unit_Kind (Encl_CU) = A_Package
         or else
          Unit_Kind (Encl_CU) = A_Generic_Package
         or else
          Unit_Kind (Encl_CU) = A_Package_Body)
      then
         Raised_Exc := Raised_Exception (Element);
         if not Is_Nil (Raised_Exc) then
            Raised_Exc := Normalize_Reference (Raised_Exc);
            Raised_Exc := Corresponding_Name_Definition (Raised_Exc);
            --  Note, that we do not unwind renamings, that is, if Raised_Exc
            --  is a renaming of a Standard exception that takes place in
            --  another package, we consider this as a rule violation.
            if not Is_From_Standard (Raised_Exc) then
               if Unit_Kind (Encl_CU) = A_Package_Body then
                  Encl_CU := Corresponding_Declaration (Encl_CU);
                  if not Is_Equal (Enclosing_Compilation_Unit (Raised_Exc),
                                   Encl_CU)
                  then
                     State.Detected := True;
                  else
                     State.Detected := not Is_Public (Raised_Exc);
                  end if;
               end if;
            end if;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   -----------------------------------
   -- Raising_Predefined_Exceptions --
   -----------------------------------
   ---------------------------------------
   -- Init_Rule (Raising_Predefined_Exceptions) --
   ---------------------------------------
   procedure Init_Rule (Rule : in out Raising_Predefined_Exceptions_Rule_Type)
   is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Raising_Predefined_Exceptions");
      Rule.Synonym     := new String'("Predefined_Exceptions");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("explicit raise of predefined " &
                                      "exceptions");
      Rule.Diagnosis   := new String'("explicit raise of a predefined " &
                                      "exception");
   end Init_Rule;
   -------------------------------------------------------
   -- Rule_Check_Pre_Op (Raising_Predefined_Exceptions) --
   -------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Raising_Predefined_Exceptions_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Raised_Exc : Asis.Element;
   begin
      if Statement_Kind (Element) = A_Raise_Statement then
         Raised_Exc := Raised_Exception (Element);
         if not Is_Nil (Raised_Exc) then
            Raised_Exc := Normalize_Reference (Raised_Exc);
            Raised_Exc := Corresponding_Name_Declaration (Raised_Exc);
            if Declaration_Kind (Raised_Exc) =
               An_Exception_Renaming_Declaration
            then
               Raised_Exc := Corresponding_Base_Entity (Raised_Exc);
               Raised_Exc := Normalize_Reference (Raised_Exc);
               Raised_Exc := Corresponding_Name_Declaration (Raised_Exc);
            end if;
            State.Detected := Is_From_Standard (Raised_Exc);
         end if;
      end if;
   end Rule_Check_Pre_Op;
   -------------------------------
   -- Unassigned_OUT_Parameters --
   -------------------------------
   --------------------------------------------------------
   -- Data structures and local subprograms for the rule --
   --------------------------------------------------------
   type Formal_Parameter_Record is record
      Par_Def_Name : Asis.Element;
      --  Defining name of the parameter
      Assigned : Boolean := False;
      --  Flag indicating if this parameter has got a value.
   end record;
   package OUT_Parameters_Table is new Table.Table
     (Table_Component_Type => Formal_Parameter_Record,
      Table_Index_Type     => Natural,
      Table_Low_Bound      =>  1,
      Table_Initial        => 20,
      Table_Increment      => 50,
      Table_Name           => "OUT parameters");
   procedure Set_OUT_Parameters (El : Asis.Element);
   --  Supposing that El is a procedure body declaration, sets in
   --  OUT_Parameters_Table the list of OUT parameters of this procedure
   function Get_Bad_Parameter_List return String_Loc;
   --  Forms from the content of OUT_Parameters_Table the list of the bad
   --  parameter names to be placed in the diagnosis and returns the
   --  corresponding pointer in the string table.
   Check_Handler : Boolean;
   --  We need this global flag to decide if we have to traverse exceptions
   --  handlers.
   First_Body : Boolean;
   --  We need this flag to make the difference between the procedure body
   --  declaration from which the traversal starts (we have to analyze it), and
   --  all the other declarations, that should be skipped during the traversal
   procedure Check_Reference
     (Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Natural);
   --  Checks if the argument is a reference to OUT parameter that sets its
   --  value. If such a reference is detected, updates parameter records in
   --  OUT_Parameters_Table. Decreases State each time when detects that one
   --  more OUT parameter gets a value. terminate the traversal when all the
   --  parameters have got values (State gets the value 0)
   procedure No_Opeation
     (Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Natural);
   --  Does nothing.
   procedure Check_References is new Asis.Iterator.Traverse_Element
     (Pre_Operation     => Check_Reference,
      Post_Operation    => No_Opeation,
      State_Information => Natural);
   -------------------------------------------------
   -- Check_Reference (Unassigned_OUT_Parameters) --
   -------------------------------------------------
   procedure Check_Reference
     (Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Natural)
   is
      Tmp_El        : Asis.Element;
      Old_Enclosing : Asis.Element;
      Par_Idx       : Natural;
   begin
      --  If we are here, State cannot be 0, so we have to do the job,,,
      case Flat_Element_Kind (Element) is
         when Flat_Declaration_Kinds =>
            if First_Body then
               First_Body := False;
            else
               Control := Abandon_Children;
            end if;
         when An_Exception_Handler =>
            if Declaration_Kind (Enclosing_Element (Element)) =
                 A_Procedure_Body_Declaration
              and then
                 Check_Handler
            then
               --  If we are here, the only possibility is that we are checking
               --  an exception handler from some procedure body.
               null;
            else
               --  If we are here, we are in some "inner" exception handler
               --  (note, that we skip all the declaration except the procedure
               --  body declaration for which the traversing is started). We
               --  just skip it)
               Control := Abandon_Children;
            end if;
         when An_Identifier =>
            Tmp_El := Get_Corresponding_Definition (Element);
            if Defining_Name_Kind (Tmp_El) = A_Defining_Identifier then
               Tmp_El := Corresponding_Body_Parameter_Definition (Tmp_El);
            end if;
            if Defining_Name_Kind (Tmp_El) = A_Defining_Identifier then
               Par_Idx := 0;
               for J in 1 .. OUT_Parameters_Table.Last loop
                  if Is_Equal
                       (Tmp_El, OUT_Parameters_Table.Table (J).Par_Def_Name)
                  then
                     Par_Idx := J;
                     exit;
                  end if;
               end loop;
               if Par_Idx > 0
                 and then
                  not OUT_Parameters_Table.Table (Par_Idx).Assigned
               then
                  --  And now we have to check if Element is in a position that
                  --  can result in assigning a value to the corresponding OUT
                  --  parameter
                  Old_Enclosing := Element;
                  Tmp_El        := Enclosing_Element (Old_Enclosing);
                  while Element_Kind (Tmp_El) = An_Expression loop
                     if (Expression_Kind (Tmp_El) = An_Indexed_Component
                       and then
                        not Is_Equal (Old_Enclosing, Prefix (Tmp_El)))
                      or else
                        (Expression_Kind (Tmp_El) = An_Explicit_Dereference
                       and then
                         Is_Equal (Old_Enclosing, Prefix (Tmp_El)))
                     then
                        --  The first condition means that we have an index in
                        --  an indexed component. The second condition means
                        --  that we have a prefix of explicit dereference. In
                        --  both cases the object in question cannot get
                        --  a value
                        exit;
                     end if;
                     Old_Enclosing := Tmp_El;
                     Tmp_El        := Enclosing_Element (Old_Enclosing);
                  end loop;
                  if Statement_Kind (Tmp_El) = An_Assignment_Statement
                    and then
                      Is_Equal
                        (Old_Enclosing, Assignment_Variable_Name (Tmp_El))
                  then
                     OUT_Parameters_Table.Table (Par_Idx).Assigned := True;
                     State := State - 1;
                  elsif Association_Kind (Tmp_El) =
                        A_Parameter_Association
                  then
                     --  Here we have to check if it is an actual for OUT
                     --  or IN OUT parameter
                     --  ??? See pre-operation for
                     --  Positional_Actuals_For_Defaulted_Parameters rule -
                     --  there is definitely some duplication here!
                     Old_Enclosing := Enclosing_Element (Tmp_El);
                     if not (Expression_Kind (Old_Enclosing) =
                             A_Function_Call
                           or else
                             Is_Call_To_Attribute_Subprogram (Old_Enclosing))
                     then
                        Old_Enclosing := Get_Parameter_Declaration (Tmp_El);
                        if Mode_Kind (Old_Enclosing) in
                           An_Out_Mode .. An_In_Out_Mode
                        then
                           OUT_Parameters_Table.Table (Par_Idx).Assigned :=
                             True;
                           State := State - 1;
                        end if;
                     end if;
                  end if;
               end if;
            end if;
         when others =>
            null;
      end case;
      if State = 0 then
         Control := Terminate_Immediately;
      end if;
   end Check_Reference;
   --------------------------------------------------------
   -- Get_Bad_Parameter_List (Unassigned_OUT_Parameters) --
   --------------------------------------------------------
   function Get_Bad_Parameter_List return String_Loc is
      Str, Tmp_Str : String_Access;
      Result       : String_Loc;
   begin
      for J in 1 .. OUT_Parameters_Table.Last loop
         if not OUT_Parameters_Table.Table (J).Assigned then
            if Tmp_Str = null then
               --  first parameter to report
               Str :=
                 new String'("%1%" & To_String
                   (Defining_Name_Image
                      (OUT_Parameters_Table.Table (J).Par_Def_Name)));
            else
               Free (Str);
               Str :=
                 new String'(Tmp_Str.all & ", " & To_String
                   (Defining_Name_Image
                      (OUT_Parameters_Table.Table (J).Par_Def_Name)));
            end if;
            Free (Tmp_Str);
            Tmp_Str := new String'(Str.all);
         end if;
      end loop;
      Result := Enter_String (Str.all & "%1%");
      Free (Str);
      Free (Tmp_Str);
      return (Result);
   end Get_Bad_Parameter_List;
   -------------------------------------------
   -- Init_Rule (Unassigned_OUT_Parameters) --
   -------------------------------------------
   procedure Init_Rule (Rule : in out Unassigned_OUT_Parameters_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Unassigned_OUT_Parameters");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("OUT parameters do not get values "     &
                                      "in procedure bodies");
      Rule.Diagnosis   := new String'("#1#procedure body does not define "    &
                                         "values for OUT parameters: %1%"     &
                                      "#2#exception handler does not define " &
                                         "values for OUT parameters: %1%");
   end Init_Rule;
   ---------------------------------------------
   -- No_Opeation (Unassigned_OUT_Parameters) --
   ---------------------------------------------
   procedure No_Opeation
     (Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Natural)
   is
      pragma Unreferenced (Element, Control, State);
   begin
      null;
   end No_Opeation;
   ---------------------------------------------------
   -- Rule_Check_Pre_Op (Unassigned_OUT_Parameters) --
   ---------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Unassigned_OUT_Parameters_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Get_Params_From   : Asis.Element;
      Unassigned_Params : Natural;
      --  Unassigned_Params indicates the number of OUT parameters for that we
      --  do not know that they have got values
      Check_Ref_Control : Traverse_Control := Continue;
   begin
      if Declaration_Kind (Element) = A_Procedure_Body_Declaration
        or else
         (Element_Kind (Element) = An_Exception_Handler
          and then
            Declaration_Kind (Get_Enclosing_Element) =
            A_Procedure_Body_Declaration)
      then
         if Element_Kind (Element) = An_Exception_Handler then
            if Raises_Exception (Element) then
               return;
            end if;
            Get_Params_From := Get_Enclosing_Element;
            First_Body      := False;
            Check_Handler   := True;
         else
            Get_Params_From := Element;
            First_Body      := True;
            Check_Handler   := False;
         end if;
         OUT_Parameters_Table.Init;
         Set_OUT_Parameters (Get_Params_From);
         Unassigned_Params := OUT_Parameters_Table.Last;
         if Unassigned_Params > 0 then
            Check_References (Element, Check_Ref_Control, Unassigned_Params);
            if Unassigned_Params > 0 then
               State.Detected := True;
               if Declaration_Kind (Element) =
                    A_Procedure_Body_Declaration
               then
                  State.Diagnosis := 1;
               else
                  State.Diagnosis := 2;
               end if;
               State.Diag_Params := Get_Bad_Parameter_List;
            end if;
         end if;
      end if;
   end Rule_Check_Pre_Op;
   ----------------------------------------------------
   -- Set_OUT_Parameters (Unassigned_OUT_Parameters) --
   ----------------------------------------------------
   procedure Set_OUT_Parameters (El : Asis.Element) is
      Par_Specs : constant Asis.Element_List := Parameter_Profile (El);
   begin
      for J in Par_Specs'Range loop
         if Mode_Kind (Par_Specs (J)) = An_Out_Mode then
            declare
               Nms : constant Asis.Element_List := Names (Par_Specs (J));
            begin
               for K in Nms'Range loop
                  OUT_Parameters_Table.Append
                    ((Par_Def_Name => Nms (K),
                      Assigned     => False));
               end loop;
            end;
         end if;
      end loop;
   end Set_OUT_Parameters;
   -----------------------------------------
   -- Uncommented_BEGIN_In_Package_Bodies --
   -----------------------------------------
   -----------------------------------------------------
   -- Init_Rule (Uncommented_BEGIN_In_Package_Bodies) --
   -----------------------------------------------------
   procedure Init_Rule
     (Rule : in out Uncommented_BEGIN_In_Package_Bodies_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Uncommented_BEGIN_In_Package_Bodies");
      Rule.Synonym     := new String'("Non_Marked_BEGIN_In_Package_Body");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("BEGIN keywords in package bodies " &
                                     "non-marked with " &
                                      "comment with package name");
      Rule.Diagnosis   := new String'("#1#mark BEGIN with package name (%1%)" &
                                      "#2#place BEGIN in package body " &
                                       "on separate line");
   end Init_Rule;
   -------------------------------------------------------------
   -- Rule_Check_Pre_Op (Uncommented_BEGIN_In_Package_Bodies) --
   -------------------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Uncommented_BEGIN_In_Package_Bodies_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
   begin
      if Declaration_Kind (Element) = A_Package_Body_Declaration
       and then
         Has_Statements_And_Decls (Element)
      then
         declare
            Dcls : constant Asis.Element_List :=
              Body_Declarative_Items (Element, Include_Pragmas => True);
            Last_Dcl : constant Positive := Dcls'Last;
            Stmts : constant Asis.Element_List :=
              Body_Statements (Element, Include_Pragmas => True);
            First_Stmt : constant Positive := Stmts'First;
            LList : constant Line_List := Lines
              (Element    => Element,
               First_Line => Element_Span (Dcls (Last_Dcl)).Last_Line,
               Last_Line  => Element_Span (Stmts (First_Stmt)).First_Line);
            Begin_Line  : Line_Number_Positive;
            Begin_Start : Character_Position;
            Begin_Found : Boolean := False;
         begin
            --  First, check a most reasonable case - if we have BEGIN on a
            --  separate line between the last declaration and the first
            --  statement
            for J in LList'First + 1 .. LList'Last - 1 loop
               --  In this range, the only word the non-comment image of a
               --  line can contain is 'BEGIN'
               if To_Lower
                    (ASIS_Trim (To_String (Non_Comment_Image (LList (J))))) =
                  "begin"
               then
                  Begin_Found := True;
                  declare
                     Img : constant Program_Text :=
                       Non_Comment_Image (LList (J));
                  begin
                     Begin_Start := 1;
                     for J in Img'Range loop
                        exit when  Img (J) = 'b' or else Img (J) = 'B';
                        Begin_Start := Begin_Start + 1;
                     end loop;
                  end;
                  Begin_Line := J;
                  exit;
               end if;
            end loop;
            if Begin_Found then
               declare
                  Img : constant String :=
                    ASIS_Trim (To_String (Comment_Image (LList (Begin_Line))));
                  Firts_Idx : Natural := Img'First;
                  Last_Idx  : Natural := Img'Last;
               begin
                  if Img'Length = 0 then
                     State.Detected := True;
                  else
                     Firts_Idx := Img'First + 2;
                     while Is_White_Space (Img (Firts_Idx))
                      and then
                           Firts_Idx <= Last_Idx
                     loop
                        Firts_Idx := Firts_Idx + 1;
                     end loop;
                     for J in Firts_Idx + 1 .. Last_Idx loop
                        if Is_White_Space (Img (J)) then
                           Last_Idx := J - 1;
                           exit;
                        end if;
                     end loop;
                     State.Detected :=
                       To_Lower (Img (Firts_Idx .. Last_Idx)) /=
                       To_Lower
                         (To_String
                           (Defining_Name_Image (First_Name (Element))));
                     State.Line   := Begin_Line;
                     State.Column := Begin_Start;
                  end if;
               end;
               if State.Detected then
                  State.Diagnosis := 1;
               end if;
            else
               --  Pathological case - BEGIN in the same line as either the
               --  last declaration  or the first statement
               State.Detected  := True;
               State.Diagnosis := 2;
               State.Line      := Element_Span (Stmts (First_Stmt)).First_Line;
               State.Column    := 1;
            end if;
            if State.Detected and then State.Diagnosis = 1 then
               State.Diag_Params :=
                 Enter_String
                   ("%1%" &
                    To_String (Defining_Name_Image (First_Name (Element))));
            end if;
         end;
      end if;
   end Rule_Check_Pre_Op;
   ------------------------------
   -- Unnamed_Blocks_And_Loops --
   ------------------------------
   ------------------------------------------
   -- Init_Rule (Unnamed_Blocks_And_Loops) --
   ------------------------------------------
   procedure Init_Rule (Rule : in out Unnamed_Blocks_And_Loops_Rule_Type) is
   begin
      Init_Rule (Rule_Template (Rule));
      Rule.Name        := new String'("Unnamed_Blocks_And_Loops");
      Rule.Synonym     := new String'("Non_Named_Blocks_And_Loops");
      Rule.Rule_Status := Fully_Implemented;
      Rule.Help_Info   := new String'("compound statements naming");
      Rule.Diagnosis   :=
        new String'("#1#non-named block statement"      &
                    "#2#non-named nested loop statement" &
                    "#3#non-named nesting loop statement");
   end Init_Rule;
   --------------------------------------------------
   -- Rule_Check_Pre_Op (Unnamed_Blocks_And_Loops) --
   --------------------------------------------------
   procedure Rule_Check_Pre_Op
     (Rule    : in out Unnamed_Blocks_And_Loops_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State)
   is
      pragma Unreferenced (Rule, Control);
      Enclosing_El : Asis.Element;
      Step_Up      : Elmt_Idx := 0;
   begin
      case Statement_Kind (Element) is
         when A_Block_Statement =>
            if Is_Nil (Statement_Identifier (Element)) then
               State.Detected  := True;
               State.Diagnosis := 1;
            end if;
         when A_Loop_Statement       |
              A_While_Loop_Statement |
              A_For_Loop_Statement   =>
            if Is_Nil (Statement_Identifier (Element)) then
               --  First, check if the loop is nested. In case if a loop
               --  statement is enclosed in another loop and itself contains a
               --  loop statement, we generate the second diagnostic variant
               Enclosing_El := Get_Enclosing_Element (Step_Up);
               while Element_Kind (Enclosing_El) in A_Statement .. A_Path loop
                  if Statement_Kind (Enclosing_El) in
                       A_Loop_Statement .. A_For_Loop_Statement
                  then
                     State.Detected  := True;
                     State.Diagnosis := 2;
                     exit;
                  end if;
                  Step_Up := Step_Up + 1;
                  Enclosing_El := Get_Enclosing_Element (Step_Up);
               end loop;
               if not State.Detected then
                  --  Non nested loop, but it may contain other loops
                  State.Detected := Contains_Loop (Element);
                  if State.Detected then
                     State.Diagnosis := 3;
                  end if;
               end if;
            end if;
         when others =>
            null;
      end case;
   end Rule_Check_Pre_Op;
end Gnatcheck.Rules.Custom_1;
 
     |