/usr/share/doc/adacontrol/adacontrol_ug.html is in adacontrol-doc 1.19r10-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>AdaControl User Guide V1.19r10</title>
<meta name="description" content="AdaControl User Guide V1.19r10">
<meta name="keywords" content="AdaControl User Guide V1.19r10">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2any">
<link href="#Top" rel="start" title="Top">
<link href="dir.html#Top" rel="up" title="(dir)">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<h1 class="settitle" align="center">AdaControl User Guide V1.19r10</h1>
<a name="Top"></a>
<div class="header">
<p>
Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> </p>
</div>
<a name="AdaControl-User-Guide"></a>
<h1 class="top">AdaControl User Guide</h1>
<p>This is the AdaControl User Guide. It describes how to install and use
AdaControl. Please refer to the AdaControl Programmer Manual to learn
how to add new kinds of rules to AdaControl.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Introduction" accesskey="1">Introduction</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Installation" accesskey="2">Installation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Program-Usage" accesskey="3">Program Usage</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Command-language-reference" accesskey="4">Command language reference</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Rules-reference" accesskey="5">Rules reference</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Examples-of-using-AdaControl-for-common-programming-rules" accesskey="6">Examples of using AdaControl for common programming rules</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Specifying-an-Ada-entity-name" accesskey="7">Specifying an Ada entity name</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Syntax-of-regular-expressions" accesskey="8">Syntax of regular expressions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Non-upward_002dcompatible-changes" accesskey="9">Non upward-compatible changes</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<p>AdaControl is Copyright © 2005-2017 Eurocontrol/Adalog,
except for some specific modules that are © 2006
Belgocontrol/Adalog, © 2006 CSEE/Adalog, ©
2006 SAGEM/Adalog, or © 2015 Alstom/Adalog.
AdaControl 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 2, or (at
your option) any later version. This unit 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 this program; see file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
</p>
<p>As a special exception, if other files instantiate generics from this
program, or if you link units from this program with other files to
produce an executable, this does not by itself cause the resulting
executable to be covered by the GNU General Public License. This
exception does not however invalidate any other reasons why the
executable file might be covered by the GNU Public License.
</p>
<p>This document is Copyright © 2005-2017
Eurocontrol/Adalog. This document may be copied, in whole or in part,
in any form or by any means, as is or with alterations, provided that
(1) alterations are clearly marked as alterations and (2) this
copyright notice is included unmodified in any copy.
</p>
<hr>
<a name="Introduction"></a>
<div class="header">
<p>
Next: <a href="#Installation" accesskey="n" rel="next">Installation</a>, Previous: <a href="#Top" accesskey="p" rel="prev">Top</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> </p>
</div>
<a name="Introduction-1"></a>
<h2 class="chapter">1 Introduction</h2>
<p>AdaControl is an Ada rules controller. It is used to control that Ada
software meets the requirements of a number of parameterizable
rules. It is not intended to supplement checks made by the compiler,
but rather to search for particular violations of good-practice rules,
or to check that some rules are obeyed project-wide. AdaControl can
also be handy to make statistics about certain usages of language
features, or simply to search for the occurrences of particular
constructs; its scope is therefore not limited to enforcing
programming rules, although it is of course one of its main goals.
</p>
<p>AdaContol can also generate commands for suggested fixes to a number
of violations; its companion program <code>adactl_fix</code> can perform
these fixes automatically, or they can be fixed interactively from
GPS.
</p>
<p>AdaControl is a commercial product of
<a href="http://www.adalog.fr/adalog2.htm">Adalog</a> with professional grade
support available. Getting support is highly recommended for
industrial projects. Adacontrol can also be customized or extended to
match your special needs, please refer to <a href="#Support">Support</a> or contact
Adalog at <a href="mailto:info@adalog.fr">info@adalog.fr</a>.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Features" accesskey="1">Features</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Support" accesskey="2">Support</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#History" accesskey="3">History</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#References" accesskey="4">References</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Features"></a>
<div class="header">
<p>
Next: <a href="#Support" accesskey="n" rel="next">Support</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> </p>
</div>
<a name="Features-1"></a>
<h3 class="section">1.1 Features</h3>
<p>AdaControl analyzes a set of Ada units, according to parameterizable
controls. Controls can be given from the command line, from a file,
or interactively. There is a wide range of controls available. Some
are quite simple (although very useful):
</p><ul>
<li> Control physical layout of the program (Maximum line length, no use of
tabulations...)
</li><li> Control occurences of special strings in comments (like TBD for “To
Be Defined”), with full wildcarding.
</li><li> Use of features (goto statement, tasking, pointers, variables in
package specifications...)
</li><li> Use of any declared entity, with full overloading resolution
</li></ul>
<p>Other rules are quite sophisticated:
</p><ul>
<li> Control series of “if”...”elsif” that could be replaced by
“case” statements
</li><li> Verify usage of declarations (variables that should be constant,
variables read but not written...)
</li><li> Control declarations that could be moved to a more reduced, internal
scope
</li><li> Limit the call depth of a program (and diagnose recursive subprograms)
</li><li> Enforce a pattern that guarantees that exceptions are not handled
silently
</li><li> Enforce a pattern for paired calls (like semaphore’s “P” and “V”)
that guarantees that the closing call is always executed, even in
presence of exceptions.
</li><li> Check that there is no aliasing between out parameters
</li><li> Ensure that no protected operation calls a potentially blocking operation
</li></ul>
<p>and much, much more... See <a href="#Rules-reference">Rules reference</a> for the complete
reference for all possible controls. The <code>rules</code> directory
contains a set of command files; especially, the file <code>verif.aru</code>
contains some commonly accepted rules. It is a good starting point for
devising your own set of rules.
</p>
<p>AdaControl is very simple to use. It takes, as parameters, a list of
units to process and a list of commands that define the controls to
apply. The complete syntax of the commands is described in chapter
<a href="#Command-language-reference">Command language reference</a>.
</p>
<p>AdaControl produces messages to the standard output, unless
redirected. Several levels of messages are defined (i.e. error or found),
depending on the kind of the control (i.e. check or search).
</p>
<p>Rules can be locally disabled for a part of the source code, and various
options can be passed to the program.
</p>
<p>Ex:
</p>
<p>Given the following package:
</p><div class="example">
<pre class="example"><b>package</b> Pack <b>is</b>
<b>pragma</b> Pure (Pack);
...
<b>end</b> Pack;
</pre></div>
<p>The following command:
</p><div class="example">
<pre class="example">adactl -l "search pragmas (pure)" pack
</pre></div>
<p>produces the following result (displayed to standard output):
</p><div class="example">
<pre class="example">pack.ads:2:4: Found: PRAGMAS: use of pragma Pure
</pre></div>
<p>AdaControl integrates nicely in environments such as GPS
(see <a href="#Running-AdaControl-from-GPS">Running AdaControl from GPS</a>), AdaGide (see <a href="#Running-AdaControl-from-AdaGide">Running AdaControl from AdaGide</a>), or emacs (see <a href="#Control-kinds-and-report-messages">Control kinds and report messages</a>). In those environments, you can run AdaControl from menus
or by just clicking on a button!
</p>
<hr>
<a name="Support"></a>
<div class="header">
<p>
Next: <a href="#History" accesskey="n" rel="next">History</a>, Previous: <a href="#Features" accesskey="p" rel="prev">Features</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> </p>
</div>
<a name="Support-1"></a>
<h3 class="section">1.2 Support</h3>
<a name="Commercial-support"></a>
<h4 class="subsection">1.2.1 Commercial support</h4>
<p>Adalog provides commercial support for AdaControl. Support includes
the following benefits:
</p><ul>
<li> Help with installation procedures.
</li><li> Explanations regarding the use of the tool, and help for translating
coding standards into AdaControl rules.
</li><li> Dedicated account into our BT system for priority handling of
problem reports.
</li><li> Correction of problems encountered in the use of AdaControl.
Pre-releases versions of AdaControl are provided for each corrected
problem.
</li><li> Access to beta-versions before they are released
</li><li> Keeping in sync customer’s own custom rules with the latest version of
AdaControl.
</li><li> Reduced rate for on-demand development of custom rules.
</li><li> Priority consideration of enhancement requests. Satisfying enhancement
requests is not part of the support contract; however, Adalog is
constantly improving AdaControl, and suggestions originating from
supported customers are given a high priority in our todo list.
</li></ul>
<p>Adalog cannot correct problems whose origin is due to compiler bugs or
defects in the implementation of ASIS (contact your compiler provider
for support on these problems). However, Adalog will do its best
effort to find workarounds for such problems.
</p>
<p>In addition, Adalog can provide various services:
</p><ul>
<li> Custom improvements to AdaControl, including application-specific
rules;
</li><li> consulting services for defining coding standards;
</li><li> consulting services in all areas related to Ada, real-time,
compilation, etc. See <a href="http://www.adalog.fr/adalog2.htm">Adalog’s site</a> for details.
</li></ul>
<p>For pricing information about support contract and other services,
please contact <a href="mailto:info@adalog.fr">info@adalog.fr</a>.
</p>
<a name="Other-support"></a>
<h4 class="subsection">1.2.2 Other support</h4>
<p>There is a Wiki for questions about AdaControl at <br>
<a href="https://sourceforge.net/p/adacontrol/wiki/Home/">https://sourceforge.net/p/adacontrol/wiki/Home/</a>. This is the
place to ask for information, make suggestions, or get help from the
community.
</p>
<p>For problem reports, please create a ticket into our BT system at <br>
<a href="https://sourceforge.net/p/adacontrol/tickets/">https://sourceforge.net/p/adacontrol/tickets/</a>.
</p>
<a name="Your-support-to-us_002c-too_0021"></a>
<h4 class="subsection">1.2.3 Your support to us, too!</h4>
<p>If you enjoy AdaControl, there are several things you can do to help
us continue and improve this nice project.
</p><ul>
<li> Rate it, or even better post a review, on the
<a href="http://sourceforge.net/projects/adacontrol/reviews/">SourceForge
review page</a>
</li><li> Click “I use it” from
<a href="http://www.adalog.fr/adacontrol2.htm">AdaControl’s home page</a>.
</li><li> Rate it on <a href="http://www.ohloh.net/p/11353?ref=sample">AdaControl’s
Ohloh page</a>
</li><li> Get a support contract, or encourage your company, your friends, or
anybody else to get a support contract!
</li><li> Provide good ideas, new rules, suggestions for improvements...
</li></ul>
<p>And remember: developing AdaControl is an expensive effort (according
to Ohlo’s COCOMO model, it is worth 15 man.year of development). We
need support from our users to keep it running!
</p>
<hr>
<a name="History"></a>
<div class="header">
<p>
Next: <a href="#References" accesskey="n" rel="next">References</a>, Previous: <a href="#Support" accesskey="p" rel="prev">Support</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> </p>
</div>
<a name="History-1"></a>
<h3 class="section">1.3 History</h3>
<p>The development of AdaControl was initially funded by Eurocontrol
(<a href="http://www.eurocontrol.int">http://www.eurocontrol.int</a>), which needed a tool to help in
verifying the million+ lines of code that does Air Traffic Flow
Management over Europe. Because it was felt that such a tool would
benefit the community at-large, and that further improvements made by
the community would benefit Eurocontrol, it was decided to release
AdaControl as free software. Later, Eurocontrol, Belgocontrol, Alstom,
Ansaldo (formerly CSEE-Transport), and SAGEM-DS sponsored the
development of more rules.
</p>
<p>The requirements for AdaControl were written by Philippe Waroquiers
(Eurocontrol-Brussels), who also conducted extensive testing of
AdaControl over the Eurocontrol software. The software was developped
by Arnaud Lecanu and Jean-Pierre Rosen (Adalog). Rules, improvements,
etc. were contributed by Pierre-Louis Escouflaire (Adalog), Alain
Fontaine (ABF consulting), Richard Toy (Eurocontrol-Maastricht), and
Isidro Ilasa Veloso (GMV). AdaGide support and improvement of icons
were contributed by Gautier de Montmollin. Emmanuel Masker (Alstom),
Yannick Duchene and Pascal Pignard contributed to GPS integration.
</p>
<p>See file <code>HISTORY</code> for a description of the various versions of
AdaControl, including enhancements of the current version over the
previous ones. Users of a previous version are warned that the rules
are not 100% upward-compatible: this is necessary to make the rules
more consistent and easier to use. However, the incompatibilities are
straightforward to fix and should affect only a very limited number of
files. See <a href="#Non-upward_002dcompatible-changes">Non upward-compatible changes</a> for details.
</p>
<hr>
<a name="References"></a>
<div class="header">
<p>
Previous: <a href="#History" accesskey="p" rel="prev">History</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> </p>
</div>
<a name="References-1"></a>
<h3 class="section">1.4 References</h3>
<ol>
<li> “On the benefits for industrials of sponsoring free software
development”, <i>Ada User Journal</i>, Volume 26, number 4, december 2005
<p><a href="http://www.adalog.fr/publicat/Free-software.pdf">http://www.adalog.fr/publicat/Free-software.pdf</a>
</p></li><li> “A Comparison of Industrial Coding Rules”, <i>Ada User Journal</i>,
Volume 29, number 4, december 2008
<p><a href="http://www.adalog.fr/publicat/coding-rules.pdf">http://www.adalog.fr/publicat/coding-rules.pdf</a>
</p></li><li> “A Methodology for Avoiding Known Compiler Problems
Using Static Analysis”, <i>proceedings of the ACM SIGAda Annual International Conference (SIGAda 2010)</i>
<p><a href="http://dl.acm.org/authorize?316395">http://dl.acm.org/authorize?316395</a>
</p></li></ol>
<hr>
<a name="Installation"></a>
<div class="header">
<p>
Next: <a href="#Program-Usage" accesskey="n" rel="next">Program Usage</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> </p>
</div>
<a name="Installation-1"></a>
<h2 class="chapter">2 Installation</h2>
<p>Like any ASIS application, AdaControl can be run only if the compiler
available on the system has exactly the same version as the one used
to compile AdaControl itself. The executable distribution of
AdaControl will work only with GNAT version GPL 2017, as distributed
by AdaCore. If you are using any other version, please use the source
distribution of AdaControl and compile it as indicated below.
</p>
<p>Another reason for using the source distribution of AdaControl is that
the user may not be interested in all provided rules. It is very easy
to remove some rules from AdaControl to increase its
speed. See <a href="#Customizing-AdaControl">Customizing AdaControl</a>.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Building-and-installing-AdaControl-from-source" accesskey="1">Building and installing AdaControl from source</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Installing-an-executable-distribution" accesskey="2">Installing an executable distribution</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Installing-support-for-AdaGide" accesskey="3">Installing support for AdaGide</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Installing-support-for-GNATDashboard-integration" accesskey="4">Installing support for GNATDashboard integration</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Building-and-installing-AdaControl-from-source"></a>
<div class="header">
<p>
Next: <a href="#Installing-an-executable-distribution" accesskey="n" rel="next">Installing an executable distribution</a>, Previous: <a href="#Installation" accesskey="p" rel="prev">Installation</a>, Up: <a href="#Installation" accesskey="u" rel="up">Installation</a> </p>
</div>
<a name="Building-and-installing-AdaControl-from-source-1"></a>
<h3 class="section">2.1 Building and installing AdaControl from source</h3>
<p>This section is only for the source distribution of AdaControl. If you
downloaded an executable distribution (and are using the latest
version of GNAT GPL), you may skip to the next section.
</p>
<a name="Getting-the-correct-version-of-the-sources-for-your-Gnat-version"></a><a name="Getting-the-correct-version-of-the-sources-for-your-Gnat-version-1"></a>
<h4 class="subsection">2.1.1 Getting the correct version of the sources for your Gnat version</h4>
<p>ASIS is continuously evolving to support Ada-2005/2012 features, and
so is AdaControl. As a consequence, the full set of features of
AdaControl is supported only with recent versions of Gnat, namely with
GnatPRO 7.2.0 and GnatGPL-2013 (and higher). We refer to these
versions as the “new Gnat”, and we encourage all users to use the
latest versions.
</p>
<p>Some users may however need to use an older version of Gnat. We provide
also a version of AdaControl that is compatible with versions GnatPRO
7.0.x and GnatGPL-2011 and older (before some incompatible -but
necessary- changes in ASIS happened). We refer to these versions as
the “old Gnat”.
</p>
<p>The old gnat version is now frozen; it does not provide controls
related to Ada-2012 (or that depend on new features of ASIS) and will
not receive any new features or improvements in the future, unless
requested by a supported customer (such requests will be honoured as
part of the support contract). See <a href="#Support">Support</a> for information on
becoming a supported user. This version can be obtained (in source
only) from the Git repository of AdaControl on SourceForge
(<a href="http://adacontrol.sourceforge.net">http://adacontrol.sourceforge.net</a>), branch “master-old_gnat”.
</p>
<p>Intermediate releases of Gnat (GnatPRO-7.1.x, GnatGPL-2012)
are not fully compatible with either of these distributions. Depending
on exact version, problems may range from compilation errors to
incorrect results in some rare (Ada 2012) cases. Compatible sources
can be obtained from the Git repository of AdaControl on SourceForge
(<a href="http://adacontrol.sourceforge.net">http://adacontrol.sourceforge.net</a>), branch “GPL2012”. We will
be happy to help our supported customers who must use one of these
versions.
</p>
<a name="Prerequisites"></a>
<h4 class="subsection">2.1.2 Prerequisites</h4>
<p>The following software must be installed in order to compile
AdaControl from source:
</p><ul>
<li> A GNAT compiler, any version (but please consider <a href="#Getting-the-correct-version-of-the-sources-for-your-Gnat-version">Getting the correct version of the sources for your Gnat version</a> above). Note
that the compiler must also be available on the machine in order to
run AdaControl (all ASIS application need the compiler).
</li><li> ASIS for GNAT
</li><li> The GNATColl component (if support of .gpr files is desired)
</li></ul>
<p>Make sure to have the same version of GNAT and ASIS. The version used
for running AdaControl must be the same as the one used to compile
AdaControl itself.
</p>
<p>As mentionned above, support of Gnat .gpr projects requires the
GNATColl component from AdaCore. If for some reason you don’t want to
include this component, it is possible to build AdaControl without
this support. To do so, go to the <code>src</code> directory and modify the
file <code>implementation_options-project_file.ads</code> as indicated. If
you don’t have GNATColl installed at all, you need also to remove the
line that says “<code>with gnatcoll;</code>” from the file
<code>build.gpr</code>.
</p>
<a name="Build-and-install-with-installer-_0028Windows_0029"></a>
<h4 class="subsection">2.1.3 Build and install with installer (Windows)</h4>
<p>Run the installer (<code>adactl_src-setup.exe</code>). This will
automatically build and install AdaControl, no other installation is
necessary.
</p>
<a name="Build-and-install-with-project-file"></a><a name="Build-and-install-with-project-file-1"></a>
<h4 class="subsection">2.1.4 Build and install with project file</h4>
<p>Simply go to the root directory of the distribution and type:
</p><div class="example">
<pre class="example">gprbuild build.gpr
gprinstall build.gpr
</pre></div>
<p>You’re done!
</p>
<p>If you want to uninstall AdaControl, just use:
</p><div class="example">
<pre class="example">gprinstall --uninstall adacontrol
</pre></div>
<p>Caveat (<i>old gnat only</i>): Due to a bug in some versions, if you are using GNATPro
6.1.2 and above, you must set the variable GNAT_FIX to 1; i.e. invoke
the command as:
</p><div class="example">
<pre class="example">gprbuild -Pbuild.gpr -XGNAT_FIX=1
</pre></div>
<p>or if gprbuild is not available for your distribution:
</p><div class="example">
<pre class="example">gnatmake -Pbuild.gpr -XGNAT_FIX=1
</pre></div>
<a name="Build-and-install-with-Makefile"></a>
<h4 class="subsection">2.1.5 Build and install with Makefile</h4>
<p>It is also possible to build and install AdaControl with a regular
Makefile, although it does little more than run the previous
commands. This is mainly useful if you want to embed AdaControl into
some distribution that uses Makefiles, or if you want to change the
default compilation options (see comments in Makefile for details).
</p>
<p>Go to the root directory of the distribution and type:
</p><div class="example">
<pre class="example">make build
make install
</pre></div>
<p>It is also possible to delete object files and do other actions with
this “Makefile”, run the following command to get more information:
</p><div class="example">
<pre class="example">make help
</pre></div>
<p>NOTE: Building AdaControl needs the “make” command provide with GNAT; it
works both with WIN32 shell and UNIX shell.
</p>
<a name="Manual-installation"></a>
<h4 class="subsection">2.1.6 Manual installation</h4>
<p>Automatic install will place AdaControl’s files in standard locations,
in your Gnat installation tree. You can skip this section unless you
want different locations (for example, if GPS is not installed in the
Gnat tree).
</p>
<p>All you need to run AdaControl is the executable named <code>adactl</code>
under Linux and MacOS or <code>adactl.exe</code> under Windows. In addition,
<code>pfni</code> (or <code>pfni.exe</code> under Windows) is a convenient
utility, required by the GPS support. See <a href="#pfni">pfni</a>. Copy these
executables (found in the root directory of the distribution) to any
convenient directory on your path.
</p>
<p>To also add AdaControl support to GPS, copy the file
<code>GPS/adacontrol.xml</code> into the <code><GNAT_dir>/share/gprconfig</code>
directory; copy all other files from the <code>GPS</code> directory into the
<code><GPS_dir>/share/gps/plug-ins</code> directory. Copy also HTML files
from the <code>doc</code> directory into the
<code><GPS_dir>/share/doc/gps/html</code> to access AdaControl’s guides from
the "Help" menu of GPS.
</p>
<a name="Build-with-a-compiler-other-than-GNAT"></a>
<h4 class="subsection">2.1.7 Build with a compiler other than GNAT</h4>
<p>It should be possible to compile AdaControl with other compilers than
GNAT, although we didn’t have an opportunity to try it. If you have
another compiler that supports ASIS, note that it may require some
easy changes in the package <code>Implementation_Options</code> to give
proper parameters to the <code>Associate</code> procedure of ASIS. Rules
that need string pattern matchings need the package
<code>Gnat.Regpat</code>. If you compile AdaControl with another compiler,
you can either port <code>Gnat.Regpat</code> to your system, or use a
(limited) portable implementation of a simple pattern matching
(package <code>String_Matching_Portable</code>). Edit the file
<code>string_matching.ads</code> and change it as indicated in the comments.
No other change should be necessary.
</p>
<p>Alternatively, if you are using another compiler, you can try and
compile your program with GNAT just to be able to run
AdaControl. However, compilers often differ in their support of
representation clauses, which can cause your program to be rejected by
GNAT. In that case, we provide a sed script to comment-out all
representation clauses; this can be sufficient to allow you to use
AdaControl. See <a href="#unrepr_002esed">unrepr.sed</a>.
</p>
<a name="Testing-AdaControl"></a>
<h4 class="subsection">2.1.8 Testing AdaControl</h4>
<p>Testing AdaControl needs a UNIX shell, so it works only with UNIX
systems. However, it is possible to run the tests on a WIN32 system
by using an UNIX-like shell for WIN32, such as those provided by
CYGWIN or MSYS. To run the tests, enter the following commands:
</p><div class="example">
<pre class="example">cd test
./run.sh
</pre></div>
<p>All tests must report PASSED. If they don’t, it may be due to one of
the following issues:
</p><ul>
<li> You are using an old version of GNAT. AdaControl runs without any
known problem (and it has been checked against the whole ACATS) only
with the latest GNATPro and GNATGPL versions; earlier versions are
known to have bugs and unimplemented features that will not allow
AdaControl to run correctly in some cases. We strongly recommend to
always use the most recent version of GNAT.
</li><li> You run an old-gnat version of AdaControl with GNATPro (6.1.2 and
above) and you forgot to specify the “-XGNAT_FIX=1”
option. See <a href="#Build-and-install-with-project-file">Build and install with project file</a>.
</li><li> It may happen that the test <code>tfw_help</code> reports “FAILED” because
it includes a check on the version of AdaControl, and the version
string refers to a different version of Gnat. The only difference (you
can see it by typing “d” when prompted for checking the differences)
should be the name of the compiler.
</li></ul>
<a name="Customizing-AdaControl"></a><a name="Customizing-AdaControl-1"></a>
<h4 class="subsection">2.1.9 Customizing AdaControl</h4>
<p>If there are some rules that you are not interested in, it is very easy
to remove them from AdaControl:
</p><ol>
<li> In the <code>src</code> directory, edit the file
<code>framework-plugs.adb</code>. There is a <code>with</code> clause for each
rule (children of package <code>Rules</code>). Comment out the ones you
don’t want.
</li><li> Recompile <code>framework-plugs.adb</code>. There will be error messages
about unknown procedure calls. Comment out the corresponding lines.
</li><li> Compile AdaControl normally. That’s all!
</li></ol>
<p>It is also possible to add new rules to AdaControl. If your favorite
rules are not currently supported, you have several options:
</p><ol>
<li> If you have some funding available, please contact
<a href="mailto::info@adalog.fr">info@adalog.fr</a>. We’ll be happy to
make an offer to customize AdaControl to your needs.
</li><li> If you <i>don’t</i> have funding, but have some knowledge of ASIS
programming, you can add the rule yourself. We have made every effort
to make this as simple as possible. Please refer to the AdaControl
programmer’s manual for details. If you do so, please send your rules
to <a href="mailto::rosen@adalog.fr">rosen@adalog.fr</a>, and we’ll be
happy to integrate them in the general release of AdaControl to make them
available to everybody.
</li><li> If you have good ideas, but don’t feel like implementing them yourself
(nor financing them), please send a note to
<a href="mailto::rosen@adalog.fr">rosen@adalog.fr</a>. We will eventually
incorporate all good suggestions, but we can’t of course commit to any
dead-line in that case.
</li></ol>
<hr>
<a name="Installing-an-executable-distribution"></a>
<div class="header">
<p>
Next: <a href="#Installing-support-for-AdaGide" accesskey="n" rel="next">Installing support for AdaGide</a>, Previous: <a href="#Building-and-installing-AdaControl-from-source" accesskey="p" rel="prev">Building and installing AdaControl from source</a>, Up: <a href="#Installation" accesskey="u" rel="up">Installation</a> </p>
</div>
<a name="Installing-an-executable-distribution-1"></a>
<h3 class="section">2.2 Installing an executable distribution</h3>
<p>If you downloaded the Windows installer executable version of
AdaControl, simply run <code>adactl_exe-setup.exe</code>. This will install
all the files in the recommended locations (as has been done with the
Windows installer source version), including GPS support if you have
GPS installed and/or AdaGide support if you have AdaGide installed.
</p>
<p>Otherwise, go to the root directory of the installation and type:
</p><div class="example">
<pre class="example">gprinstall inst.gpr
</pre></div>
<p>This will install the executables and the GPS support in the standard
locations (the Gnat directory). However, if you are using AdaGide, the
support will have to be installed manually as explained below.
</p>
<p>If you want to uninstall AdaControl, just use:
</p><div class="example">
<pre class="example">gprinstall --uninstall adacontrol
</pre></div>
<hr>
<a name="Installing-support-for-AdaGide"></a>
<div class="header">
<p>
Next: <a href="#Installing-support-for-GNATDashboard-integration" accesskey="n" rel="next">Installing support for GNATDashboard integration</a>, Previous: <a href="#Installing-an-executable-distribution" accesskey="p" rel="prev">Installing an executable distribution</a>, Up: <a href="#Installation" accesskey="u" rel="up">Installation</a> </p>
</div>
<a name="Installing-support-for-AdaGide-1"></a>
<h3 class="section">2.3 Installing support for AdaGide</h3>
<p>To add AdaControl support to AdaGide, copy the file
<code>AdaControl.tdf</code> from the <code>AdaGide</code> directory of the
distribution into AdaGide’s root directory. Note that AdaControl
support requires AdaGide version 7.42 or above.
</p>
<hr>
<a name="Installing-support-for-GNATDashboard-integration"></a>
<div class="header">
<p>
Previous: <a href="#Installing-support-for-AdaGide" accesskey="p" rel="prev">Installing support for AdaGide</a>, Up: <a href="#Installation" accesskey="u" rel="up">Installation</a> </p>
</div>
<a name="Installing-support-for-GNATDashboard-integration-1"></a>
<h3 class="section">2.4 Installing support for GNATDashboard integration</h3>
<p>Integration into GNATDashboard is provided in a separate package that
you can download from the same source that you obtained AdaControl
from. It is provided as a .zip file that contains two files:
<code>adacontrol-plugin-1.0a.jar</code> and <code>adacontrol.py</code>.
</p>
<p>Of course, the prerequisite is that you have a working installation of
GNATDashboard, including SonarQube and its sonnar-scanner
utility. Copy the first (<code>.jar</code>) file into the
<code><sonarqube-dir>/extensions/plugins/</code> directory. Copy the second
(<code>.py</code>) file into the <code><gnat-dir>/share/gnathub/extras/</code>
directory.
</p>
<hr>
<a name="Program-Usage"></a>
<div class="header">
<p>
Next: <a href="#Command-language-reference" accesskey="n" rel="next">Command language reference</a>, Previous: <a href="#Installation" accesskey="p" rel="prev">Installation</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> </p>
</div>
<a name="Program-Usage-1"></a>
<h2 class="chapter">3 Program Usage</h2>
<p>AdaControl is a command-line program, i.e. it is normally called
directly from the system shell. <i>Options</i> are introduced by a “-”
followed by a letter and can be grouped as usual. Some options take
the following word on the command line as a value; such options must
appear last in a group of options. <i>Parameters</i> are words on the command
line that stand by themselves. Options and parameters can be given in
any order.
</p>
<p>The syntax for invoking AdaControl in regular mode is:
</p><div class="example">
<pre class="example">adactl [-deEirsTuvwx]
[-p <project file>] [-f [<command file>]] [-l <commands>]
[-F <format>] [-o <output file>] [-t <trace file>]
[-G <fix level>] [-S <statistics level>]
[-m <warning limit>] [-M <message limit>]
{<unit>[+|-<unit>]|[@]<file>} [-- <ASIS options>]
</pre></div>
<p>AdaControl can process all versions of Ada, up to Ada-2012. If you are
using Ada-2005 (or Ada-2012) features, make sure that GNAT is set up
for Ada-2005/2012 (this is the default for GNAT-GPL). Due to technical
reasons, the -gnat05 or -gnat12 option cannot be passed to the
compiler in “compile on the fly” mode, but you can do any of the
following:
</p><ul>
<li> have a “gnat.adc” file in the current directory that contains a
<code><b>pragma</b> Ada_05;</code> (or <code><b>pragma</b> Ada_12;</code>)
</li><li> put a <code><b>pragma</b> Ada_05</code> (or <code><b>pragma</b> Ada_12;</code>) on top
of every compilation unit that uses Ada-2005/2012 features;
</li><li> generate the tree files manually (see <a href="#Generating-tree-files-manually">Generating tree files manually</a>) with the “-gnat05” (or “-gnat12)”) option. Note that
this allows you to pass any other GNAT option as well.
</li></ul>
<p>Note that if your program is pure Ada-95 and you are using a version
of GNAT where Ada-2005 is the default (especially GNAT-GPL), and in
the rare cases where your program would not compile in Ada-2005 mode
(notably if you have a function that returns a task type), you can
force Ada-95 the same way by using <code><b>pragma</b> Ada_95</code> instead.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Command-line-parameters-and-options" accesskey="1">Command line parameters and options</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Return-codes" accesskey="2">Return codes</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Environment-variable-and-default-settings" accesskey="3">Environment variable and default settings</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Fixing-violations" accesskey="4">Fixing violations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Interactive-mode" accesskey="5">Interactive mode</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Other-execution-modes" accesskey="6">Other execution modes</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Running-AdaControl-from-GPS" accesskey="7">Running AdaControl from GPS</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Running-AdaControl-from-AdaGide" accesskey="8">Running AdaControl from AdaGide</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Integrating-AdaControl-into-GNATDashboard" accesskey="9">Integrating AdaControl into GNATDashboard</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Helpful-utilities">Helpful utilities</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Optimizing-Adacontrol">Optimizing Adacontrol</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#In-case-of-trouble">In case of trouble</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Command-line-parameters-and-options"></a>
<div class="header">
<p>
Next: <a href="#Return-codes" accesskey="n" rel="next">Return codes</a>, Previous: <a href="#Program-Usage" accesskey="p" rel="prev">Program Usage</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Command-line-parameters-and-options-1"></a>
<h3 class="section">3.1 Command line parameters and options</h3>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Input-units" accesskey="1">Input units</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Commands" accesskey="2">Commands</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Output-file" accesskey="3">Output file</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Output-format" accesskey="4">Output format</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Output-limits" accesskey="5">Output limits</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Project-files" accesskey="6">Project files</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Local-disabling-control" accesskey="7">Local disabling control</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Verbose-and-debug-mode" accesskey="8">Verbose and debug mode</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Treatment-of-warnings" accesskey="9">Treatment of warnings</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Exit-on-error">Exit on error</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#ASIS-options">ASIS options</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Input-units"></a>
<div class="header">
<p>
Next: <a href="#Commands" accesskey="n" rel="next">Commands</a>, Previous: <a href="#Command-line-parameters-and-options" accesskey="p" rel="prev">Command line parameters and options</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Input-units-1"></a>
<h4 class="subsection">3.1.1 Input units</h4>
<p>Units to be processed are given as parameters on the command
line. Note that they are Ada <em>compilation unit</em> names, not
<em>file names</em>: case is not significant, and there should be no
extension! Child units are allowed following normal Ada naming rules:
<code>Parent.Child</code>, but be aware that specifying a child unit will
automatically include its parent unit in the analysis. Subunits are
processed during the analysis of the including unit; there is
therefore no need to specify subunits explicitely. If you do specify a
subunit explicitly, it will result in the whole enclosing unit being
analyzed.
</p>
<p>However, as a convenience to the user, units can be specified as file
names, provided they follow the default GNAT naming convention. More
precisely, if a parameter ends in “.ads” or “.adb”, the unit name
is extracted from it (and all “-” in the name are substituted with
“.”). File names can include a path; in this case, the path is
automatically added to the list of directories searched (“-I” ASIS
option). The file notation is convenient to process all units in a
directory, as in the following example:
</p><div class="example">
<pre class="example">adactl -f my_rules.aru *.adb
</pre></div>
<p>In the unlikely case where you have a child unit called <code>Ads</code> or
<code>Adb</code>, use the “-u” option to force interpretation of all
parameters as unit names.
</p>
<p>By default, both the specification and body of the unit are processed;
however, it is possible to specify processing of the specification
only by providing the “-s” option. If only file names are given, the
“-s” option is assumed if all files are specifications (“.ads”
files). It is not possible to specify processing of bodies only, since
rules dealing with visibility would not work.
</p>
<p>The “-r” option tells AdaControl to process (recursively) all user
units that the specified units depend on (including parent units if
the unit is a child unit or a subunit). Predefined Ada units and units
belonging to the compiler’s run-time library are never processed.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">adactl -r -f my_rules.aru my_main
</pre></div>
<p>will process <code>my_main</code> and all units that <code>my_main</code> depends
on. If <code>my_main</code> is the main procedure, this means that the whole
program will be processed.
</p>
<p>If both options “-r” and “-s” are given, then AdaControl will
process all units given on the command line, plus (recursively) the
specifications (but not the bodies) of all units that the given units
depend on. In short, it will process the minimal transitive closure of
all compilation units that are necessary to compile the units given on
the command line.
</p>
<p>It is possible to specify more than one unit (not file) to process in
a parameter by separating the names with “+”. Conversely, it is
possible to specify units that are <i>not</i> to be processed, separated
by “-”. When a unit is subtracted from the unit list, it is never
processed even if it is included via the recursive option, and all its
child and separate units are also excluded. This is convenient to
avoid processing reusable components, that are not part of a
project. For example, if you want to run AdaControl on itself, you
should use the following command:
</p><div class="example">
<pre class="example">adactl -f my_rules_file.aru -r adactl-asis-a4g-gnatcoll
</pre></div>
<p>This applies the rules from the file <code>my_rules_files.aru</code> to
AdaControl itself, but not to units that are part of ASIS (units
<code>Asis</code>, <code>A4G</code>, and their children) that would be found by
the “-r” (recursive) option otherwise.
</p>
<p>Alternatively, it is possible to provide units indirectly with a
parameter consisting of an “@” followed by the name of a file. This
file must contain a list of unit names (not files), one on each
line. Only the first “word” of the line is considered,
i.e. everything after the first blank is ignored. This can be useful
to annotate unit names. All units whose names are given in the file
will be processed. In addition, some lines have a special meaning:
</p><ul>
<li> If a line in the file starts with “#” or “-<!-- /@w -->-”, it is
ignored. This can be useful to temporarily disable the processing of
some files or to add comments.
</li><li> If a name in the file starts with “-”, it indicates the name of a
unit that is <i>not</i> to be processed. This is useful if the indirect
file is used with the “-r” (recursive) option to prevent some units
that would be found by the recursive search to be included in the
analysis.
</li><li> If a name in the file starts with “@”, it will also be treated as
an indirect file (i.e. the same process will be invoked recursively).
</li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">adactl -f my_rules.aru @unit_file.txt
</pre></div>
<p>If no input units are specified on the command line, but a project
file is given which specifies a units file, the units from the units
file are processed. If the project file has no units file, but one or
several main files are given, the main files are processed (in
recursive mode if the recursive option is also given in the project
file). See <a href="#Project-files">Project files</a>.
</p>
<hr>
<a name="Commands"></a>
<div class="header">
<p>
Next: <a href="#Output-file" accesskey="n" rel="next">Output file</a>, Previous: <a href="#Input-units" accesskey="p" rel="prev">Input units</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Commands-1"></a>
<h4 class="subsection">3.1.2 Commands</h4>
<p>Commands specify which processing AdaControl should apply to
units. See <a href="#Command-language-reference">Command language reference</a> for a detailed description
of all commands.
</p>
<p>Commands can be given directly on the command line with the “-l”
option. A commands list must be quoted with “"”.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">adactl pack.ads proc.adb -l "check instantiations (My_Generic);"
</pre></div>
<p>It is possible to pass several commands separated by “;”,
but as a convenience to the user, the last “;” may be omitted.
</p>
<p>Commands can also be read from a file, whose name is given after the
“-f” option (the “<code>.aru</code>” extension is taken by default). As
a special case, if the file name is “-”, commands are read from the
standard input. This is intended to allow AdaControl to be pipelined
behind something that generates commands; if you want to type commands
directly to AdaControl, the interactive mode is more
appropriate. See <a href="#Interactive-mode">Interactive mode</a>.
</p>
<p>Alternatively, AdaControl will consider a command file set as default in a .gpr
project file, unless an explicit “-f” option is given.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">adactl -f my_rules.aru proc.adb
</pre></div>
<p>Note that the “-l” and “-f” options are <i>not</i> exclusive: if both
are specified, the commands to be performed include those in the file
(first) and then those given on the command line.
</p>
<p>This applies also when there is no “-f” option, but a .gpr file is
given which includes a default command file. If you need a project file,
and don’t want its default command file to be considered, use “-f”
without a <command file>.
</p>
<hr>
<a name="Output-file"></a>
<div class="header">
<p>
Next: <a href="#Output-format" accesskey="n" rel="next">Output format</a>, Previous: <a href="#Commands" accesskey="p" rel="prev">Commands</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Output-file-1"></a>
<h4 class="subsection">3.1.3 Output file</h4>
<p>Messages produced by controls are output to the output file; by
default, it is the standard output, but it can be changed by
specifying the “-o” option.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">adactl -f my_rules.aru -o my_output.txt proc.adb
</pre></div>
<p>If the output file exists, new messages are appended to it. This
allows running AdaControl under several directories that make up the
project, and gathering the results in a single file. However, if the
“-w” option is given, AdaControl overwrites the output file if it
exists.
</p>
<p>All other messages, including syntax error messages, units processed
(in verbose mode), and possible internal error mesages from AdaControl
itself are output to the standard error file.
</p>
<hr>
<a name="Output-format"></a>
<div class="header">
<p>
Next: <a href="#Output-limits" accesskey="n" rel="next">Output limits</a>, Previous: <a href="#Output-file" accesskey="p" rel="prev">Output file</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Output-format-1"></a>
<h4 class="subsection">3.1.4 Output format</h4>
<p>The “-F” option selects the output format. It must be followed by
“Gnat”, “Gnat_Short”, “CSV”, “CSV_Short”, “Source”,
“Source_Short”, or “None” (case insensitive). By default, the
output is in “Gnat” format.
</p>
<p>The “-S” option selects which statistics are output after each
run. It must be followed by a value in the range 0..3. See
<a href="#Control-kinds-and-report-messages">Control kinds and report messages</a> for details on the various
statistics levels.
</p>
<p>The “-T” option prints a summary of timing at the end of each run. This
indicates how long (in real-time seconds) was spent in processing each rule.
</p>
<p>The “-G” option controls the generation, in the output file, of
commands for fixing violations. It must be followed by “none” (the
default), where no fixes information is generated, “check”, where
fixes information is generated only for messages that use “check”,
or “search” where fixes information is generated for all messages
(i.e. “search” messages and above). Fixes information is never
generated for “count”.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">adactl -F CSV -S 2 -f my_rules.aru -o my_output.csv proc.adb
</pre></div>
<hr>
<a name="Output-limits"></a>
<div class="header">
<p>
Next: <a href="#Project-files" accesskey="n" rel="next">Project files</a>, Previous: <a href="#Output-format" accesskey="p" rel="prev">Output format</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Output-limits-1"></a>
<h4 class="subsection">3.1.5 Output limits</h4>
<p>The “-m” and “-M” options are used to limit the output of
AdaControl. These options are followed by an integer value that
specifies the maximum number of error messages (“-m”) or warning and
error messages (“-M”). If the value is omitted, a previous
limitation (comming for example from a command file) is cancelled.
</p>
<p>If the indicated number of messages is exceeded during a run,
AdaControl stops immediately.
</p>
<hr>
<a name="Project-files"></a>
<div class="header">
<p>
Next: <a href="#Local-disabling-control" accesskey="n" rel="next">Local disabling control</a>, Previous: <a href="#Output-limits" accesskey="p" rel="prev">Output limits</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Project-files-1"></a>
<h4 class="subsection">3.1.6 Project files</h4>
<p>Starting with version 1.18, AdaControl supports GNAT project files
(“.gpr”). The “-p” option is used to provide the name of a project
file; Ada units to analyze will be searched in all “source_dirs”
specified in the project file or one of the projects it depends on
(directly or indirectly). In addition, if the project file specifies a
command file for AdaControl, this file will be considered, unless there
is also an explicit “-f” option.
</p>
<p>Similarly, if no units are given on the command line, AdaControl
processes the units from the units file of the project file if any, or
the main files from the project file. In the later case, the units are
processed recursively if the project file specifies the recursive
option.
</p>
<p>In short, if you specify AdaControl parameters in the project file,
you only need to pass the “-p” option to it.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">adactl -f my_rules.aru -p proj.gpr proc.adb
</pre></div>
<p>Alternatively, an old emacs project file (the file with a “.adp”
extension used by the Ada mode of Emacs and older versions of
AdaControl) can also be specified with the “ -p” option. AdaControl
will consider all the directories mentioned in “src_dir” lines from
the project file.
</p>
<hr>
<a name="Local-disabling-control"></a>
<div class="header">
<p>
Next: <a href="#Verbose-and-debug-mode" accesskey="n" rel="next">Verbose and debug mode</a>, Previous: <a href="#Project-files" accesskey="p" rel="prev">Project files</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Local-disabling-control-1"></a>
<h4 class="subsection">3.1.7 Local disabling control</h4>
<p>The “-i” option tells AdaControl to ignore disabling markers in Ada
source code (see <a href="#Disabling-controls">Disabling controls</a>); i.e. all controls will be
performed, regardless of the presence of disabling markers. This is
equivalent to the command “<code>set ignore ON;</code>”. Note that if you
have many messages, setting this option can speed-up AdaControl
considerably. It is therefore advisable to always set this option
when you know that there is no disabling marker in your source code.
</p>
<p>The “-j” option tells AdaControl to invert the meaning of disabling
markers, i.e. only messages marked as disabled will be printed. This
is useful to check which messages have been disabled. This is
equivalent to the command “<code>set ignore INVERTED;</code>”.
</p>
<hr>
<a name="Verbose-and-debug-mode"></a>
<div class="header">
<p>
Next: <a href="#Treatment-of-warnings" accesskey="n" rel="next">Treatment of warnings</a>, Previous: <a href="#Local-disabling-control" accesskey="p" rel="prev">Local disabling control</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Verbose-and-debug-mode-1"></a>
<h4 class="subsection">3.1.8 Verbose and debug mode</h4>
<p>In the default mode, AdaControl displays only messages from triggered
controls. It is possible to get more information with the verbose
option (“-v”). In this mode, AdaControl displays a a progress
indicator and unit names as they are processed, and its global
execution time when it finishes. Note that the progress indicator
includes an indication of the run number if there are more than one
“go” command.
</p>
<p>The “-d” option enables debug mode. This mode provides more
information in case of an internal program error, and is of little
interest for the casual user. Note that if you hit Ctrl-C in debug
mode, AdaControl aborts with a message telling the currently active
rule and module. This can be useful if you suspect AdaControl to be
stuck in an infinite loop.
</p>
<p>In debug mode, AdaControl may also, in rare occasions (and only with
some versions of GNAT), display ASIS “bug boxes”; this does not mean
that something went wrong with the program, but simply that an ASIS
failure was properly recovered by AdaControl.
</p>
<p>Output of the messages printed by the “-d” option can be directed to
a “trace” file (instead of being printed to the standard error
file). This is done by the “-t” option, which must be followed by
the file name. If the trace file exists, new messages are appended to
it.
</p>
<hr>
<a name="Treatment-of-warnings"></a>
<div class="header">
<p>
Next: <a href="#Exit-on-error" accesskey="n" rel="next">Exit on error</a>, Previous: <a href="#Verbose-and-debug-mode" accesskey="p" rel="prev">Verbose and debug mode</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Treatment-of-warnings-1"></a>
<h4 class="subsection">3.1.9 Treatment of warnings</h4>
<p>The “-e” option tells AdaControl to treat warnings as errors,
i.e. to report a return code of 1 even if only “search” controls
were triggered. See <a href="#Return-codes">Return codes</a>. It does not change the messages
however.
</p>
<p>Conversely, the “-E” option tells AdaControl to <i>not</i> report
warnings at all, i.e. only errors are reported. However, if you ask
for statistics, the number of warning messages is still
counted. See <a href="#Control-kinds-and-report-messages">Control kinds and report messages</a>.
</p>
<hr>
<a name="Exit-on-error"></a>
<div class="header">
<p>
Next: <a href="#ASIS-options" accesskey="n" rel="next">ASIS options</a>, Previous: <a href="#Treatment-of-warnings" accesskey="p" rel="prev">Treatment of warnings</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="Exit-on-error-1"></a>
<h4 class="subsection">3.1.10 Exit on error</h4>
<p>If an internal error is encountered during the processing of a unit,
AdaControl will do its best effort to recover and to continue to
process other units. However, if the “-x” option is given,
AdaControl will stop on the first error encountered. This option is
mainly useful if you want to debug AdaControl itself (or your own
rules). See <a href="#In-case-of-trouble">In case of trouble</a>.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">adactl -x -f my_rules.aru proc.adb
</pre></div>
<hr>
<a name="ASIS-options"></a>
<div class="header">
<p>
Previous: <a href="#Exit-on-error" accesskey="p" rel="prev">Exit on error</a>, Up: <a href="#Command-line-parameters-and-options" accesskey="u" rel="up">Command line parameters and options</a> </p>
</div>
<a name="ASIS-options-1"></a>
<h4 class="subsection">3.1.11 ASIS options</h4>
<p>Everything that appears on the command line after “-<!-- /@w -->-” will be
treated as an ASIS option, as described in the ASIS user manual.
</p>
<p>Casual users don’t need to care about ASIS options, except in one
case: if you are running AdaControl from the command line (not from
GPS), and if the units that you are processing reference other units
whose source is not in the same directory, AdaControl needs to know
how to access these units (as GNAT would). This can be done either by
using a project file with the “-p” option (see <a href="#Project-files">Project files</a>), by putting the appropriate directories into the
ADA_INCLUDE_PATH environment variable, or by passing “-I” options to
ASIS.
</p>
<p>It is possible to pass one or several “-I” options to ASIS, to
provide other directories where sources can be found. The syntax is
the same as the “-I” option for GNAT.
</p>
<p>Other ASIS options, like the “-Cx” and/or “-Fx” options, can be
specified. Most users can ignore this feature; however, specifying
these options can improve the processing time of big
projects. See <a href="#Optimizing-Adacontrol">Optimizing Adacontrol</a>.
</p>
<hr>
<a name="Return-codes"></a>
<div class="header">
<p>
Next: <a href="#Environment-variable-and-default-settings" accesskey="n" rel="next">Environment variable and default settings</a>, Previous: <a href="#Command-line-parameters-and-options" accesskey="p" rel="prev">Command line parameters and options</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Return-codes-1"></a>
<h3 class="section">3.2 Return codes</h3>
<p>In order to ease the automation of controlling programs with shell
scripts, AdaControl returns various error codes depending on how
successful it was. Values returned are:
</p><ul>
<li> 0: At most “search” controls (i.e. warnings) were triggered (no control
at all with “-e” option)
</li><li> 1: At least one “check” control (i.e. error) was triggered (or at
least one “search” or “check” control with “-e” option)
</li><li> 2: AdaControl was not run due to a syntax error in the rules or in the
specification of units.
</li><li> 10: There was an internal failure of AdaControl.
</li></ul>
<hr>
<a name="Environment-variable-and-default-settings"></a>
<div class="header">
<p>
Next: <a href="#Fixing-violations" accesskey="n" rel="next">Fixing violations</a>, Previous: <a href="#Return-codes" accesskey="p" rel="prev">Return codes</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Environment-variable-and-default-settings-1"></a>
<h3 class="section">3.3 Environment variable and default settings</h3>
<p>If the environment variable “ADACTLINI” is set, its content is taken
as a set of commands (separated by semi-colons) that are executed
before any other command. Although any command can be specified, this
is intended to allow changing default settings with “set”
commands. See <a href="#Set-command">Set command</a>.
</p>
<p>For example, you can set ADACTLINI to “set format Gnat_Short” if you
prefer having you messages in short format rather than the (default)
long format.
</p>
<hr>
<a name="Fixing-violations"></a>
<div class="header">
<p>
Next: <a href="#Interactive-mode" accesskey="n" rel="next">Interactive mode</a>, Previous: <a href="#Environment-variable-and-default-settings" accesskey="p" rel="prev">Environment variable and default settings</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Fixing-violations-1"></a>
<h3 class="section">3.4 Fixing violations</h3>
<p>If the “-G” option is given with “check” or “search”, AdaControl
generates in the output file (in addition to the regular messages)
special directives to fix the source that violated some
rule. See <a href="#Output-format">Output format</a>.
</p>
<p>Not all rule provide automatic fixing, either because the rule is just
intended to report on the presence of some construct, or because the
fix needs manual inspection. When a rule does provide for automatic
fixing, there is a “Fixes” section in its description that explains
what can (or cannot) be fixed by the rule.
</p>
<a name="Interactive-fixing"></a>
<h4 class="subsection">3.4.1 Interactive fixing</h4>
<p>If the output file is loaded into GPS (automatically, or as a result
file), messages for which there is a known fix will appear as usual,
but with the “Fix” symbol (the little wrench icon) in the left
margin. Clicking on the icon will perform the fix and remove the
corresponding icon (just like fixable compilation errors).
</p>
<p>Alternatively, there is an “Apply all fixes” entry in the AdaControl
menu. This will apply all fixes, just as if you clicked on every
“Fix” symbol. Note that the “Undo” command can be used to revert
the effect of this command!
</p>
<p>Note that by default, the generation of fixes is enabled under GPS.
</p>
<a name="Automatic-fixing"></a>
<h4 class="subsection">3.4.2 Automatic fixing</h4>
<p>An output file containing the directives can be processed by the
<code>adactl_fix</code> utility. The syntax is:
</p><div class="example">
<pre class="example">adactl_fix [-v] [-o <output-prefix>] <file>...
adactl_fix -h
</pre></div>
<p>With the “-h” option, <code>adactl_fix</code> prints a brief help message
and exits, ignoring all other options and parameters.
</p>
<p>Otherwise, <code>adactl_fix</code> reads the indicated <file>s (more than
one can be provided) and performs the corresponding fixes. The
modified files are printed on the standard output, which can be
redirected to a file for later splitting at an appropriate place with
<code>gnatchop</code>. Alternatively, if the “-o” option is given, each
modified file is output to a file whose name is obtained by prefixing
the <output-prefix> of the "-o" option to the original name of the
corresponding source file. The <output-prefix> can be any string, and
is not analyzed by Adactl_Fix. A prefix like "result/" will result in
all the output going to the directory "result", with the same name as
the original. Alternatively, a prefix like "new-" will result in all
output files being in the same directory, with a "new-" prepended to
the name. Adactl_Fix will overwrite any existing file with the same
name.
</p>
<a name="Conflicts"></a>
<h4 class="subsubsection">3.4.2.1 Conflicts</h4>
<p>It is possible that several fixes modify the same place, or
overlapping places. When using automatic fixing, if one of the fixes
is the deletion of a zone of text that fully covers the other one,
then the deletion is kept and the other one discarded. Otherwise, the
first fix is kept and the other one is ignored; a message at the end
of the run tells the user that some fixes were not performed, and that
AdaControl should be run again.
</p>
<p>When this happens, it is possible (although we expect it to be
infrequent) that the modified code does not compile anymore and that
some easy manual adjustments be necessary.
</p>
<p>It is expected that this algorithm for resolving conflicts be improved
in the future. Suggestions and examples welcome!
</p>
<p>When using interactive fixing, all fixes are kept; just click on the
various “fix” icons, and check that the code is transformed
appropriately.
</p>
<a name="How-to-proceed"></a>
<h4 class="subsection">3.4.3 How to proceed</h4>
<p>Automatic fixing is a powerful feature of AdaControl, but like any
tool that transforms the source it requires some care. Automatic
fixing makes sense when there are many violations, and these
violations would be easy but tedious to fix by hand. A typical use
case is when you apply new rules to an existing software, and discover
that the casing rules have not been obeyed: fixing the casing of
thousands of identifiers is a long and uninteresting job...
Therefore, the automatic fixing tool has been designed under the
assumption that it will be used “one-shot”, not as day-to-day use.
</p>
<p>The automatic fixing should therefore be used as follows:
</p><ul>
<li> Use backups, your CMS, etc. to save the initial state and to be able
to compare the original and fixed versions.
</li><li> Always run AdaControl on the whole program; some rules need a complete
analysis to be reliable. For example, a (visible) variable is known
to be unused only if all possible users have been analyzed.
</li><li> Prefer running AdaControl on a single rule, fix the resulting errors,
then run it again on a different rule. This should minimize the number
of conflicts.
</li><li> In case of conflicts, Adactl_Fix warns you that some fixes were not
applied; recompile your program to check that the partial fixes did
not introduce syntax errors, and fix if necessary. Then run AdaControl
and Adactl_Fix again, until all fixes are applied.
</li></ul>
<p>On the other hand, interactive fixing is fully under user control. It
is possible to check (and possibly undo) any modification. But of
course, since it is a manual operation, it becomes tedious when there
are many changes to perform.
</p>
<p>As a rule of thumb, perform automatic fixing, one rule at a time, for
the controls that often result in a big number of violations, and
where the fix is both obvious and riskless (typically: incorrect
casing of identifiers or keywords). Use interactive fixing for more
subtile controls where it is more appropriate to check the result of
the substitution.
</p>
<p>Caveat: fixing a violation can create another violation! Typically,
if the fix adds some text (like changing a positional association to a
named one), it can then exceed the maximum allowed line length. Hence
fixing violations is necessarily an iterative process.
</p>
<p>And of course, the best advice is: fix violations as early as
possible. Run AdaControl each time you modify a module. This is the
best way to save the effort!
</p>
<a name="A-word-of-caution"></a>
<h4 class="subsection">3.4.4 A word of caution</h4>
<p>Attention of users designing safety critical applications (DOD-178B/C
level A, EN-50128 SIL4) is drawn to the fact that the automatic fixing
is relevant to TQL1-4, instead of TQL5 as AdaControl normally is.
</p>
<p>AdaControl has not been subject to the formal verifications required by
TQL1-4 tools; therefore it is up to the user to check that the applied
fixes maintain the integrity of the software.
</p>
<hr>
<a name="Interactive-mode"></a>
<div class="header">
<p>
Next: <a href="#Other-execution-modes" accesskey="n" rel="next">Other execution modes</a>, Previous: <a href="#Fixing-violations" accesskey="p" rel="prev">Fixing violations</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Interactive-mode-1"></a>
<h3 class="section">3.5 Interactive mode</h3>
<p>The “-I” option tells AdaControl to operate interactively. In this
mode, commands specified with “-l” or “-f” options are first
processed, then AdaControl prompts for commands on the terminal. Note
that the “quit” command (see <a href="#Quit-command">Quit command</a>) is used to terminate
AdaControl.
</p>
<p>The syntax of commands run interactively is exactly the same as the
one used for files; especially, each command must be terminated with a
“;”. Note that the prompt (“Command:”) becomes “.......:” when
AdaControl requires more input because a command is not completely
given, and especially if you forget the final “;”.
</p>
<p>As with files, it is possible to give several commands on a single
line in interactive mode. If a command contains syntax errors, all
“go” commands (see <a href="#Go-command">Go command</a>) on the same line are temporarily
disabled. Other commands that do not have errors are normally
processed however.
</p>
<p>The interactive mode is useful when you want to do some analysis of
your code, but don’t know beforehand what you want to control. Since
the ASIS context is open only once when the program is loaded, queries
will be much faster than running AdaControl entirely with a new query
given in a “-l” option each time. It is also useful to experiment
with AdaControl, and to check interactively commands before putting
them into a file.
</p>
<hr>
<a name="Other-execution-modes"></a>
<div class="header">
<p>
Next: <a href="#Running-AdaControl-from-GPS" accesskey="n" rel="next">Running AdaControl from GPS</a>, Previous: <a href="#Interactive-mode" accesskey="p" rel="prev">Interactive mode</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Other-execution-modes-1"></a>
<h3 class="section">3.6 Other execution modes</h3>
<p>In addition to normal usage, AdaControl features special options to
ease its use; no Ada unit is analyzed when using these options.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Getting-help" accesskey="1">Getting help</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Checking-commands-syntax" accesskey="2">Checking commands syntax</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Generating-a-units-list" accesskey="3">Generating a units list</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Getting-help"></a>
<div class="header">
<p>
Next: <a href="#Checking-commands-syntax" accesskey="n" rel="next">Checking commands syntax</a>, Previous: <a href="#Other-execution-modes" accesskey="p" rel="prev">Other execution modes</a>, Up: <a href="#Other-execution-modes" accesskey="u" rel="up">Other execution modes</a> </p>
</div>
<a name="Getting-help-1"></a>
<h4 class="subsection">3.6.1 Getting help</h4>
<p>The “-h” option provides help about Adacontrol usage. If the “-h”
option is given, no other option is analyzed and no further processing
happens.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">adactl -h [<keyword> | <rule name> | variables ["<pattern>"] ...]
<keyword> ::= all | commands | license | list |
options | rules | version
</pre></div>
<p>The “-h” option without parameter displays a help message about usage of the
AdaControl program, the various options, and the rule names.
</p>
<p>Otherwise, the “-h” must be followed by one or several keywords or
rule names (case irrelevant); its effect is:
</p><ul>
<li> <rule name>: if <rule name> is exactly the name of rule, display the
help message for the indicated rule. Otherwise, <rule name> is
interpreted as a pattern, and help messages for all rules that match
the pattern is displayed. Patterns are given using the full
Regexp syntax. see <a href="#Syntax-of-regular-expressions">Syntax of regular expressions</a> for details.
</li><li> “variables” lists the values of all variables whose name matches <pattern>,
or all variables if there is no <pattern>. Patterns are given using the full
Regexp syntax. see <a href="#Syntax-of-regular-expressions">Syntax of regular expressions</a> for details.
</li><li> “all”: display the help message for all rules.
</li><li> “commands”: display a summary of all commands
</li><li> “license”: display the license information
</li><li> “list”: display the names of all rules (note that “rules” also
displays the list of rules, in a prettier format; the “list” option
is mainly useful for the integration of AdaControl into GPS).
</li><li> “options”: display help about the command-line options
</li><li> “rules”: display the names of all rules.
</li><li> “version”: display AdaControl and ASIS implementation version numbers.
</li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">adactl -h pragmas Unnecessary_Use_Clause
adactl -h all
adactl -h version license
adactl -h stat
</pre></div>
<p>Note in the last example that “stat” is not the name of a rule; it
is therefore interpreted as a pattern, and help will be displayed for
all rules that include the string “stat” in their name. This can be
very convenient to retrieve the name of a rule if you don’t remember
exactly how it is spelled.
</p>
<hr>
<a name="Checking-commands-syntax"></a>
<div class="header">
<p>
Next: <a href="#Generating-a-units-list" accesskey="n" rel="next">Generating a units list</a>, Previous: <a href="#Getting-help" accesskey="p" rel="prev">Getting help</a>, Up: <a href="#Other-execution-modes" accesskey="u" rel="up">Other execution modes</a> </p>
</div>
<a name="Checking-commands-syntax-1"></a>
<h4 class="subsection">3.6.2 Checking commands syntax</h4>
<p>The “-C” option is used to check syntax of commands without
executing any control.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">adactl -C [-dv] [-f <command file>] [-l <rules list>]
</pre></div>
<p>In this mode, AdaControl simply checks the syntax of the commands
provided with the “-l” option, or of the commands provided in the
file named by the “-f” option (at least one of these options must be
provided). No other processing will happen.
</p>
<p>AdaControl will exit with a return code of 0 if the syntax is correct,
and 2 if any errors are found. A confirming message that no errors
were found is output if the “-v” option is given.
</p>
<p>This option is especially useful when you have modified a command file,
before trying it on many units. The way AdaControl works, it must open
the ASIS context (a lengthy operation) <i>before</i> analyzing the
rules. This option can therefore save a lot of time if the command file
contains errors.
</p>
<hr>
<a name="Generating-a-units-list"></a>
<div class="header">
<p>
Previous: <a href="#Checking-commands-syntax" accesskey="p" rel="prev">Checking commands syntax</a>, Up: <a href="#Other-execution-modes" accesskey="u" rel="up">Other execution modes</a> </p>
</div>
<a name="Generating-a-units-list-1"></a>
<h4 class="subsection">3.6.3 Generating a units list</h4>
<p>The “-D” options produces a list of units that can be reused as an
indirect file in later runs.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">adactl -D [-rsvw] [-o <output file>] [-p <project file>]
{<unit>[+|-<unit>]|[@]<file>} [-- <ASIS options>]
</pre></div>
<p>In this mode, AdaControl outputs the list of units that would be
processed. It is especially useful when used with the “-r” option
and given the main unit name, since it will then generate the whole
dependencies list (hence the name “D”), i.e. the list of units that
are part of the program. However, if -D is used with -s, the list
includes only transitive dependencies from the specifications of
required units (but not from their bodies). This is the list of all
units required to compile the given units.
</p>
<p>The list can be directed to a file with the “-o” option (if the
file exists, it won’t be overwritten unless the “-w” option is
specified). This file can then be used in an indirect list of
units. See <a href="#Input-units">Input units</a>. Note that it is more efficient to create
the list of units once and then use the indirect file than to specify
all applicable units or use the “-r” option each time AdaControl is
run.
</p>
<a name="Limitation-1"></a>
<h4 class="subsubsection">3.6.3.1 Limitation</h4>
<p>If you use the “-Drs” option to generate the minimum set of required
units to compile the given unit, note that some units may still be
missing when the compiler requires the presence of a body due to
inlining of subprograms or generic instantiations. These units depend
on the compiler and cannot be computed from the text of the program
alone.
</p>
<hr>
<a name="Running-AdaControl-from-GPS"></a>
<div class="header">
<p>
Next: <a href="#Running-AdaControl-from-AdaGide" accesskey="n" rel="next">Running AdaControl from AdaGide</a>, Previous: <a href="#Other-execution-modes" accesskey="p" rel="prev">Other execution modes</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Running-AdaControl-from-GPS-1"></a>
<h3 class="section">3.7 Running AdaControl from GPS</h3>
<p>AdaControl integrates nicely into GPS, making it even easier to
use. It can be launched from menu commands, and parameters can be set
like any other GPS project parameters. When run from within GPS,
AdaControl will automatically retrieve all needed directories from the
current GPS project.
</p>
<p>After running AdaControl, the “locations” panel will open, and you
can retrieve the locations of errors from there, just like with a
regular compilation. Errors will be marked in red in the source,
warning will be marked orange, and you will have corresponding marks
showing the places of errors and warnings in the speedbar. Note that
AdaControl errors appear under the “AdaControl” category, but if
there were compilation errors, they will appear under the
“Compilation” category. Final counts from “count” control kinds will
appear under the “Counts summary” category, and statistics under the
“Statistics” category.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#The-AdaControl-menu-and-buttons" accesskey="1">The AdaControl menu and buttons</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Contextual-menu" accesskey="2">Contextual menu</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#AdaControl-switches" accesskey="3">AdaControl switches</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#AdaControl-preferences" accesskey="4">AdaControl preferences</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#AdaControl-language" accesskey="5">AdaControl language</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#AdaControl-help" accesskey="6">AdaControl help</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Caveat" accesskey="7">Caveat</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="The-AdaControl-menu-and-buttons"></a>
<div class="header">
<p>
Next: <a href="#Contextual-menu" accesskey="n" rel="next">Contextual menu</a>, Previous: <a href="#Running-AdaControl-from-GPS" accesskey="p" rel="prev">Running AdaControl from GPS</a>, Up: <a href="#Running-AdaControl-from-GPS" accesskey="u" rel="up">Running AdaControl from GPS</a> </p>
</div>
<a name="The-AdaControl-menu-and-buttons-1"></a>
<h4 class="subsection">3.7.1 The AdaControl menu and buttons</h4>
<p>AdaControl adds an “AdaControl” menu to GPS, with several submenus:
</p><ul>
<li> “Control Current File (rules file)” runs AdaControl on the currently
edited file, with rules taken from the current rules file; this menu
is greyed-out if no rules file is defined, if no file window is
currently active, or if the associated language is not “Ada”. The
name of the rules file can be set from the “Library” tab from the
“Project/Edit Project Properties” menu.
</li><li> “Control Root Project (rules file)” runs AdaControl on all units
that are part of the root project, with rules taken from the current
rules file; this menu is greyed-out if no rules file is defined. The
name of the rules file can be set from the “Library” tab from the
“Project/Edit Project Properties” menu.
</li><li> “Control Units from List (rules file)” runs AdaControls on units
given in a indirect file, with rules taken from the current rules
file. This menu is greyed-out if no rules file is defined or if no
indirect file is defined. The name of the rules file and of the
indirect file can be set from the “Library” tab from the
“Project/Edit Project Properties” menu.
</li><li> “Control Current File (interactive)” runs AdaControl on the
currently edited file, with a rule asked interactively from a pop-up;
this menu is greyed-out if no file window is currently active, or if
the associated language is not “Ada”.
</li><li> “Control Root Project (interactive)” runs AdaControl on all units
that are part of the root project, with a rule asked interactively
from a pop-up.
</li><li> “Control Units from List (interactive)” runs AdaControls on units
given in a indirect file, with a rule asked interactively from a
pop-up. This menu is greyed-out if no indirect file is defined. The
name of the indirect file can be set from the “Library” tab from the
“Project/Edit Project Properties” menu.
</li><li> “Apply all fixes” applies all automatic fixes resulting from the
latest run, like if you had clicked on every “fix” icon reported by
AdaControl.
</li><li> “Check Rules File” checks the syntax of the current rules file. This
menu is deactivated if the current window does not contain an
AdaControl rules file.
</li><li> “Open Rules File” opens the rules file. This menu is deactivated if
there is no current rules file defined.
</li><li> “Open Units File” opens the units file. This menu is deactivated if
there is no current units file defined.
</li><li> “Create units file” creates a text file containing all units (not
files) names from the current root project. This file is appropriate
as an indirect file for the “... from list” commands.
</li><li> “Create .adp project” creates an Emacs-style project file from the
current GPS project. This is of little interest now that AdaControl
accepts GPS project files directly, and is still provided for
compatibility with older versions of AdaControl. See <a href="#Project-files">Project files</a>.
</li><li> “Delete Tree Files” removes existing tree files from the current
directory. This is convenient when AdaControl complains that the tree
files are not up-to-date. Note that you can set the preferences for
automatic deletion of tree files after each run (see below). Note that
the name of this menu is changed to “Delete Tree and .ali Files” if
you have chosen to delete .ali files in the preferences (see below).
</li><li> “Load results file” loads in the location window the result file
obtained from a previous run of AdaControl. The file must have been
produced with the “Gnat” or “Gnat_Short” format. See <a href="#Control-kinds-and-report-messages">Control kinds and report messages</a>.
</li></ul>
<p>There are also two buttons representing Lady Ada in a magnifier glass
in the toolbar, one with a red question mark in the background. These
buttons launch AdaControl, by default on the file currently being
edited; however, you can change this behaviour from the preferences to
control either files from a list, or all files from the project. The
button without the question mark uses rules from the current rules
file, while the one with the question mark asks for the control to
apply interactively.
</p>
<p>Here are some tips about using the “interactive” menus (or the
button with the question mark):
</p><ul>
<li> When you use the “interactive” menus several times, the
previously entered command(s) is used as a default.
</li><li> You can enter any command from AdaControl’s language in the dialog;
you can even enter several commands separated by “;”.
</li><li> Especially, if you want to run AdaControl with a command file that is
not the one defined by the switches, you can use one of the
“interactive” commands, and give “source <file name>” as the
command.
</li></ul>
<hr>
<a name="Contextual-menu"></a>
<div class="header">
<p>
Next: <a href="#AdaControl-switches" accesskey="n" rel="next">AdaControl switches</a>, Previous: <a href="#The-AdaControl-menu-and-buttons" accesskey="p" rel="prev">The AdaControl menu and buttons</a>, Up: <a href="#Running-AdaControl-from-GPS" accesskey="u" rel="up">Running AdaControl from GPS</a> </p>
</div>
<a name="Contextual-menu-1"></a>
<h4 class="subsection">3.7.2 Contextual menu</h4>
<p>AdaControl adds two entries to the contextual menus (right click) of
Ada files. They call the <code>pfni</code> utility on the current
entity. See <a href="#pfni">pfni</a>. The entry “Print full name” displays the full
name of the entity in simple form, while the entry “Print full name
(with overloading)” ) prints it with overloading information. If the
name refers to an entity which is initialized (or to a parameter with
a default value), the initial value is printed. If the entity is a
discrete type, its range is printed. If the entity is an array type,
the ranges of its indices are printed.
</p>
<p>This is convenient to find how to name entities in rule
files. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. It is also convenient to
find where an entity is declared, and which of several overloaded
entities is being referred to.
</p>
<p>This is also convenient to find the actual value of a constant from
anywhere in the program text, since the printed value is completely
evaluated if it is a (static) expression.
</p>
<hr>
<a name="AdaControl-switches"></a>
<div class="header">
<p>
Next: <a href="#AdaControl-preferences" accesskey="n" rel="next">AdaControl preferences</a>, Previous: <a href="#Contextual-menu" accesskey="p" rel="prev">Contextual menu</a>, Up: <a href="#Running-AdaControl-from-GPS" accesskey="u" rel="up">Running AdaControl from GPS</a> </p>
</div>
<a name="AdaControl-switches-1"></a>
<h4 class="subsection">3.7.3 AdaControl switches</h4>
<p>The tab “switches” from the “Project/Edit Project Properties” menu
includes a page for AdaControl, which allows you to set various
parameters. Since the GPS interface analyzes the output of AdaControl,
you should not set options directly in the bottom window of this page
(the one that displays the actual options passed to AdaControl).
</p>
<a name="Files"></a>
<h4 class="subsubsection">3.7.3.1 Files</h4>
<p>This section controls the definition of various files used by AdaControl.
</p><ul>
<li> “Rules file”. This is the name of a file that contains the
definition of the controls to be applied to your project. This file is
required for all “control (rules file)” commands.
</li><li> “Units file”. This is the name of a file that contains the list of
units to be controlled. This file is required for all “control from
list” commands.
</li></ul>
<a name="Processing"></a>
<h4 class="subsubsection">3.7.3.2 Processing</h4>
<p>This section offers options that control how units are processed.
</p><ul>
<li> “Recursive mode”. This sets the “-r” option. See <a href="#Input-units">Input units</a>.
</li><li> “Ignore local deactivation”. This sets the “-i”
option. See <a href="#Local-disabling-control">Local disabling control</a>.
</li><li> “Process specs only”. This sets the “-s” option. See <a href="#Input-units">Input units</a>.
</li><li> “Compilation unit mode”. This sets the “-u” option. See <a href="#Input-units">Input units</a>.
</li></ul>
<a name="Debug"></a>
<h4 class="subsubsection">3.7.3.3 Debug</h4>
<p>This section controls the debugging options of AdaControl.
</p><ul>
<li> “Debug messages”. This sets the “-d” option. See <a href="#Verbose-and-debug-mode">Verbose and debug mode</a>.
</li><li> “Halt on error”. This sets the “-x” option. See <a href="#Exit-on-error">Exit on error</a>.
</li></ul>
<a name="Output"></a>
<h4 class="subsubsection">3.7.3.4 Output</h4>
<p>This section offers options that control where and how the output of
AdaControl is displayed.
</p><ul>
<li> “Display only errors”. This sets the “-E” option. See <a href="#Treatment-of-warnings">Treatment of warnings</a>.
</li><li> “Warnings as errors”. This sets the “-e” option. See <a href="#Treatment-of-warnings">Treatment of warnings</a>.
</li><li> “Statistics”. This sets the “-S” option from a pull-down
menu. See <a href="#Control-kinds-and-report-messages">Control kinds and report messages</a>.
</li><li> “Send results to GPS”. When checked (default), the output of
AdaControl is sent to the “locations” window of GPS.
</li><li> “Send results to File”. When checked, the output of AdaControl is
sent to the file indicated in the box below.
</li><li> “Send results to File and GPS”. When checked, the output of
AdaControl is sent to the file indicated in the box below, and the
content of the file is then automatically reloaded in the
“locations” window of GPS. If this option is set, the file format is
always “Gnat” (the file format option is ignored).
</li><li> “File name”. This is the name of the file that will contain the
results when sent to “File” or “File and GPS”. If the results are
sent to “File” and the file exists, AdaControl will ask for the
permission to overwrite it. If the results are sent to “File and
GPS”, the result file is always overriden without asking.
</li><li> “File format”. This is a pull-down menu that allows you to select
the desired format when output is directed to a file (“-F” option).
See <a href="#Control-kinds-and-report-messages">Control kinds and report messages</a>.
</li><li> “Generate fixes for”. This is a pull-down menu that allows you to
select whether you want fixes generated only for errors (“Check”) or
also for warnings (“Check and Search”). If you select “None”, no
fixes are generated (although this is not very interesting, unless you
want the output of AdaControl to be directed to a file for later
processing by a tool that does not know about fixes).
</li></ul>
<a name="ASIS"></a>
<h4 class="subsubsection">3.7.3.5 ASIS</h4>
<p>This section controls the ASIS parameters passed to AdaControl. The
content of the input field “ASIS options” is used in place of the
standard (“-CA -FM”) one.
</p>
<p>Casual users don’t need to change the default ASIS options. For more
details, see <a href="#ASIS-options">ASIS options</a>.
</p>
<hr>
<a name="AdaControl-preferences"></a>
<div class="header">
<p>
Next: <a href="#AdaControl-language" accesskey="n" rel="next">AdaControl language</a>, Previous: <a href="#AdaControl-switches" accesskey="p" rel="prev">AdaControl switches</a>, Up: <a href="#Running-AdaControl-from-GPS" accesskey="u" rel="up">Running AdaControl from GPS</a> </p>
</div>
<a name="AdaControl-preferences-1"></a>
<h4 class="subsection">3.7.4 AdaControl preferences</h4>
<p>There is an entry for AdaControl in the “edit/preferences” menu:
</p><ul>
<li> “delete trees”. If this box is checked, tree files are automatically
deleted after each run of AdaControl. This avoids having problems with
out-of-date tree files, at the expanse of slightly slowing down
AdaControl if you run it several times in a row without changing the
source files.
</li><li> “Delete .ali files with tree files”. If this box is checked, the
“.ali” files in the current directory will also be deleted together
with the tree files (either automatically if the previous box is
checked, or when the “AdaControl/Delete Tree Files” menu is
selected). This is normally what you want, unless the current
directory is also used as the object directory for compilations; in
the latter case, deleting “.ali” files would cause a full
recompilation for the next build of the project.
</li><li> “Help on rule”. This allows you to select how rule specific help
(from the “Help/AdaControl/Help on rule” menu) is displayed. If you
select “Pop-up”, a summary of the rule’s purpose and syntax is
displayed in a pop-up. If you select “User Guide”, the user guide
opens in a browser at the page that explains the rule. (<b>Caveat</b>:
due to a problem in GPS under Windows, the “User Guide” option may
not work at all, or the browser will not find the right anchor;
hopefully, this will be fixed in an upcomming release of GPS. No such
problem under Linux).
</li><li> “Use separate categories”. If this box is checked, there will be one
category (i.e. tree in the locations window) for each rule type or
label, otherwise all messages will be grouped under the single
category “AdaControl”. In practice, this means that with the box
checked, messages will be sorted by rules first, then by files, while
otherwise, the messages will be sorted by files first, then by rules.
In any case, compilation errors appear under the “Compilation”
category, final counts under the “Counts summary” category, and
statistics under the “Statistics” category.
</li><li> “Auto save files”. If this box is checked, all modified files are
automatically saved without asking before running
AdaControl. Otherwise, a dialog appears allowing the user to choose
which files to save.
</li><li> “Buttons operate on”. This defines the behaviour of the buttons.
If “Current File” is selected, the buttons operate on the file being
currently edited. If “Root Project” is selected, the buttons operate
on all files that are part of the current project. If “Units from List”
is selected, the buttons operate on all units from the units file.
</li><li> “Display AdaControl run”. If this box is checked, the command line used
to launch AdaControl and the output messages are displayed in the “Messages”
window.
</li><li> “Max allowed error messages”. If non zero, run will stop if the
number of error messages exceeds this limit. See <a href="#Output-limits">Output limits</a>.
</li><li> “Max allowed messages (all kinds)”. If non zero, run will stop if
the number of error and warning messages exceeds this
limit. See <a href="#Output-limits">Output limits</a>.
</li></ul>
<hr>
<a name="AdaControl-language"></a>
<div class="header">
<p>
Next: <a href="#AdaControl-help" accesskey="n" rel="next">AdaControl help</a>, Previous: <a href="#AdaControl-preferences" accesskey="p" rel="prev">AdaControl preferences</a>, Up: <a href="#Running-AdaControl-from-GPS" accesskey="u" rel="up">Running AdaControl from GPS</a> </p>
</div>
<a name="AdaControl-language-1"></a>
<h4 class="subsection">3.7.5 AdaControl language</h4>
<p>If you check “AdaControl” in the “Languages” tab of the project
properties, GPS will recognize files with extension <code>.aru</code> as
AdaControl command files, and provide appropriate colorization. Remember
to check also the corresponding “no compiler” checkbox to avoid
spurious messages from GPS.
</p>
<hr>
<a name="AdaControl-help"></a>
<div class="header">
<p>
Next: <a href="#Caveat" accesskey="n" rel="next">Caveat</a>, Previous: <a href="#AdaControl-language" accesskey="p" rel="prev">AdaControl language</a>, Up: <a href="#Running-AdaControl-from-GPS" accesskey="u" rel="up">Running AdaControl from GPS</a> </p>
</div>
<a name="AdaControl-help-1"></a>
<h4 class="subsection">3.7.6 AdaControl help</h4>
<p>The AdaControl User Manual (this manual) and the AdaControl
Programmer Manual are available from the "Help/AdaControl" menu of GPS.
</p>
<p>The "Help on rule" entry displays the list of all rules; if you click
on one of them, you get help for the particular rule. Depending on the
setting of the “Help on rule” preference (see above), it opens a
pop-up that displays the rule(s) purpose and the syntax of its
parameters, or opens the user guide at the appropriate location.
</p>
<p>The “About” entry displays a popup with AdaControl’s version number
and license condition.
</p>
<hr>
<a name="Caveat"></a>
<div class="header">
<p>
Previous: <a href="#AdaControl-help" accesskey="p" rel="prev">AdaControl help</a>, Up: <a href="#Running-AdaControl-from-GPS" accesskey="u" rel="up">Running AdaControl from GPS</a> </p>
</div>
<a name="Caveat-1"></a>
<h4 class="subsection">3.7.7 Caveat</h4>
<p>GPS may crash when the output of a command is too big (i.e. hundreds
of messages with AdaControl). If this happens, use the
“preferences” menu to limit the number of messages.
</p>
<hr>
<a name="Running-AdaControl-from-AdaGide"></a>
<div class="header">
<p>
Next: <a href="#Integrating-AdaControl-into-GNATDashboard" accesskey="n" rel="next">Integrating AdaControl into GNATDashboard</a>, Previous: <a href="#Running-AdaControl-from-GPS" accesskey="p" rel="prev">Running AdaControl from GPS</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Running-AdaControl-from-AdaGide-1"></a>
<h3 class="section">3.8 Running AdaControl from AdaGide</h3>
<p>If you want to use AdaControl from AdaGide, make sure you have copied
the necessary file into the required place. See <a href="#Installing-support-for-AdaGide">Installing support for AdaGide</a>. Note that AdaGide does not have all the parameterization
facilities of sophisticated environments like GPS, but all AdaControl
options, like the name of the command file or the output format, can
easily be changed by editing the tool description file
<code>AdaControl.tdf</code>.
</p>
<p>AdaGide now features several AdaControl commands from the “tool” menu:
</p><ul>
<li> “AdaControl” runs AdaControl on the currently
edited file, with rules taken from the file named <code>verif.aru</code>.
</li><li> “AdaControl recursive” works like the previous command, with the
addition of the “-r” (recursive) option. When used on the main
program, it will analyze the whole set of compilation units in the
program.
</li><li> “AdaControl interactive” runs AdaControl on the currently
edited file, with a rule asked interactively from a pop-up.
</li><li> “AdaControl: delete .adt” removes existing tree files from the
current directory. This is convenient when AdaControl complains that
the tree files are not up-to-date.
</li></ul>
<hr>
<a name="Integrating-AdaControl-into-GNATDashboard"></a>
<div class="header">
<p>
Next: <a href="#Helpful-utilities" accesskey="n" rel="next">Helpful utilities</a>, Previous: <a href="#Running-AdaControl-from-AdaGide" accesskey="p" rel="prev">Running AdaControl from AdaGide</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Integrating-AdaControl-into-GNATDashboard-1"></a>
<h3 class="section">3.9 Integrating AdaControl into GNATDashboard</h3>
<p>Once GNATDashboard support is installed, AdaControl is usable like any
other tool that comes with GNATDashboard. The name of the plug-in is
“adacontrol”. It can be given either on the command line of
<code>gnathub</code> or in the “Plugins” attribute of the “Dashboard”
package of a project file.
</p>
<p>Extra options for AdaControl can be given using the
“–targs:adacontrol” option of gnathub. However, the simplest way to
give fundamental options is to give a units file and the command file in
the project file: in the absence of explicit parameters on the command
line, these will be taken by default.
</p>
<p>AdaControl installs a non-default profile called “AdaControl way”
that contains all AdaControl rules. Use it to activate the rules you
need. You can also make it inherit from “GNATdashboard way” if you
want to use AdaControl with other GNAT tools.
</p>
<hr>
<a name="Helpful-utilities"></a>
<div class="header">
<p>
Next: <a href="#Optimizing-Adacontrol" accesskey="n" rel="next">Optimizing Adacontrol</a>, Previous: <a href="#Integrating-AdaControl-into-GNATDashboard" accesskey="p" rel="prev">Integrating AdaControl into GNATDashboard</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Helpful-utilities-1"></a>
<h3 class="section">3.10 Helpful utilities</h3>
<p>This section describe utilities that are handy to use in conjunction
with AdaControl.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#pfni" accesskey="1">pfni</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#adactl_005ffix" accesskey="2">adactl_fix</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#makepat_002esed" accesskey="3">makepat.sed</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#unrepr_002esed" accesskey="4">unrepr.sed</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="pfni"></a>
<div class="header">
<p>
Previous: <a href="#Helpful-utilities" accesskey="p" rel="prev">Helpful utilities</a>, Up: <a href="#Helpful-utilities" accesskey="u" rel="up">Helpful utilities</a> </p>
</div>
<a name="pfni-1"></a>
<h4 class="subsection">3.10.1 pfni</h4>
<p>The convention used to refer to entities (as described in
<a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>) is very powerful, but it may be
difficult to spell out correctly the name of some entities, especially
when using the overloaded syntax.
</p>
<p><code>pfni</code> (which stands for <i>Print Full Name Image</i>) can be used
to get the correct spelling for any Ada entity. The syntax of
<code>pfni</code> is:
</p><div class="example">
<pre class="example">pfni [-sofdq] [-p <project-file>] <unit>[:<span>]
[-- <ASIS options>]
<span> ::= <line_number>
| [<first_line>]-[<last_line>]
| <line_number>:<column_number>
</pre></div>
<p>or
</p><div class="example">
<pre class="example">pfni -h
</pre></div>
<p>If called with the “-h” option, <code>pfni</code> prints a help message
and exits.
</p>
<p>Otherwise, <code>pfni</code> prints the full name image of all identifiers
declared in the indicated unit, unless there is a “-f” (full)
option, in which case it prints the full name image of all identifiers
(i.e. including those that are used, but not declared, in the
unit). The image is printed without overloading information, unless
the “-o” option is given.
</p>
<p>In addition, <code>pfni</code> prints the initial value of variables if
there is one, the range of discrete types, and the range of the
indices of array types.
</p>
<p>The <unit> is given either as an Ada unit, or as a file name, provided
the extension is “.ads” or “.adb” (as in AdaControl). If a span is
given, only identifiers within the span are printed. In the first
form, the span includes only the indicated line; in the second form,
the span includes all lines from <first_line> to <last_line> (if
omitted, they are taken as the first and last line of the file,
respectively). In the third form, the span includes only the place at
the specified <line_number> and <column_number>.
</p>
<p>Normally, the source line corresponding to the names is printed above
the names. The “-q” (quiet) option suppresses this.
</p>
<p>If the “-s” option is given (or the unit is a file name with a
“.ads” extension), the specification of the unit is processed,
otherwise the body is processed. The “-p” option specifies the name
of a project file (“.gpr” or “.adp”), and the “-d” option is the
debug mode, as for AdaControl itself. ASIS options can be passed, like
for AdaControl, after a “-<!-- /@w -->-” (but -FS is the
default). See <a href="#ASIS-options">ASIS options</a>.
</p>
<p>As a side usage of <code>pfni</code>, if you are calling a subprogram that
has several overloadings and you are not sure which one is called, use
<code>pfni</code> with the “-o” option on that line: the program will tell
you the full name and profile of the called subprogram.
</p>
<hr>
<a name="adactl_005ffix"></a>
<div class="header">
<p>
Next: <a href="#makepat_002esed" accesskey="n" rel="next">makepat.sed</a>, Previous: <a href="#pfni" accesskey="p" rel="prev">pfni</a>, Up: <a href="#Helpful-utilities" accesskey="u" rel="up">Helpful utilities</a> </p>
</div>
<a name="adactl_005ffix-1"></a>
<h4 class="subsection">3.10.2 adactl_fix</h4>
<p><code>adactl_fix</code> is a utility that applies automatically the fixes
generated by AdaControl. See <a href="#Fixing-violations">Fixing violations</a> for details.
</p>
<hr>
<a name="makepat_002esed"></a>
<div class="header">
<p>
Next: <a href="#unrepr_002esed" accesskey="n" rel="next">unrepr.sed</a>, Previous: <a href="#adactl_005ffix" accesskey="p" rel="prev">adactl_fix</a>, Up: <a href="#Helpful-utilities" accesskey="u" rel="up">Helpful utilities</a> </p>
</div>
<a name="makepat_002esed-1"></a>
<h4 class="subsection">3.10.3 makepat.sed</h4>
<p>This file (provided in the “src” directory) is a sed script that
transforms a text file into a set of correponding regular expressions.
It is useful to generate model header files. See <a href="#Header_005fComments">Header_Comments</a>.
</p>
<hr>
<a name="unrepr_002esed"></a>
<div class="header">
<p>
Previous: <a href="#makepat_002esed" accesskey="p" rel="prev">makepat.sed</a>, Up: <a href="#Helpful-utilities" accesskey="u" rel="up">Helpful utilities</a> </p>
</div>
<a name="unrepr_002esed-1"></a>
<h4 class="subsection">3.10.4 unrepr.sed</h4>
<p>This file (provided in the “src” directory) is a sed script that
comments out all representation clauses. It is typically useful if you
use a different compiler that accepts representation clauses not
supported by GNAT.
</p>
<p>Typically, you would copy all your sources in a different directory,
copy “unrepr.sed” in that directory, then run:
</p><div class="example">
<pre class="example">sed -i -f unrepr.sed *.ads *.adb
</pre></div>
<p>You can now run AdaControl on the patched files. Of course, you won’t
be able to check rules related to representation clauses any more...
</p>
<p>Note that the script adds “-<!-- /@w -->-UNREPR ” to all representation
clauses. Its effect can thus easily be undone with the following
commad:
</p><div class="example">
<pre class="example">sed -i -e "s/--UNREPR //" *.ads *.adb
</pre></div>
<hr>
<a name="Optimizing-Adacontrol"></a>
<div class="header">
<p>
Next: <a href="#In-case-of-trouble" accesskey="n" rel="next">In case of trouble</a>, Previous: <a href="#Helpful-utilities" accesskey="p" rel="prev">Helpful utilities</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="Optimizing-Adacontrol-1"></a>
<h3 class="section">3.11 Optimizing Adacontrol</h3>
<p>There are many factors that may influence dramatically the speed of
AdaControl when processing many units. For example, on our canonical
test (same controls, same units), the extreme points for execution time
were 111s. vs 13s.! Unfortunately, this seems to depend on a number of
parameters that are beyond AdaControl’s control, like the relative
speed of the CPU to the speed of the hard-disk, or the caching
strategy of the file system.
</p>
<p>This section will give some hints that may help you increase the speed
of AdaControl, but it will not change the output of the program; you
don’t really need to read it if you just use AdaControl
occasionnally. This section is concerned only with the GNAT
implementation of ASIS; other implementations work differently.
</p>
<p>Bear in mind that the best strategy depends heavily on how your
program is organized, and on the particular OS and hardware you are
using. Therefore, no general rule can be given, you’ll have to
experiment yourself. Hint: if you specify the “-v” option to
AdaControl, it will print in the end the elapsed time for running the
tests; this is very helpful to make timing comparisons.
</p>
<p>Note: all options described in this section are ASIS options,
i.e. they must appear last on the command line, after a “-<!-- /@w -->-”.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Tree-files-and-the-ASIS-context" accesskey="1">Tree files and the ASIS context</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Generating-tree-files-manually" accesskey="2">Generating tree files manually</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Choosing-an-appropriate-combination-of-options" accesskey="3">Choosing an appropriate combination of options</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Tree-files-and-the-ASIS-context"></a>
<div class="header">
<p>
Next: <a href="#Generating-tree-files-manually" accesskey="n" rel="next">Generating tree files manually</a>, Previous: <a href="#Optimizing-Adacontrol" accesskey="p" rel="prev">Optimizing Adacontrol</a>, Up: <a href="#Optimizing-Adacontrol" accesskey="u" rel="up">Optimizing Adacontrol</a> </p>
</div>
<a name="Tree-files-and-the-ASIS-context-1"></a>
<h4 class="subsection">3.11.1 Tree files and the ASIS context</h4>
<p>Since AdaControl is an ASIS application, it is useful to explain here
how ASIS works. ASIS (and therefore AdaControl) works on a set of
units constituting a “context”. Any reference to an Ada entity which
is not in the context (nor automatically added, see below) will be
ignored; especially, if you specify to AdaControl the name of a unit
which is not included in the current context, the unit will simply not
be processed.
</p>
<p>ASIS works by exploring tree files (same name as the corresponding Ada
unit, with a “.adt” extension), which are “predigested” views of
the corresponding Ada units. By default, the tree files are generated
automatically when needed, and kept after each run, so that subsequent
runs do not have to recreate them.
</p>
<p>A context in ASIS-for-Gnat is a set of tree files. Which trees are
part of the context is defined by the “-C” option:
</p><ul>
<li> -C1 Only one tree makes up the context. The name of the tree file must
follow the option.
</li><li> -CN Several explicit trees make up the context. The name of the tree
files must follow the option.
</li><li> -CA All available trees make up the context. These are the tree files
found in the current directory, and in any directory given with a
“-T” option (which works like the “-I” option, but for tree files
instead of source files).
</li></ul>
<p>The “-F” option specifies what to do if the program tries to access
an Ada unit which is not part of the context:
</p><ul>
<li> -FT Only consider tree files, do not attempt to compile units
on-the-fly
</li><li> -FS Always compile units on-the-fly, ignore existing tree files
</li><li> -FM Compile on-the-fly units for which there is no already existing
tree file
</li></ul>
<p>Note that “-FT” is the only allowed mode, and <i>must</i> be specified,
with the “-C1” and “-CN” options.
</p>
<p>The default combination used by AdaControl is “-CA -FM”. A
consequence of this is that the context is established by first
loading all available tree files before starting the analysis, even
those that are not necessary. Since tree files are often big and long
to load, if you want to check a single unit and have remaining trees
from a previous run, it is often more efficient to delete all “.adt”
files first.
</p>
<p>More generally, given the current speed of CPUs and the not-so-fast
access time of disks, it may happen that recomputing the trees instead
of loading them from disk might be faster. Only experiencing will tell
you the best procedure to follow.
</p>
<hr>
<a name="Generating-tree-files-manually"></a>
<div class="header">
<p>
Next: <a href="#Choosing-an-appropriate-combination-of-options" accesskey="n" rel="next">Choosing an appropriate combination of options</a>, Previous: <a href="#Tree-files-and-the-ASIS-context" accesskey="p" rel="prev">Tree files and the ASIS context</a>, Up: <a href="#Optimizing-Adacontrol" accesskey="u" rel="up">Optimizing Adacontrol</a> </p>
</div>
<a name="Generating-tree-files-manually-1"></a>
<h4 class="subsection">3.11.2 Generating tree files manually</h4>
<p>It is also possible to generate the tree files manually before running
AdaControl. Although this mode of operation is less practical, it is
recommended by AdaCore for any ASIS tool that deals with many
compilation units. Some reasons why you might want to generate the
tree files manually are:
</p><ul>
<li> Your project has several source directories (ASIS had problems with
ADA_INCLUDE_PATH, until releases dated later than Sept. 1st,
2006). Note that an alternative solution is to provide a project file
with the -p option, or to specify source directories with the -I
option;
</li><li> Your project uses some compilation options that cannot be set
otherwise (AdaControl just uses the “source_dirs” from GPR projects,
not other options)
</li><li> It is faster to generate tree files once than to use “compile on the
fly” mode.
</li></ul>
<p>To generate tree files manually, simply recompile your project with
the “-gnatct” option. This option can be passed to <code>gnatmake</code>
or <code>gprbuild</code> normally. Of course, you will need all other
options needed by your project (like the “-P” option if you are
using GNAT project files).
</p>
<p>Tree files may be copied into a different directory if you don’t want
your current directory to be cluttered by them. In this case, use the
“-T” ASIS option to indicate the directory where the tree files are
located.
</p>
<p>If you chose to generate the tree files manually, you may want to
specify the “-FT” ASIS option (see above) to prevent from accidental
automatic recompilation.
</p>
<hr>
<a name="Choosing-an-appropriate-combination-of-options"></a>
<div class="header">
<p>
Previous: <a href="#Generating-tree-files-manually" accesskey="p" rel="prev">Generating tree files manually</a>, Up: <a href="#Optimizing-Adacontrol" accesskey="u" rel="up">Optimizing Adacontrol</a> </p>
</div>
<a name="Choosing-an-appropriate-combination-of-options-1"></a>
<h4 class="subsection">3.11.3 Choosing an appropriate combination of options</h4>
<p>In order to optimize the use of AdaControl, it is important to
remember that reading tree files is a time-consuming operation. On the
other hand, a single tree file contains not only information for the
corresponding unit, but also for the <i>specifications</i> of all units
that the given unit depends on. Moreover, our measures showed that
reading an existing tree file may be <i>slower</i> than compiling the
corresponding unit on-the-fly (but once again, YMMV).
</p>
<p>Here are some hints to help you find the most efficient combination of
options.
</p><ul>
<li> If you want to run AdaControl on all units of your program, use the
“-D” option to create a file containing the list of all required
units, then use this file as an indirect file. Using the the “-r”
option (recursive mode) of AdaControl implies an extra pass over the
whole program tree to determine the necessary units.
</li><li> If you have not disabled any rule (and have many messages), specifying
the “-i” option (ignore disabling) saves AdaControl the burden of
checking whether rules are disabled, which can result in a
sensible speed-up.
</li><li> Avoid having unnecessary tree files. All tree files in the context are
read by ASIS, even if they are not later used. If you don’t want to
run AdaControl on the whole project, deleting tree files from a
previous run can save a lot of time.
</li><li> When using an indirect file, the order in which units are given may
influence the speed of the program. As a rule of thumb, units that are
closely related should appear close to each other in the file. A good
starting point is to sort the file in alphabetical order: this way,
child units will appear immediately after their parent. You can then
reorder units, and measure if it has a significant effect on speed.
</li><li> If you want to check a unit individually, try using the “-C1” option
(especially if the current directory contains many tree files from
previous runs). Remember that you must specify the unit to check to
AdaControl, and the tree file to ASIS. I.e., if you want to check the
unit “Example”, the command line should look like:
<div class="example">
<pre class="example">adactl -f rules_file.aru example -- -FT -C1 example.adt
</pre></div>
<p>provided the tree file already exists.
</p></li><li> For each strategy, first run AdaControl with the default options
(which will create all necessary tree files). Compare execution time
with the one you get with “-FT” and “-FS”. This will tell you if
compiling on-the-fly is more efficient than loading tree files, or not.
</li></ul>
<hr>
<a name="In-case-of-trouble"></a>
<div class="header">
<p>
Previous: <a href="#Optimizing-Adacontrol" accesskey="p" rel="prev">Optimizing Adacontrol</a>, Up: <a href="#Program-Usage" accesskey="u" rel="up">Program Usage</a> </p>
</div>
<a name="In-case-of-trouble-1"></a>
<h3 class="section">3.12 In case of trouble</h3>
<a name="Known-issues"></a>
<h4 class="subsection">3.12.1 Known issues</h4>
<p>If you are using an old version of GNAT and your project includes
source files located in several directories, the ADA_INCLUDE_PATH
environment variable may not be considered by ASIS, resulting in error
messages that tell you that the bodies of some units have not been
found (and hence have not been processed). This problem has been fixed
in GNAT dated later than Sept. 1st, 2006. If this happens, either
provide your source directories as “-I” options (see <a href="#ASIS-options">ASIS options</a>), or generate the tree files manually (see <a href="#Generating-tree-files-manually">Generating tree files manually</a>). Note that this problem does not happen if you are
using a project file (see <a href="#Project-files">Project files</a>), nor if you are
running AdaControl from GPS.
</p>
<a name="AdaControl-or-ASIS-failure"></a>
<h4 class="subsection">3.12.2 AdaControl or ASIS failure</h4>
<p>Like any sophisticated piece of software, AdaControl may fail when
encountering some special case of construct. ASIS may also fail
occasionnally; actually, we discovered several ASIS bugs during the
development of AdaControl. These were reported to ACT, and have been
corrected in the wavefront version of GNAT - but you may be using an
earlier version. In this case, try to upgrade to a newer version of
ASIS. If an AdaControl or ASIS problem is not yet solved, AdaControl
is designed in such a way that an occasionnal bug won’t prevent you
from using it.
</p>
<p>If AdaControl detects an unexpected exception during the processing of
a unit (an ASIS error or an internal error), it will abandon the unit,
clean up everything, and go on processing the remaining units. This
way, an error due to a special case in a unit will <i>not</i> affect the
processing of other units. AdaControl will return a Status of 10 in
this case.
</p>
<p>However, if it is run with the “-x” option (eXit on error), it will
stop immediately, and no further processing will happen.
</p>
<p>If you don’t want the garbage from a failing rule to pollute your
report, you may chose to disable the rule for the unit that has a
problem. See <a href="#Inhibit-command">Inhibit command</a>.
</p>
<p>If you encounter a problem while using AdaControl, you are very
welcome to report it through our
<a href="https://sourceforge.net/p/adacontrol/tickets/">bug tracking
system</a> (under Windows, you can click on “Report problem” in the
AdaControl Start menu). Please include the exact control and the unit
that caused the problem, as well as the captured output of the program
(with “-dx” option).
</p>
<hr>
<a name="Command-language-reference"></a>
<div class="header">
<p>
Next: <a href="#Rules-reference" accesskey="n" rel="next">Rules reference</a>, Previous: <a href="#Program-Usage" accesskey="p" rel="prev">Program Usage</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> </p>
</div>
<a name="Command-language-reference-1"></a>
<h2 class="chapter">4 Command language reference</h2>
<p>AdaControl is about <i>controlling rules</i>. <i>Rules</i> are built in
AdaControl; each rule has a name, and may require parameters. For the
complete description of each rule, see <a href="#Rules-reference">Rules reference</a>.
</p>
<p>To run AdaControl, you need to define which rules you want to apply to
your Ada units, what are the parameters, etc. In addition, you may
want to define various things, like the file where the results should
go, the output format, etc.
</p>
<p>AdaControl defines a small command language which is used to describe
how you want to process your units. Commands can be specified either
on the command line or in a file, that we call here a rules
file. Commands can also be given interactively; See <a href="#Interactive-mode">Interactive mode</a>.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#General" accesskey="1">General</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Controls" accesskey="2">Controls</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Other-commands" accesskey="3">Other commands</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Example-of-commands" accesskey="4">Example of commands</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="General"></a>
<div class="header">
<p>
Next: <a href="#Controls" accesskey="n" rel="next">Controls</a>, Previous: <a href="#Command-language-reference" accesskey="p" rel="prev">Command language reference</a>, Up: <a href="#Command-language-reference" accesskey="u" rel="up">Command language reference</a> </p>
</div>
<a name="General-1"></a>
<h3 class="section">4.1 General</h3>
<p>The command language is not case-sensitive, i.e. the case of the
keywords, rule names, and parameters is not significant. The layout
of commands is free (i.e. a command can extend over several lines, and
spaces are freely allowed between syntactic elements).
</p>
<p>Comments are allowed in and between commands. Comments begin with a
“#” or a “-<!-- /@w -->-”, and extend to the end of the line.
</p>
<p>Since wide characters are allowed in Ada programs, AdaControl accepts
wide characters in commands as well. With GNAT, the encoding scheme is
Hex ESC encoding (see the GNAT User-Guide/Reference-Manual). This is
the prefered method, since few people require wide characters in
programs anyway, and that keeping the default bracket encoding would
not conveniently allow brackets for regular expressions, like those
used by some rules. See <a href="#Syntax-of-regular-expressions">Syntax of regular expressions</a>.
</p>
<p>If a syntax error is encountered in a command, an appropriate error
message is output, and analysis of the command file continues in order
to output all errors, but no analysis of user code will be performed.
</p>
<hr>
<a name="Controls"></a>
<div class="header">
<p>
Next: <a href="#Other-commands" accesskey="n" rel="next">Other commands</a>, Previous: <a href="#General" accesskey="p" rel="prev">General</a>, Up: <a href="#Command-language-reference" accesskey="u" rel="up">Command language reference</a> </p>
</div>
<a name="Controls-1"></a>
<h3 class="section">4.2 Controls</h3>
<p>A <i>control command</i> is a command that declares one (or several)
controls. A control defines how a rule is applied to Ada units. The
syntax of a control command is as follows:
</p><div class="example">
<pre class="example"><control_command> ::= [<label> ":"] <control> {"," <control>} ";"
<control> ::= <ctrl_kind> <Rule_Name> [<parameters>]
<parameters> ::= "(" [<modifiers>] <value>
{"," [<modifiers>] <value>} ")"
<ctrl_kind> ::= "check"|"search"|"count"
</pre></div>
<p>If present, the label gives a name to the control(s); it will be
printed whenever each control is activated, and can be used to disable
the control(s). See <a href="#Disabling-controls">Disabling controls</a>. If no label is present,
the rule name is printed instead. The label must have the syntax of an
Ada identifier, or else the label must be included within double
quotes (<code>"</code>), in which case it can contain any character.
</p>
<p>Each control consists of a <ctrl_kind> followed by a rule name, and
(optionally) parameters. Some parameters may be preceded by modifiers
(such as “not” or “case_sensitive”). The meaning of the rule
parameters and modifiers depends on the rule.
</p>
<p>Here are some examples of commands:
</p><div class="example">
<pre class="example">check unnecessary_use_clause;
All_Imports: search pragmas (Import);
"Why do you need that?": check entities (Unchecked_Conversion,
all 'Address);
</pre></div>
<p>Specifying several controls with the same label is a shorthand which
is equivalent to specifying the same label for several controls. It is
handy when the label is long, and/or to stress that several controls are
part of the same programming rule. For example:
</p><div class="example">
<pre class="example">"Check why this obsolete stuff is still used":
check entities (obsolete_unit_1), -- Note comma here!
check instantiations (some_obsolete_generic);
</pre></div>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Control-kinds-and-report-messages" accesskey="1">Control kinds and report messages</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Parameters" accesskey="2">Parameters</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Multiple-controls" accesskey="3">Multiple controls</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Disabling-controls" accesskey="4">Disabling controls</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Control-kinds-and-report-messages"></a>
<div class="header">
<p>
Next: <a href="#Parameters" accesskey="n" rel="next">Parameters</a>, Previous: <a href="#Controls" accesskey="p" rel="prev">Controls</a>, Up: <a href="#Controls" accesskey="u" rel="up">Controls</a> </p>
</div>
<a name="Control-kinds-and-report-messages-1"></a>
<h4 class="subsection">4.2.1 Control kinds and report messages</h4>
<p>There are three control kinds: “check”, “search”, and “count”.
</p>
<p>“Check” is intended to search for rules that must be obeyed in your
programs. Normally, if a “Check” control fails, you should fix the
program. “Search” is intended to report some situations, but you
should consider what to do on a case-by-case basis. Roughly, use
“check” when you consider that the failure of the control is an
error, and “search” when you consider it as a warning. AdaControl
will exit with a status of 1 if any “Check” control is triggered,
and a status of 0 if only “Search” controls were triggered (or no
control was triggered at all).
</p>
<p>“Count” works like “Search”, but instead of printing a message for
each control which is triggered, it simply counts occurrences and prints
a summary at the end of the run. There is a separate count for each
control label (or if no label is given, the rule name is taken instead);
if you give the same label to different controls, this allows you to
accumulate the counts.
</p>
<p>A report message (except for the final report of “count”) comprises
the following elements:
</p><ul>
<li> the file name (where the control matches)
</li><li> the line number (where the control matches)
</li><li> the column number (where the control matches)
</li><li> the label (if there is one) and/or the rule name (the rule that matches).
</li><li> a message (why the control matches). A control whose kind is “check”
will produce an error report message (i.e. containing the keyword
“Error”) and a control whose kind is “search” will produce a
found report message (i.e. containing the keyword “Found”).
</li></ul>
<p>The formatting of the report message depends on the format option,
which can be selected with the “-F” command-line option or the “set
format” command.
</p>
<p>If the format is “Gnat” (the default) or “Gnat_Short”, items are
separated by ’:’; this is the same format as the one used by GNAT
error messages. Editors (like Emacs or GPS) that recognize this format
allow you to go directly to the place of the message by clicking on
it. In order to avoid too long messages, only the label appears,
unless there is none, in which case it is replaced with the rule
name.
</p>
<p>If the format is “CSV” or “CSV_Short”, items are separated by ’,’
and surrounded by double quotes. This is the “Comma Separated
Values” format, which can be read by any known spreadsheet program,
except Excel(tm) by default, which uses the semicolon and not the
comma to separate fields. Therefore, the formats “CSVX” and
“CSVX_Short” do the same thing, but using semi-colons (’;’) instead
of commas. Both the label (replaced by an empty column if there is
none) and the rule name appear. Note that when an output file is
created in one of the “CSV” formats, a title line is issued as the
first line, following normal CSV convention.
</p>
<p>If the format is “Source” or “Source_Short”, the offending source
line is output, and the message is output behind it, with a “!”
pointing to the exact location of the problem.
</p>
<p>If the format is “None”, no error message is output at all. This is
useful when only the return code of running AdaControl is desired
(just to check if a program is OK or not). Note that this does <i>not</i>
prevent the output of statistics, since these are under control of the
“-S” option or the “set statistics” command. In this case,
statistics are output in CSVX format, since asking for statistics with
a “none” format is mainly useful for analysing the statistics with a
spreadsheet program.
</p>
<p>With recent versions of GNAT, the file name includes the full path of
the source file. If the “_Short” form of the format option is used,
the file name is stripped from any path. This can make it easier to
compare the results of controlling units from various directories.
Note that with older versions of GNAT, the file name never includes
the full path, and the “_Short” form of the format option has no
effect.
</p>
<p>After each run (see <a href="#Go-command">Go command</a>), statistics may be output,
depending on the statistics level which is set with the “-S” option
or the “set statistics” command. The meaning of the various levels
is as follows:
</p><ul>
<li> 0: No statistics are output (default)
</li><li> 1: A count of units, (raw) lines, error and warning messages is output
</li><li> 2: The rule name and label (if any) of any control <i>not</i> triggered are
output
</li><li> 3: The rule name and label (if any) of every control is output,
together with a count of each triggering kind (“check”, “search”,
“count”), or “not triggered” if the control was not triggered.
</li></ul>
<hr>
<a name="Parameters"></a>
<div class="header">
<p>
Next: <a href="#Multiple-controls" accesskey="n" rel="next">Multiple controls</a>, Previous: <a href="#Control-kinds-and-report-messages" accesskey="p" rel="prev">Control kinds and report messages</a>, Up: <a href="#Controls" accesskey="u" rel="up">Controls</a> </p>
</div>
<a name="Parameters-1"></a>
<h4 class="subsection">4.2.2 Parameters</h4>
<p>Most rules accept parameters. Parameters can be:
</p><ul>
<li> a keyword for the rule
</li><li> a numerical value
</li><li> a character string (often a regular expression)
</li><li> an Ada entity name
</li></ul>
<p>A numerical value is given with the syntax of an Ada integer or real
literal (underscores and exponents are allowed as in Ada). Based
literals are supported for integer values; if somebody can justify a
need for supporting them for reals, we’ll be happy to add this feature
later...
</p>
<p>A character string is given within double quotes “"”. As usual, quotes
appearing within the string are doubled. The tilde character (“~”) can be
used as a replacement delimiter, but the same character must be used at both
ends of the string. The latter has been chosen as a character not used
by the various shells, and can be useful to pass quoted strings from
parameters on the command line (unfortunately, we could not use the
percent (“%”) sign, because it plays a special role in DOS/Windows).
</p>
<p>An Ada entity name is the full name (prefixed with the names of all
units that include it) of something declared in a program. It can be
followed by overloading information, in order to uniquely identify the
Ada entity. If an Ada entity is overloaded and no overloading
information is provided, the rule is applied to all (overloaded) Ada
entities that match the name. Alternatively, it can be “all”
followed by a simple name, in wich case it applies to all entities
with that name. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a> for the full
description of the syntax. Here are some examples of entity names:
</p><div class="example">
<pre class="example">Ada.Text_IO.Put -- All Put defined in Ada.Text_IO
Ada.Text_IO.Put{Standard.Character} -- The Put on Character
all Put -- All Put
Standard.Integer'Image -- The 'Image function on Integer
all 'Image -- All 'Image functions
</pre></div>
<hr>
<a name="Multiple-controls"></a>
<div class="header">
<p>
Next: <a href="#Disabling-controls" accesskey="n" rel="next">Disabling controls</a>, Previous: <a href="#Parameters" accesskey="p" rel="prev">Parameters</a>, Up: <a href="#Controls" accesskey="u" rel="up">Controls</a> </p>
</div>
<a name="Multiple-controls-1"></a>
<h4 class="subsection">4.2.3 Multiple controls</h4>
<p>Most rules can be used in more than one control (with different
parameters). There is no difference between a single or a multiple
configuration rule use: outputs, efficiency, etc. are the same.
</p>
<p>The following command files produce an identical configuration:
</p><div class="example">
<pre class="example">Search Pragmas (Pure, Elaborate_All);
</pre></div>
<p>and
</p><div class="example">
<pre class="example">Search Pragmas (Pure);
Search Pragmas (Elaborate_All);
</pre></div>
<p>However, the second form can be used to give different labels. Consider:
</p><div class="example">
<pre class="example">Search Pragmas (Pure);
No_Elaborate: Search Pragmas (Elaborate_All);
</pre></div>
<p>The messages for pragma <code>Pure</code> will contain “PRAGMAS”, while
those for <code>Elaborate_All</code> will contain “No_Elaborate”. If a
disabling comment mentions <code>pragmas</code>, it will disable both controls,
but a disabling comment that mentions <code>No_Elaborate</code> will disable
only the second one.
</p>
<hr>
<a name="Disabling-controls"></a>
<div class="header">
<p>
Previous: <a href="#Multiple-controls" accesskey="p" rel="prev">Multiple controls</a>, Up: <a href="#Controls" accesskey="u" rel="up">Controls</a> </p>
</div>
<a name="Disabling-controls-1"></a>
<h4 class="subsection">4.2.4 Disabling controls</h4>
<p>It is possible to disable controls on parts of the source code by
placing markers in the source code. A marker is an Ada comment, where
the comment mark (<code>--</code>) is immediately followed by the special
tag “<code>##</code>” (by default).
</p>
<p>There are two kinds of markers: block markers and line markers. Both
kinds specify a list of controls to disable/re-enable. A list of
controls is a list of rule names (to disable/re-enable all controls on
the indicated rule(s)) or control labels (to disable/re-enable all
controls with that label), separated by spaces. Alternatively, the
list of controls can be the word “all” to disable/re-enable all
controls.
</p>
<p>In a “<code>--##</code>” line, everything appearing after another “##”
tag (by default) is ignored. This allows the insertion of a comment
explaining why the control is disabled at that point.
</p>
<p>Both tags can be changed with the “set” command. See <a href="#Set-command">Set command</a>.
</p>
<a name="Block-disabling"></a>
<h4 class="subsubsection">4.2.4.1 Block disabling</h4>
<p>A control is disabled from a “rule off” marker that applies to it
until a “rule on” marker that applies to it. If there is no
appropriate “rule on” marker, the control is disabled up to the end
of file.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">--## rule off <control_list>
Ada code block
--## rule on <control_list>
</pre></div>
<p>Ex:
</p><div class="example">
<pre class="example">--## rule off rule1 rule2 ## Authorized by QA ref 1234
I := I + 1;
Proc (I);
--## rule on rule2
</pre></div>
<a name="Line-disabling"></a>
<h4 class="subsubsection">4.2.4.2 Line disabling</h4>
<p>A control is disabled only for the line where a marker that applies to
it appears.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">Ada code line --## rule line off <rule_list>
</pre></div>
<p>Ex:
</p><div class="example">
<pre class="example">I := I + 1; --## rule line off rule3 rule_label_1
</pre></div>
<p>Conversely, it is possible to re-enable a control for just the current
line in a block where it is disabled:
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">Ada code line --## rule line on <rule_list>
</pre></div>
<p>Ex:
</p><div class="example">
<pre class="example">--## rule off rule1 rule2
...
I := I + 1; --## rule line on rule2
</pre></div>
<a name="Limitation-2"></a>
<h4 class="subsection">4.2.5 Limitation</h4>
<p>Since the disabling is based on special comments, there is a conflict
with the rule “header_comments” which is based on the content of
comments. Line disabling is not possible with this rule, and block
disabling needs special care. See <a href="#Header_005fComments">Header_Comments</a>.
</p>
<hr>
<a name="Other-commands"></a>
<div class="header">
<p>
Next: <a href="#Example-of-commands" accesskey="n" rel="next">Example of commands</a>, Previous: <a href="#Controls" accesskey="p" rel="prev">Controls</a>, Up: <a href="#Command-language-reference" accesskey="u" rel="up">Command language reference</a> </p>
</div>
<a name="Other-commands-1"></a>
<h3 class="section">4.3 Other commands</h3>
<p>In addition to controls, AdaControl recognizes a number
of commands. Although these commands are especially useful when using
the interactive mode (see <a href="#Interactive-mode">Interactive mode</a>), they can be used in
command files as well.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Go-command" accesskey="1">Go command</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Quit-command" accesskey="2">Quit command</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Message-command" accesskey="3">Message command</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Help-command" accesskey="4">Help command</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Clear-command" accesskey="5">Clear command</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Set-command" accesskey="6">Set command</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Source-command" accesskey="7">Source command</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Inhibit-command" accesskey="8">Inhibit command</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Go-command"></a>
<div class="header">
<p>
Next: <a href="#Quit-command" accesskey="n" rel="next">Quit command</a>, Previous: <a href="#Other-commands" accesskey="p" rel="prev">Other commands</a>, Up: <a href="#Other-commands" accesskey="u" rel="up">Other commands</a> </p>
</div>
<a name="Go-command-1"></a>
<h4 class="subsection">4.3.1 Go command</h4>
<p>This command starts processing of the controls that have been
specified.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">go;
</pre></div>
<p>Controls are <i>not</i> reset after a “go” command; for example, the
following program:
</p><div class="example">
<pre class="example">search entities (pack1);
go;
search entities (pack2);
go;
</pre></div>
<p>will first output all usages of <code>Pack1</code>, then all usages of both
<code>Pack1</code> and <code>Pack2</code>. See <a href="#Clear-command">Clear command</a> to reset
controls.
</p>
<p>If not in interactive mode, a “go” command is automatically added at
the end, therefore it is not required in command files.
</p>
<hr>
<a name="Quit-command"></a>
<div class="header">
<p>
Next: <a href="#Message-command" accesskey="n" rel="next">Message command</a>, Previous: <a href="#Go-command" accesskey="p" rel="prev">Go command</a>, Up: <a href="#Other-commands" accesskey="u" rel="up">Other commands</a> </p>
</div>
<a name="Quit-command-1"></a>
<h4 class="subsection">4.3.2 Quit command</h4>
<p>This command terminates AdaControl.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">quit;
</pre></div>
<p>If given in a file, all subsequent commands will be ignored. This
command is really useful only in interactive mode. See <a href="#Interactive-mode">Interactive mode</a>.
</p>
<hr>
<a name="Message-command"></a>
<div class="header">
<p>
Next: <a href="#Help-command" accesskey="n" rel="next">Help command</a>, Previous: <a href="#Quit-command" accesskey="p" rel="prev">Quit command</a>, Up: <a href="#Other-commands" accesskey="u" rel="up">Other commands</a> </p>
</div>
<a name="Message-command-1"></a>
<h4 class="subsection">4.3.3 Message command</h4>
<p>This command prints a message on the output file.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">message "<any string>" [pause];
</pre></div>
<p>The length of the message is limited to 250 characters. If the word
“pause” (case irrelevant) is specified after the message, AdaControl
will wait for the user to press the Return key before proceeding.
</p>
<p>Note that the message is syntactically a string, and must therefore be
quoted (double quotes).
</p>
<hr>
<a name="Help-command"></a>
<div class="header">
<p>
Next: <a href="#Clear-command" accesskey="n" rel="next">Clear command</a>, Previous: <a href="#Message-command" accesskey="p" rel="prev">Message command</a>, Up: <a href="#Other-commands" accesskey="u" rel="up">Other commands</a> </p>
</div>
<a name="Help-command-1"></a>
<h4 class="subsection">4.3.4 Help command</h4>
<p>This command prints various informations about the rules and AdaControl
itself.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">Help [<help_item> {,<help_item>}]
<Help_Item> ::=<keyword> | <rule name> | variables ["<pattern>"]
<keyword> ::= all | commands | license | list | options |
rules | version
</pre></div>
<p>Without any argument, this command prints a summary of all commands
and rule names. If given one or more keywords or rule names, it prints the
corresponding help message. See <a href="#Getting-help">Getting help</a> for the details.
</p>
<hr>
<a name="Clear-command"></a>
<div class="header">
<p>
Next: <a href="#Set-command" accesskey="n" rel="next">Set command</a>, Previous: <a href="#Help-command" accesskey="p" rel="prev">Help command</a>, Up: <a href="#Other-commands" accesskey="u" rel="up">Other commands</a> </p>
</div>
<a name="Clear-command-1"></a>
<h4 class="subsection">4.3.5 Clear command</h4>
<p>This command command clears (i.e. removes) controls that have been
previously given.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">Clear all | <rule name>{,<rule name>} ;
</pre></div>
<p>The command clears all controls given for the indicated rules, or for
all rules if the <code>all</code> keyword is given. Rule variables
(see <a href="#Set-command">Set command</a>) associated to cleared rules are returned to
their default values. For example, the following program:
</p><div class="example">
<pre class="example">search entities (pack1);
go;
clear all;
search entities (pack2);
go;
</pre></div>
<p>will first output all usages of <code>Pack1</code>, then all usages of
<code>Pack2</code>. Without the “clear all” command, the second “go”
would output all usages of <code>Pack1</code> together with all usages of
<code>Pack2</code>.
</p>
<hr>
<a name="Set-command"></a>
<div class="header">
<p>
Next: <a href="#Source-command" accesskey="n" rel="next">Source command</a>, Previous: <a href="#Clear-command" accesskey="p" rel="prev">Clear command</a>, Up: <a href="#Other-commands" accesskey="u" rel="up">Other commands</a> </p>
</div>
<a name="Set-command-1"></a>
<h4 class="subsection">4.3.6 Set command</h4>
<p>This command sets various parameters of AdaControl.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">set Format Gnat|Gnat_Short|CSV|CSV_Short|Source|Source_short|None;
set Check_Key|Search_Key "<value>"
set Max_Errors [<value>];
set Max_Messages [<value>];
set Output|New_Output <output file>;
set Fixes_Gen Check|Search|None
set Statistics <level>;
set Tag1|Tag2 "<value>";
set Trace <trace file>;
set Debug|Exit_On_Error|Verbose|Warning|Warning_As_Error
On|Off;
set Timing On|Off|Global
set Ignore On|Off|Inverted;
set <Rule_Name>.<Variable> <Value>
</pre></div>
<p>The “set format” command selects the output format for the messages,
like the “-F” option; see <a href="#Control-kinds-and-report-messages">Control kinds and report messages</a> for
details.
</p>
<p>The “set check_key” command defines a string which is used in place
of “Error” in messages issued by a “check” control. Similarly, the
“set search_key” command defines a string which is used in place of
“Found” in messages issued by a “search” control. This can be
useful when AdaControl is used, for example, to detect places where
manual inspection is required; having the word “Error” in the
message could be misleading to the persons in charge of the
review. Note however that if you set these keys, the GPS interface
will not be able to recognize properly the messages.
</p>
<p>The “set max_errors” and “set max_messages” limit the output of
AdaControl, like the “-m” and “-M” options; see <a href="#Output-limits">Output limits</a> for details. If no <value> is given after the command name,
the corresponding limitation is removed.
</p>
<p>The “set output” and “set new_output” commands redirect the output
of subsequent controls to the indicated file. If the string
<code>console</code> (case irrelevant) is given as the <output file>, output
is redirected to the console.
</p>
<p>The “set fixes_gen” command controls the generation of fixes
indications, like the “-G” option; see <a href="#Output-format">Output format</a> for
details.
</p>
<p>The “set new_output” always create a new file (or overwrites an
existing file with the same name).
</p>
<p>The “set output” command appends if the file exists, unless the
“-w” option is given, in which case it is overwritten. However, the
file is overwritten only the first time it is mentionned in an
“output” command. This means that you can switch forth and back
between two output files, all results from the same run will be
kept. Note however that for this to work, you need to specify the
output files exactly the same way: if you specify it once as
“result.txt”, and then as “./result.txt”, the second one will
overwrite the first one.
</p>
<p>The “set statistics” command sets the statistics level, like the
“-S” option; see <a href="#Control-kinds-and-report-messages">Control kinds and report messages</a> for details.
</p>
<p>The “set Tag1|Tag2” command changes the tags used to disable (or
enable) rules. “Tag1” is the string that appears immediately after
the comment indicator (<code>--</code>), and “tag2” is the tag that
terminates the special comment. Note that these tags must be given as
strings (in quotes) and that case is relevant. See <a href="#Disabling-controls">Disabling controls</a> for details.
</p>
<p>The “set trace” command redirects the trace messages of the
“-d” option to the indicated file. If the string <code>console</code>
(case irrelevant) is given as the <trace file>, trace messages are
redirected to the console. As with the “-t” option, if the file
exists, output is appended to it.
</p>
<p>The “set Debug|Exit_On_Error|Verbose|Warning|Warning_As_Error”
command activates (“on”) or deactivates (“off”) options. “Debug”
corresponds to the “-d” option, “Exit_On_Error” to the “-x”
option, “Ignore” to the “-i” option, “Timing” to the “-T”
option, “Verbose” to the “-v” option, “Warning” to the “-E”
option, and “Warning_As_Error” to the “-e” option. See
<a href="#Verbose-and-debug-mode">Verbose and debug mode</a>, <a href="#Exit-on-error">Exit on error</a>, <a href="#Treatment-of-warnings">Treatment of warnings</a>, <a href="#Output-format">Output format</a>, and <a href="#Local-disabling-control">Local disabling control</a> for
details.
</p>
<p>The “set Timing” command activates (“on”) or deactivates (“off”)
the printing of the time spent in each rule after each “go”
command. If set to “global” instead of “on”, the timings are
accumulated over all “go” commands, and output when the program
terminates.
</p>
<p>The “set Ignore” command governs handling of disabled messages
(see <a href="#Disabling-controls">Disabling controls</a>). In default mode (“set Ignore Off”),
disabled messages are not printed. When set to “on” (“set Ignore
On”), all messages are printed, including those that are
disabled. Setting this option can result in considerable speed-up of
the printing of messages. When set to “Inverted” (“set Ignore
Inverted”), <i>only</i> disabled messages are printed. This is useful to
check which messages have been disabled.
</p>
<p>Some rules may also have user-settable global variables that affect
their behaviour; the last form of the “set” command allows changing
their value. The variable name is of the form of a qualified name
(i.e. “rule.var”), and the value depends on the variable. The
description of the variables (if any) and appropriate values is given
for each rule.
</p>
<hr>
<a name="Source-command"></a>
<div class="header">
<p>
Next: <a href="#Inhibit-command" accesskey="n" rel="next">Inhibit command</a>, Previous: <a href="#Set-command" accesskey="p" rel="prev">Set command</a>, Up: <a href="#Other-commands" accesskey="u" rel="up">Other commands</a> </p>
</div>
<a name="Source-command-1"></a>
<h4 class="subsection">4.3.7 Source command</h4>
<p>This command inputs commands from another file.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">Source <input file>;
</pre></div>
<p>Commands are read and executed from the indicated file, then control
is returned to the place after the “source” command. There is no
restriction on the content of the sourced file; especially, it may
itself include other “source” commands.
</p>
<p>If <input file> is a relative file path, it is taken relatively to the
file where the “source” command is given. Especially, if no path is
specified, the sourced file will be taken from the same directory as
the sourcing file (irrespectively of where the command is being run
from). If the file is not found there, it is searched on the path given
by the environment variable <code>ADACTL_PATH</code>.
</p>
<p>The default extension is <code>.aru</code>, i.e. if <input file> is not
found as given, AdaControl will retry the same name with <code>.aru</code>
appended. It is a syntax error if the file is not found either.
</p>
<p>If the string <code>console</code> (case irrelevant) is given as the <input
file>, commands are read from the console until a “quit” command is
given. This command is of course useful only from files, and allows to
pass temporarily control to the user in interactive mode.
</p>
<hr>
<a name="Inhibit-command"></a>
<div class="header">
<p>
Previous: <a href="#Source-command" accesskey="p" rel="prev">Source command</a>, Up: <a href="#Other-commands" accesskey="u" rel="up">Other commands</a> </p>
</div>
<a name="Inhibit-command-1"></a>
<h4 class="subsection">4.3.8 Inhibit command</h4>
<p>This command prevents execution of certain controls on particular units.
</p>
<p>Syntax:
</p><div class="example">
<pre class="example">Inhibit <rule name>|all ([all] <unit> {,[all] <unit>});
</pre></div>
<p>Controls refering to the given rule (or all rules if “all” is
specified in place of a rule name) for the indicated unit(s) are not
performed. In addition, if “all” is specified in front of the unit
name, the unit will not be accessed at all, even from rules that
follow call graphs, and could thus access this unit while analyzing
other units.
</p>
<p>There are several reasons why you might want to inhibit a control of
a rule for certain units:
</p><ul>
<li> The unit is known not to obey the rule in many places, and you don’t
want the output to be cluttered with too many messages (of course,
you’ll fix the unit in the near future!);
</li><li> The unit is known to obey the rule, execution of the rule is
time-consuming, and you want to save some processing time;
</li><li> The unit is known to raise an ASIS bug, and until you upgrade to the
appropriate version of GNAT, you don’t want to be bothered by the
error messages.
</li></ul>
<p>The “all” option for a unit is intended for the last case, to
prevent ASIS bugs from spoiling any unit that calls something from an
offending unit.
</p>
<hr>
<a name="Example-of-commands"></a>
<div class="header">
<p>
Previous: <a href="#Other-commands" accesskey="p" rel="prev">Other commands</a>, Up: <a href="#Command-language-reference" accesskey="u" rel="up">Command language reference</a> </p>
</div>
<a name="Example-of-commands-1"></a>
<h3 class="section">4.4 Example of commands</h3>
<p>Below is an example of a file with multiple commands:
</p><div class="example">
<pre class="example">message "Searching Unchecked_Conversion";
search entitities (ada.unchecked_conversion);
set output uc_usage.txt;
go;
clear all;
message "Searching 'Address";
search entities (all 'Address);
set output address_usage.txt;
go;
</pre></div>
<p>This file will output all usages of <code>Ada.Unchecked_Conversion</code>
into the file <code>uc_usage.txt</code>, then output all usages of the
<code>'Address</code> attribute into the file
<code>address_usage.txt</code>. Messages are output to tell the user about
what’s happenning.
</p>
<hr>
<a name="Rules-reference"></a>
<div class="header">
<p>
Next: <a href="#Examples-of-using-AdaControl-for-common-programming-rules" accesskey="n" rel="next">Examples of using AdaControl for common programming rules</a>, Previous: <a href="#Command-language-reference" accesskey="p" rel="prev">Command language reference</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> </p>
</div>
<a name="Rules-reference-1"></a>
<h2 class="chapter">5 Rules reference</h2>
<p>This chapter describes each rule currently provided by
AdaControl. Note that the <code>rules</code> directory of the distribution
contains a file named <code>verif.aru</code> that contains an example of a
set of rules appropriate to check on almost any software.
</p>
<p>A general limitation applies to all rules. AdaControl is a <i>static</i>
checking tool, and therefore cannot check usages that depend on
run-time values. For example, it is not possible to check rules
applying to an entity when this entity is aliased and accessed through
an access value, or rules applying to subprogram calls when the call
is a dispatching call.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Abnormal_005fFunction_005fReturn" accesskey="1">Abnormal_Function_Return</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Allocators" accesskey="2">Allocators</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Array_005fDeclarations" accesskey="3">Array_Declarations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Aspects" accesskey="4">Aspects</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Assignments" accesskey="5">Assignments</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Barrier_005fExpressions" accesskey="6">Barrier_Expressions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Case_005fStatement" accesskey="7">Case_Statement</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Characters" accesskey="8">Characters</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Comments" accesskey="9">Comments</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Declarations">Declarations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Default_005fParameter">Default_Parameter</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Dependencies">Dependencies</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Derivations">Derivations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Directly_005fAccessed_005fGlobals">Directly_Accessed_Globals</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Duplicate_005fInitialization_005fCalls">Duplicate_Initialization_Calls</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Entities">Entities</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Entity_005fInside_005fException">Entity_Inside_Exception</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Exception_005fPropagation">Exception_Propagation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Expressions">Expressions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Generic_005fAliasing">Generic_Aliasing</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Global_005fReferences">Global_References</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Header_005fComments">Header_Comments</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Improper_005fInitialization">Improper_Initialization</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Instantiations">Instantiations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Insufficient_005fParameters">Insufficient_Parameters</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Local_005fAccess">Local_Access</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Local_005fHiding">Local_Hiding</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Max_005fBlank_005fLines">Max_Blank_Lines</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Max_005fCall_005fDepth">Max_Call_Depth</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Max_005fLine_005fLength">Max_Line_Length</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Max_005fNesting">Max_Nesting</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Max_005fSize">Max_Size</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Max_005fStatement_005fNesting">Max_Statement_Nesting</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Movable_005fAccept_005fStatements">Movable_Accept_Statements</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Naming_005fConvention">Naming_Convention</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#No_005fOperator_005fUsage">No_Operator_Usage</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Non_005fStatic">Non_Static</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Not_005fElaboration_005fCalls">Not_Elaboration_Calls</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Not_005fSelected_005fName">Not_Selected_Name</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Object_005fDeclarations">Object_Declarations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Parameter_005fAliasing">Parameter_Aliasing</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Parameter_005fDeclarations">Parameter_Declarations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Positional_005fAssociations">Positional_Associations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Potentially_005fBlocking_005fOperations">Potentially_Blocking_Operations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Pragmas">Pragmas</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Record_005fDeclarations">Record_Declarations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Reduceable_005fScope">Reduceable_Scope</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Representation_005fClauses">Representation_Clauses</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Return_005fType">Return_Type</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Side_005fEffect_005fParameters">Side_Effect_Parameters</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Silent_005fExceptions">Silent_Exceptions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Simplifiable_005fExpressions">Simplifiable_Expressions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Simplifiable_005fStatements">Simplifiable_Statements</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Statements">Statements</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Style">Style</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Terminating_005fTasks">Terminating_Tasks</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Type_005fInitial_005fValues">Type_Initial_Values</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Type_005fUsage">Type_Usage</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Uncheckable">Uncheckable</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Unit_005fPattern">Unit_Pattern</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Units">Units</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Unnecessary_005fUse_005fClause">Unnecessary_Use_Clause</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Unsafe_005fElaboration">Unsafe_Elaboration</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Unsafe_005fPaired_005fCalls">Unsafe_Paired_Calls</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Unsafe_005fUnchecked_005fConversion">Unsafe_Unchecked_Conversion</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Usage">Usage</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Use_005fClauses">Use_Clauses</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#With_005fClauses">With_Clauses</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Abnormal_005fFunction_005fReturn"></a>
<div class="header">
<p>
Next: <a href="#Allocators" accesskey="n" rel="next">Allocators</a>, Previous: <a href="#Rules-reference" accesskey="p" rel="prev">Rules reference</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Abnormal_005fFunction_005fReturn-1"></a>
<h3 class="section">5.1 Abnormal_Function_Return</h3>
<p>This rule controls functions that may not terminate normally, i.e. where
<code>Program_Error</code> could be raised due to reaching the end of the
function without encountering a <code><b>return</b></code> statement.
</p>
<a name="Syntax"></a>
<h4 class="subsection">5.1.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> abnormal_function_return;
</pre></div>
<a name="Action"></a>
<h4 class="subsection">5.1.2 Action</h4>
<p>The rule controls that the sequence of statements of each function
body, as well as each of its exception handlers, ends with:
</p><ul>
<li> a <code><b>return</b></code> statement (including extended return statements)
</li><li> a <code><b>raise</b></code> statement (or equivalently, a call to
<code>Ada.Exceptions.Raise_Exception</code> or
<code>Ada.Exceptions.Reraise_Occurrence</code>);
</li><li> a call to a procedure which is the target of a <code><b>pragma</b> No_Return</code>;
</li><li> a block statement, whose last statement of its sequence and any
exception handler is one of these;
</li><li> an <code><b>if</b></code> statement that includes an <code><b>else</b></code> path, and
where the last statement of every path is one of these;
</li><li> a <code><b>case</b></code> statement where the last statement of every path is
one of these.
</li><li> a plain <code><b>loop</b></code> statement (not <code><b>for</b></code> or
<code><b>while</b></code>) without any <code><b>exit</b></code> or <code><b>goto</b></code>
statement transfering control outside of the loop.
</li></ul>
<p>This is a sufficient (but of course not necessary) condition to ensure
that no function raises <code>Program_Error</code> due to reaching the end
of its statements without encountering a <code><b>return</b></code>.
</p>
<p>This rule can be specified only once.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check abnormal_function_return;
</pre></div>
<a name="Tips"></a>
<h4 class="subsection">5.1.3 Tips</h4>
<p>This rule checks that a function always returns correctly, but does not
prevent multiple <code><b>return</b></code> statements in functions. If you want
to ensure that there is exactly one <code><b>return</b></code> statement in functions,
and that this statement is always the last one, use this rule together with
the rule <code>statements(function_return)</code>.
See <a href="#Statements">Statements</a>.
</p>
<p>It is possible to exit from an extended return statement with an
<code><b>exit</b></code> or <code><b>goto</b></code> statement. If this happens, the
return statement is not considered a proper return statement, and an
appropriate message is issued.
</p>
<hr>
<a name="Allocators"></a>
<div class="header">
<p>
Next: <a href="#Array_005fDeclarations" accesskey="n" rel="next">Array_Declarations</a>, Previous: <a href="#Abnormal_005fFunction_005fReturn" accesskey="p" rel="prev">Abnormal_Function_Return</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Allocators-1"></a>
<h3 class="section">5.2 Allocators</h3>
<p>This rule controls the use of allocators (i.e. dynamic memory allocation).
</p><a name="Syntax-1"></a>
<h4 class="subsection">5.2.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> allocators [(<target> {, <target>})];
<target> ::= [anonymous | inconsistent | not] [<category>|<entity>]
<category> ::= () | access | array | delta | digits |
mod | protected | range | record | tagged | task
</pre></div>
<a name="Action-1"></a>
<h4 class="subsection">5.2.2 Action</h4>
<p>If one or several <entity> or <category> are given, only allocators
whose allocated type matches the <entity>, or whose type belongs to
the indicated <category>, are controlled; otherwise all allocators are
controlled. As usual, the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. The meaning of
<category> is:
</p><ul>
<li> “()”: The allocated value is of an enumerated type.
</li><li> “access”: The allocated value is of an access type.
</li><li> “array”: The allocated value is of an array type.
</li><li> “delta”: The allocated value is of a fixed point type (it is not currently
possible to distinguish ordinary fixed point types from decimal fixed
point types).
</li><li> “digits”: The allocated value is of a floating point type.
</li><li> “mod”: The allocated value is of a modular type.
</li><li> “protected”: The allocated value is of a protected type.
</li><li> “range”: The allocated value is of a signed integer type.
</li><li> “record”: The allocated value is of an (untagged) record type.
</li><li> “tagged”: The allocated value is of a tagged type (including type
extensions).
</li><li> “task”: The allocated value is of a task type.
</li></ul>
<p>This rule is especially useful for finding memory leaks, since it
tells all the places where dynamic allocation occurs.
</p>
<p>If a parameter is preceded by the word “not”, allocators for the
corresponding type or category are not controlled (i.e. they are
always allowed). If a control includes only “not” parameters, an
implicit check for all allocators is assumed.
</p>
<p>If a parameter is preceded by the word “anonymous”, only allocators
whose expected type is an anonymous access type are controlled.
</p>
<p>If a parameter is preceded by the word “inconsistent”, only
allocators whose allocator subtype (the name after “<code><b>new</b></code>”)
is not the same as the designated subtype (from the access type
declaration) are controlled. However an allocator is not considered
inconsistent when the designated subtype imposes no special
constraint:
</p><ul>
<li> when it is a class-wide type, since the allocator subtype will
generally be of some descendant specific type;
</li><li> when it is an unconstrained array type, since the allocated subtype is
necessarily constrained;
</li><li> when it is a base type (of the form <code>T'Base</code>).
</li></ul>
<p>Note that if the access type includes a constraint like in the
following example:
</p><div class="example">
<pre class="example"> <b>type</b> Acc <b>is</b> <b>access</b> integer <b>range</b> 1..10;
</pre></div>
<p>all allocators will necessarilly be inconsistent, since there is no
way to repeat the constraint at the place of the allocator.
</p>
<p>“Inconsistent” can be given alone, in which case all inconsistent
allocators are controlled.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search allocators (standard.string);
check allocators (T'Class);
check allocators (array);
check allocators (Inconsistent standard.Integer);
check allocators (Inconsistent);
-- all task allocators, except when the type is called "special":
check allocators (task, not all Special);
</pre></div>
<a name="Tips-1"></a>
<h4 class="subsection">5.2.3 Tips</h4>
<p>The type given as an <entity> in the rule must be a first named
subtype, and the rule will also find allocators that use a subtype of
this type. If the type is declared within a generic package, the rule
will control all corresponding types from instantiations.
</p>
<p>The type mentionned in the rule is the one following the
<code><b>new</b></code> keyword, which is not necessarily the same as the
expected type in presence of implicit conversions like this:
</p>
<div class="example">
<pre class="example"> <b>type</b> T <b>is</b> <b>tagged</b> ...;
<b>type</b> Class_Access <b>is</b> <b>access</b> T'Class;
X : Class_Access;
begin
X := <b>new</b> T;
</pre></div>
<p>This allocator will be found for type <code>T</code>, not for type <code>T'Class</code>.
</p>
<p>For <categories>, note that the rule “sees through” derived and
private types (i.e. it will trigger if the ultimate type belongs to
the indicated category).
</p>
<p>The reason for the “inconsistent” modifier is that inconsistent
allocators may cost a double check. Given:
</p><div class="example">
<pre class="example"> <b>type</b> Acc <b>is</b> <b>access</b> Positive;
V : Acc;
<b>begin</b>
V := <b>new</b> Natural'(...);
</pre></div>
<p>The compiler will first check the constraint for Natural, then the
constraint for Positive. To avoid confusion, it is better to always
use the same subtype for the allocator as used in the access type
declaration.
</p>
<p>The reason for the “anonymous” modifier is that allocators of
an anonymous type (especially access parameters) create a terrible mess in
accessibility rules, and are better avoided.
</p><a name="Limitations"></a>
<h4 class="subsection">5.2.4 Limitations</h4>
<p>In some (rare) cases involving anonymous access types as array or
record components, ASIS provides no way to determine the target type
of the (anonymous) acccess type. Inconsistent allocators will thus not
be controlled. Such cases are detected by the rule “uncheckable”.
See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Array_005fDeclarations"></a>
<div class="header">
<p>
Next: <a href="#Aspects" accesskey="n" rel="next">Aspects</a>, Previous: <a href="#Allocators" accesskey="p" rel="prev">Allocators</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Array_005fDeclarations-1"></a>
<h3 class="section">5.3 Array_Declarations</h3>
<p>This rule controls properties of arrays, by enforcing a consistent
value or range of values for the lower or upper bound, or by limiting
the possible size. It can also control various aspects of the
component type of the array.
</p><a name="Syntax-2"></a>
<h4 class="subsection">5.3.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> array_declarations (first, <value> | <bounds>);
<control_kind> array_declarations (last, <value> | <bounds>);
<control_kind> array_declarations (dimensions, <value> | <bounds>);
<control_kind> array_declarations ([all] length, <bounds>);
<control_kind> array_declarations (component, <type> {,<repr_cond>});
<control_kind> array_declarations (index, <type> | <>
{,<type> | <>});
<bounds> ::= min|max <value> [, min|max <value> ]
<type> ::= <entity>|<category>
<category > ::= () | access | array | delta | digits | mod | private
| protected | range | record | tagged | task
<repr_cond> ::= [not] pack | size | component_size
</pre></div>
<a name="Action-2"></a>
<h4 class="subsection">5.3.2 Action</h4>
<p>This rule controls properties of the index or component of an array
type. The checks are therefore performed on array definitions, i.e. on
array (sub)type declarations and single array declarations. However,
the “length” subrule can be checked on any array variable, see
below.
</p>
<p>The first parameter is a subrule keyword:
</p><ul>
<li> “First” and “Last” control the lower (respectively upper) bound of
each dimension of arrays (even unconstrained array types). If a single
value is specified without the “min” or “max” modifiers, the
subrule controls the bounds that are not exactly this value;
otherwise, it controls the bounds that are smaller than the given
“min” value or greater than the given “max” value. It is possible,
but not required to specify both “min” and “max”. If this subrule
is given both for “search” and for “check”, the value(s) for
“search” is interpreted as the prefered one, and the value(s) for
“check” is interpreted as an alternative acceptable one; i.e., it is
a warning if the value is the one given for “check”, and an error if
it is neither. In short:
<div class="example">
<pre class="example">search array_declarations (first, 1);
check array_declarations (first, min -1, max 1);
</pre></div>
<p>will be silent if the lower bound of an array is 1, it will issue a
warning if it is in the range -1 .. 1, and an error otherwise.
</p></li><li> “Dimensions”controls the number of dimensions of arrays. If a single
value is specified without the “min” or “max” modifiers, the
subrule controls arrays whose number of dimensions is not exactly this
value; otherwise, it controls arrays whose number of dimensions are
smaller than the given “min” value or greater than the given “max”
value. It is possible, but not required to specify both “min” and
“max”. If this subrule is given both for “search” and for
“check”, the value(s) for “search” is interpreted as the prefered
one, and the value(s) for “check” is interpreted as an alternative
acceptable one; i.e., it is a warning if the value is the one given
for “check”, and an error if it is neither. In short:
<div class="example">
<pre class="example">search array_declarations (Dimensions, 1);
check array_declarations (Dimensions, min 2, max 3);
</pre></div>
<p>will be silent for one-dimensional arrays, it will issue a warning for
2- and 3-dimensional arrays, and an error otherwise.
</p></li><li> “Length” controls arrays that have a dimension whose number of
elements is smaller than the given “min” value or greater than the
given “max” value (except for unconstrained array types). At least
one of “min” or “max” must be specified, but it is not required to
specify both.
<p>If the “all” modifier is specified, all object declarations of an
array type are controlled, even if the declaration does not include
an explicit range constraint. This is useful if you want to assess
all variables that contain more than a certain number of elements. For
example:
</p><div class="example">
<pre class="example"> type Tab is array (Min..Max) of Compo; -- Always checked
subtype Str is String (Min..Max); -- Always checked
V1 : String (Min..Max); -- Always checked
V2 : Str; -- Checked only with "all"
</pre></div>
</li><li> “Component” controls arrays whose component type is the indicated
<entity>, or whose component type belongs to the indicated
<category>. If the <entity> is a subtype, only arrays whose components
are of that subtype are controlled. If the indicated <entity> is a
type, all arrays whose components are of that type (including
subtypes) are controlled. The meaning of <category> is:
<ul>
<li> “()”: The component is of an enumerated type.
</li><li> “access”: The component is of an access type.
</li><li> “array”: The component is of an array type.
</li><li> “delta”: The component is of a fixed point type (it is not currently
possible to distinguish ordinary fixed point types from decimal fixed
point types).
</li><li> “digits”: The component is of a floating point type.
</li><li> “mod”: The component is of a modular type.
</li><li> “private”: The component is of a private type (including private
extensions).
</li><li> “protected”: The component is of a protected type.
</li><li> “range”: The component is of a signed integer type.
</li><li> “record”: The component is of an (untagged) record type.
</li><li> “tagged”: The component is of a tagged type (including type
extensions).
</li><li> “task”: The component is of a task type.
</li></ul>
<p>If <repr_cond> are specified, the rule controls only arrays to which
all the corresponding representation items apply:
</p><ul>
<li> “pack”: A pragma Pack applies to the array.
</li><li> “not pack”: No pragma Pack applies to the array.
</li><li> “size”: A size representation clause applies to the array.
</li><li> “not size”: No size representation clause applies to the array.
</li><li> “component_size”: A component_size representation clause applies to
the array.
</li><li> “not component_size”: No component_size representation clause
applies to the array.
</li></ul>
</li><li> “index” controls arrays whose index types are the indicated
<entity>, or whose index types belong to the indicated <category>. If
the <entity> is a subtype, only arrays whose indexes are of that
subtype are controlled. If the indicated <entity> is a type, all
arrays whose indexes are of that type (including subtypes) are
controlled. The meaning of <category> is the same as for
“component”, but obviously only “()”, “range”, and “mod” are
allowed.
<p>The number of <entity> given determines the dimensionality of the
controlled arrays. If a “<>” is given in place of an entity, it
means that any type matches at that position.
</p></li></ul>
<p>This rule can be specified several times for the “component” and
“index” subrules. For other subrules, it can be specified at most
once for each subrule and for each of “check”, “search” and
“count”. It is thus possible for each subrule to have a value
considered a warning, and a value considered an error.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- All arrays should start at 1:
check array_declarations (first, 1);
-- No arrray of more than 100 elements:
check array_declarations (length, max 100);
-- No empty array:
check array_declarations (length, min 1);
-- Arrays whose component type is private:
check array_declarations (component, private);
-- Packed arrays of Character
check array_declarations (component, Standard.Character, pack);
-- Packed arrays of record without size clause
check array_declarations (component, record, packed, not size);
-- One-dimensional arrays indexed by Integer
check array_declarations (index, standard.integer);
-- Three dimensional arrays whose second index is an enumeration
check array_declarations (index, <>, (), <>);
</pre></div>
<a name="Tips-2"></a>
<h4 class="subsection">5.3.3 Tips</h4>
<p>The subrule <code>Max_Length</code> ignores index constraints that are not
static. Non static index constraints can be controlled with the rule
<code>Non_Static (Index_Constraint)</code>. See <a href="#Non_005fStatic">Non_Static</a>.
</p>
<p>Requiring the same <i>upper</i> bound for all arrays is not very useful, but:
</p><div class="example">
<pre class="example">check array_declarations (last, min 1);
</pre></div>
<p>can be used to check that no array has a negative or zero upper bound.
</p>
<p>The subrule “index” controls a precise pattern of types used as
indices. To control the use of a type as an index at any position and
irrespectively of the number of indices of the array, use the rule
“type_usage”. See <a href="#Type_005fUsage">Type_Usage</a>.
</p>
<hr>
<a name="Aspects"></a>
<div class="header">
<p>
Next: <a href="#Assignments" accesskey="n" rel="next">Assignments</a>, Previous: <a href="#Array_005fDeclarations" accesskey="p" rel="prev">Array_Declarations</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Aspects-1"></a>
<h3 class="section">5.4 Aspects</h3>
<p>This rule controls aspect specifications (new feature in Ada 2012), either
all of them, specific ones, or those whose value is implicitely <code>True</code>.
</p><a name="Syntax-3"></a>
<h4 class="subsection">5.4.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> aspects [(<aspect key> {, <aspect key>})];
<aspect_key> ::= all | implicit_true | <aspect mark>
</pre></div>
<a name="Action-3"></a>
<h4 class="subsection">5.4.2 Action</h4>
<p>Without parameters, controls all aspect specifications. Otherwise,
controls only the aspect specifications corresponding to the given
aspect marks. If “all” is given together with explicit aspect marks,
it controls aspects not given explicitely.
</p>
<p>If “implicit_true” is given, it controls aspect specifications
without an association (i.e. boolean aspects given without an explicit
association that take implicitely the value <code>True</code>).
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search aspects;
DBC: check aspects (Pre, Post, Pre'Class, Post'Class);
Explicit_Required: check aspects (implicit_true);
</pre></div>
<hr>
<a name="Assignments"></a>
<div class="header">
<p>
Next: <a href="#Barrier_005fExpressions" accesskey="n" rel="next">Barrier_Expressions</a>, Previous: <a href="#Aspects" accesskey="p" rel="prev">Aspects</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Assignments-1"></a>
<h3 class="section">5.5 Assignments</h3>
<p>This rule controls various issues related to the assignment statement:
assignments that involve array sliding, assignments that cause
duplication of access values, redundant assignments to the same
variable, or groups of assignments that are replaceable by aggregate
assignment.
</p>
<a name="Syntax-4"></a>
<h4 class="subsection">5.5.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> assignments (sliding);
<control_kind> assignments ([[not] controlled] access_duplication
{, [not] <target>});
<control_kind> assignments (repeated);
<control_kind> assignments (groupable, <filter> {,<filter>});
<target> ::= <entity> | <category>
<category> ::= () | access | array | delta | digits |
function | mod | private | procedure | protected |
range | record | tagged | task
<filter> ::= given <min_val> | missing <max_val> | ratio <min_val> |
total <max_val>
</pre></div>
<a name="Action-4"></a>
<h4 class="subsection">5.5.2 Action</h4>
<p>The first form (keyword “sliding”) controls array assignments where
the target variable has a different lower bound than the assigned
expression; this is allowed by the language only in so-called
“sliding” contexts.
</p>
<p>The second form (keyword “access_duplication”) controls assignments
where the content of an object of an access type is stored (directly,
or as a subcomponent) into another object. The <code><b>null</b></code> value
and allocators (<code><b>new</b></code>) are <i>not</i> controlled. In other
words, this rule spots places where you start having more than one way
to access a variable. If the modifier “controlled” is given, only
access types that are subcomponents (directly or indirectly) of a
controlled type are controlled, while if “not controlled” is given,
only those that are <i>not</i> subcomponents of a controlled type are
controlled. No modifier is equivalent to giving both “controlled”
and “not controlled”. If one or several <target> without <code>not</code>
are given, the control applies only to access types whose target type
matches the given <entity>, or belongs to the given <category>. As
usual, the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. The meaning of <category> is:
</p><ul>
<li> “()”: The target is of an enumerated type.
</li><li> “access”: The target is of an access type.
</li><li> “array”: The target is of an array type.
</li><li> “delta”: The target is of a fixed point type (it is not currently
possible to distinguish ordinary fixed point types from decimal fixed
point types).
</li><li> “digits”: The target is of a floating point type.
</li><li> “function”: The target is a function.
</li><li> “mod”: The target is of a modular type.
</li><li> “private”: The target is of a private type (including private
extensions).
</li><li> “procedure”: The target is a procedure.
</li><li> “protected”: The target is of a protected type.
</li><li> “range”: The target is of a signed integer type.
</li><li> “record”: The target is of an (untagged) record type.
</li><li> “tagged”: The target is of a tagged type (including type
extensions).
</li><li> “task”: The target is of a task type.
</li></ul>
<p>If the <target> is preceded by <code>not</code>, it means that the corresponding
<entity> or <category> is not controlled.
</p>
<p>This subrule can be given at most twice for each <target>, once
for “controlled” and once for “not controlled”.
</p>
<p>Note that the two rules above are checked for initialization of
variables and constants, as well as in regular assignments.
</p>
<p>Other subrules control properties of groups of assignment statements. A
group is made of consecutive assignments, without any other
intervening kind of statements (except null statements).
</p>
<p>The third form (keyword “repeated”) controls when a same variable
(or a same subcomponent of a structured variable) is assigned several
times in the same group of assignments. This form of the rule can be
given only once.
</p>
<p>The fourth form (keyword “groupable”) controls assignments to
different subcomponents of a same structured variable; such
assignments are often replaceable by a global assignment of an
aggregate to the variable. One or several <filter> parameters
indicate under which conditions a group is reported:
</p><ul>
<li> “given”: <min_val> (an integer value) indicates the minimum number
of assigned subcomponents that will trigger the rule (i.e. the rule is
triggered if the number of assignments to subcomponents of a same
variable is greater or equal to the indicated value).
</li><li> “missing”: <max_val> (an integer value) indicates the maximum number
of subcomponents not assigned that will trigger the rule (i.e. the
rule is triggered if the number of subcomponents not assigned to is
lesser or equal to the indicated value).
</li><li> “ratio”: <min_val> (an integer value) indicates the minimum
percentage of assigned subcomponents that will trigger the rule
(i.e. the rule is triggered if the percentage of assigned
subcomponents is greater or equal to the indicated value).
</li><li> “total”: <max_val> (an integer value) indicates the maximum number
of subcomponents of the type that will trigger the rule (i.e. the
rule is triggered if the number of subcomponents of the record type is
lesser or equal to the indicated value).
</li></ul>
<p>If several filters are given, the rule is triggered if all conditions
are met (“and” logic). Note however that this rule can be given
several times, thus achieving “or” logic.
</p>
<p>The rule is <i>not</i> triggered on an object if a subcomponent of that object
is of a limited type, since global assignment would not be allowed in
that case.
</p>
<p>For other structured objects, a subcomponent is counted as assigned if
it has been assigned in full, or if it <i>should</i> have been assigned
in full (in other words: if the rule is triggered on those
subcomponents as well) - recursively, of course.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search Assignments (sliding);
check Assignments (repeated);
-- Warn if a at least 3 fields are given and at most
-- two fields are missing, or if 80% of the fields are given:
search assignments (groupable, given 3, missing 2);
search assignments (groupable, ratio 80);
</pre></div>
<a name="Tips-3"></a>
<h4 class="subsection">5.5.3 Tips</h4>
<p>The “sliding” subrule is not intended to prevent all cases of
slidings (the dynamic ones are uncheckable), it is rather an
indication of “obvious” cases that could be avoided.
</p>
<p>The “access_duplication” subrule is especially handy to track
remaining duplication of access values after they have been
Unchecked_Deallocated through one of the variables. The
“not controlled” modifier is intended to avoid too many false
positives when you use controlled types to manage pointers. It may also
be useful to check all access duplications, but consider that those that
are part of a controlled type deserve only a warning:
</p><div class="example">
<pre class="example">check assignments (not controlled access_duplication);
search assignments ( controlled access_duplication);
</pre></div>
<p>Note that for the “groupable” subrule, it is possible to give 1 for
the “given” criterion; in this case, any assignment to parts of a
structured variable will be reported, only global assignment is
allowed.
</p>
<a name="Limitations-1"></a>
<h4 class="subsection">5.5.4 Limitations</h4>
<p>As usual, AdaControl can control only static aspects of
assignments. Therefore, it cannot control assignments whose target is
not statically known (like dynamic indexing of arrays). Slices are
always considered dynamic (the cases where it would be useful did not
seem worth the additional complexity).
</p>
<p>For the “sliding” subrule, if the assigned expression is a
multidimensional aggregate, only the first dimension is checked for
sliding, other dimensions are ignored. This is not considered an
important issue, since in any case the rule can detect only static
cases, and the handling of sliding in multi-dimensional array
aggregates is extremely touchy (see RM 4.3.3 for details).
</p>
<p>For the “groupable” subrule, if the number of subcomponents is not
statically determinable (dynamic arrays, discriminated records), only
the “given” criterion can be met.
</p>
<hr>
<a name="Barrier_005fExpressions"></a>
<div class="header">
<p>
Next: <a href="#Case_005fStatement" accesskey="n" rel="next">Case_Statement</a>, Previous: <a href="#Assignments" accesskey="p" rel="prev">Assignments</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Barrier_005fExpressions-1"></a>
<h3 class="section">5.6 Barrier_Expressions</h3>
<p>Although the language allows any expression as the barrier of a
protected entry, it is generally better to use only “simple”
expressions. This rule controls the kind of constructs allowed in
barrier expressions.
</p><a name="Syntax-5"></a>
<h4 class="subsection">5.6.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> Barrier_Expressions ([<allowable> {, <allowable>}]);
<allowable> ::= <entity> | <keyword>
<keyword> ::=
allocation | any_component | any_variable |
arithmetic_operator | array_aggregate | comparison_operator |
conversion | dereference | indexing |
function_attribute | local_function | logical_operator |
record_aggregate | value_attribute
</pre></div>
<a name="Action-5"></a>
<h4 class="subsection">5.6.2 Action</h4>
<p>Without parameters, the only elements allowed in barriers are
references to boolean components of the protected element and
litterals (this corresponds to what is allowed for the Ravenscar
profile). Parameters specify other constructs that are allowed:
</p><ul>
<li> Any <entity> (like a global variable, a function...) can be specified
and is thus allowed. As usual, the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</li><li> “allocation” allows use of allocators.
</li><li> “any_component” allows use of protected components that are not of
type <code>Standard.Boolean</code>.
</li><li> “any_variable” allows use of any variable (i.e. variables external to
the protected element).
</li><li> “arithmetic_operator” allows use of predefined arithmetic operators
(<code>"+"</code>, <code>"**"</code>, etc.).
</li><li> “array_aggregate” allows use of array aggregates.
</li><li> “comparison_operator” allows use of predefined comparison and
membership operators (<code>"="</code>, <code>">"</code>, <code><b>in</b></code>, etc.).
</li><li> “conversion” allows use of type conversions and type qualifications.
</li><li> “dereference” allows use of dereferencing of access types (both implicit
and explicit dereferences).
</li><li> “indexing” allows use of array indexing and slices.
</li><li> “function_attribute” allows use of attributes that are functions
(like <code>'Pred</code>, <code>'Image</code>, etc.).
</li><li> “local_function” allows use of (protected) functions declared in the
same protected object.
</li><li> “logical_operator” allows use of predefined logical operators and
short-circuit forms (<code><b>and</b></code>, <code><b>or else</b></code>, etc.).
</li><li> “record_aggregate” allows use of record aggregates and extension
aggregates.
</li><li> “value_attribute” allows use of attributes that are simple values
(like <code>'First</code>, <code>'Terminated</code>, etc.).
</li></ul>
<p>This rule can be given only once for each of “check”, “search” and
“count”.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search barrier_expressions;
check barrier_expressions (logical_operator, comparison_operator,
any_component,
Pack.Global_State);
</pre></div>
<a name="Tips-4"></a>
<h4 class="subsection">5.6.3 Tips</h4>
<p>The goal of the “Simple_Barrier” restriction from the Ravenscar
profile is to ensure that evaluation of barriers never raise
exceptions. Even simple things like a qualified expression can raise
exceptions, but in practice more than the restriction of the Ravenscar
profile can be “reasonably” allowed.
</p>
<p>Note that the various “operator” keywords allow only the use of
predefined operators. If a user defined operator should be allowed,
provide it explicitely as an <entity>. There is no way to allow any
function call, since this would boil down to allowing pretty much
anything, but you can of course specify explicitely functions that can
be called.
</p>
<p>You can provide this rule both for “check” and “search”, but of
course it makes sense only if the set of allowed features for
“search” is a superset of those allowed for “check”. This way, the
use of certain features can be interpreted only as a warning.
</p>
<hr>
<a name="Case_005fStatement"></a>
<div class="header">
<p>
Next: <a href="#Characters" accesskey="n" rel="next">Characters</a>, Previous: <a href="#Barrier_005fExpressions" accesskey="p" rel="prev">Barrier_Expressions</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Case_005fStatement-1"></a>
<h3 class="section">5.7 Case_Statement</h3>
<p>This rule controls various metrics related to the <code><b>case</b></code>
statement. It is intended for cases where it is desired to limit the
complexity of <code><b>case</b></code> statements.
</p><a name="Syntax-6"></a>
<h4 class="subsection">5.7.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> Case_Statement (<subrule>, <bound> [, <bound>]);
<subrule> ::= others_span | paths | range_span | values |
values_if_others
<bound> ::= min | max <value>
</pre></div>
<a name="Action-6"></a>
<h4 class="subsection">5.7.2 Action</h4>
<p>The first parameter is a subrule keyword. The second (and optionnally
third) parameter give the minimum and/or maximum allowed values
(i.e. the rule will control values outside the indicated interval). If
not specified, the minimum value is defaulted to 0 and the maximum
value to infinity. The parameters controlled by each subrule are:
</p><ul>
<li> “others_span” controls the number of values covered by
<code><b>when</b></code> <code><b>others</b></code> case alternatives.
</li><li> “paths” controls the number of paths (i.e. <code><b>when</b></code> branches).
</li><li> “range_span” controls the number of values covered by ranges used as
choices.
</li><li> “values” controls the number of values covered by the subtype
of the <code><b>case</b></code> selector.
</li><li> “values_if_others” is like “values”, but is activated only for
<code><b>case</b></code> statements with a <code><b>when</b></code> <code><b>others</b></code>
alternative.
</li></ul>
<p>This rule can be specified at most once for each subrule and for each
of “check”, “search” and “count”. It is thus possible for each
subrule to have a value considered a warning, and a value considered
an error.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check Case_Statement (others_span, min 1);
search Case_Statement (others_span, min 5);
check Case_Statement (values, max 10);
check Case_Statement (paths, min 3, max 30);
</pre></div>
<a name="Tips-5"></a>
<h4 class="subsection">5.7.3 Tips</h4>
<p>To control that no range is used as a choice in a <code><b>case</b></code>
statement:
</p><div class="example">
<pre class="example">check case_statement (range_span, max 0);
</pre></div>
<p>To control “<code><b>when</b></code> <code><b>others</b></code>” that
cover no value at all:
</p><div class="example">
<pre class="example">check case_statement (others_span, min 1);
</pre></div>
<a name="Limitations-2"></a>
<h4 class="subsection">5.7.4 Limitations</h4>
<p>If some characteristic of the <code><b>case</b></code> statement depend on a
generic formal type, it is not possible to control some of the
features statically. Such cases are detected by the rule
“uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<p>If the subtype of the selecting expression of the <code><b>case</b></code>
statement, or a subtype in one of its a choice lists, has applicable
static predicates, AdaControl is not able to control the features that
depend on the number of values of the subtype. Such cases are detected
by the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>. We hope to be able to
remove this limitation in the future, but the problem is quite
difficult...
</p>
<hr>
<a name="Characters"></a>
<div class="header">
<p>
Next: <a href="#Comments" accesskey="n" rel="next">Comments</a>, Previous: <a href="#Case_005fStatement" accesskey="p" rel="prev">Case_Statement</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Characters-1"></a>
<h3 class="section">5.8 Characters</h3>
<p>This rule makes sure that the program text does not use
“undesirable” characters.
</p><a name="Syntax-7"></a>
<h4 class="subsection">5.8.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> characters [(<subrule> {, <subrule>})];
<subrule> ::= control | not_iso_646 | trailing_space | wide
</pre></div>
<a name="Action-7"></a>
<h4 class="subsection">5.8.2 Action</h4>
<p>The rule controls the occurrence in the source file of characters
belonging to the classe(s) defined by the subrules. Without
parameters, all classes are controlled. The classes are defined as
follows:
</p><ul>
<li> “control”: control characters that are allowed by the language
(ASCII HT, ASCII VT and ASCII FF).
</li><li> “not_iso_646”: characters outside the ISO-646 set (aka ASCII).
</li><li> “trailing_space”: space characters appearing at the end of the
source line.
</li><li> “wide”: wide characters that are not in <code>Standard.Character</code>.
</li></ul>
<p>This rule can be given only once for each class of characters.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check characters (control, trailing_space);
search characters (not_iso_646);
</pre></div>
<a name="Fixes"></a>
<h4 class="subsection">5.8.3 Fixes</h4>
<p>The following subrules generate fixes:
</p><ul>
<li> “control”: HT characters are replaced by spaces, up to the next position wich
is a multiple of 4; VT and FF characters are replaced by a single space.
</li><li> “trailing_space”: extra space characters are removed.
</li></ul>
<a name="Limitations-3"></a>
<h4 class="subsection">5.8.4 Limitations</h4>
<p>With the “wide” subrule, the error message may seem to not always
appear at the right place; this depends on the encoding scheme
used. For example, if your source contains (using bracket encoding):
</p><div class="example">
<pre class="example">S : Wide_String := "["1041"]["1042"]";
</pre></div>
<p>it will appear to AdaControl as a string containing two characters,
and therefore the error message for the second wide character will
point at two characters after the opening quote of the string.
</p>
<p>This rule controls only the characters in the source file; other means
of having characters in the corresponding classes (like using the
<code>'Val</code> attribute) are not controlled.
</p>
<hr>
<a name="Comments"></a>
<div class="header">
<p>
Next: <a href="#Declarations" accesskey="n" rel="next">Declarations</a>, Previous: <a href="#Characters" accesskey="p" rel="prev">Characters</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Comments-1"></a>
<h3 class="section">5.9 Comments</h3>
<p>This rule controls comments that must, or must not, appear in certain cases.
</p>
<a name="Syntax-8"></a>
<h4 class="subsection">5.9.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> comments (pattern, "<pattern>" {, "<pattern>"});
<control_kind> comments (position, <value> | <bounds>);
<control_kind> comments (terminating {, "<pattern>" | begin | end});
<control_kind> comments (unnamed_begin, <kind> {, <kind>});
<bounds> ::= min|max <value> [, min|max <value> ]
<kind> ::= [<condition>] <unit_kind>
<condition> ::= always | declaration | program_unit
<unit_kind> ::= all | procedure | function | entry | package | task
</pre></div>
<a name="Action-8"></a>
<h4 class="subsection">5.9.2 Action</h4>
<p>The first parameter is a subrule name which detemines what is being
controlled.
</p><ul>
<li> “pattern” controls comments that match one of the given patterns
(given as strings). Only the “useful” part of the comment is
matched against the patterns, i.e. the part after the “<code>--</code>”
and spaces following it. Patterns are given using the full Regexp
syntax. see <a href="#Syntax-of-regular-expressions">Syntax of regular expressions</a> for details. Pattern
matching is always case insensitive.
<p>This subrule is especially useful to find lines with comments like
“TBSL” (To Be Supplied Later) or “fixme”, which are often used to
mark places where something should be done before releasing the
program.
</p></li><li> “position” controls the starting position of comments. If a single
value is specified without the “min” or “max” modifiers, the
subrule controls comments that do not start exactly at the indicated
column position; otherwise, it controls comments whose starting column
is smaller than the given “min” value or greater than the given
“max” value. It is possible, but not required to specify both
“min” and “max”. If this subrule is given both for “search” and
for “check”, the value(s) for “search” is interpreted as the
prefered one, and the value(s) for “check” is interpreted as an
alternative acceptable one; i.e., it is a warning if the value is the
one given for “check”, and an error if it is neither. In short:
<div class="example">
<pre class="example">search comments (position, 1);
check comments (position, min 1, max 6);
</pre></div>
<p>will be silent for comments that start in column 1, it will issue a
warning for comments that start at columns 2 to 6, and an error otherwise.
</p>
</li><li> “terminating” controls comments that are at the end of an otherwise
non empty line (i.e. that appear on the same line as a declaration or
statement). If “begin” is specified, comments appearing on a line
that contains only a <code><b>begin</b></code> are allowed (not reported);
similarly, if “end” is specified, comments appearing on a line that
contains only an <code><b>end</b></code> are allowed. Otherwise, the other
parameters are patterns that specify forms of comments that are
allowed. Patterns are given using the full Regexp syntax.
see <a href="#Syntax-of-regular-expressions">Syntax of regular expressions</a> for details. Pattern matching is
always case insensitive.
</li><li> “unnamed_begin” controls <code><b>begin</b></code> of various constructs that
do not have a comment that repeats the name of the program unit
associated to the <code><b>begin</b></code>. Except for spaces, the comment
must not contain anything else than the unit name.
<p>The <condition> keyword determines circumstances where the comment is required:
</p><ul>
<li> ”always” (default): the comment is always required.
</li><li> “declaration”: the comment is required only if the preceding
declaration part is non-empty (not counting pragmas).
</li><li> “program_unit”: the comment is required only if the preceding
declaration part contains the declarations of other program units
(subprograms, packages, protected objects, or tasks).
</li></ul>
<p>The <unit_kind> keyword detemines the kind of program unit to which
the rule applies (“all” stands for all kinds). The subrule can be
given only once of each kind of program unit.
</p></li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">check comments (pattern, "TBSL");
-- Report places where rules are disabled:
search comments (pattern, "##.* off");
-- End of line comments are not allowed, except for the
-- comment that repeats the name of a procedure on the "begin"
-- line, and special AdaControl comments
check comments (terminating, begin, "^ *##");
-- Named begin required for packages unless they have no
-- declaration, and subprograms if they have nested units
check comments (unnamed_begin, declaration package);
check comments (unnamed_begin, program_unit procedure);
check comments (unnamed_begin, program_unit function);
</pre></div>
<a name="Fixes-1"></a>
<h4 class="subsection">5.9.3 Fixes</h4>
<p>The following subrules generate fixes:
</p><ul>
<li> “Unnamed_Begin”: a comment with the name of the entity is added to the <code><b>begin</b></code> if it has no comment, or
replaces an existing comment.
</li></ul>
<a name="Tips-6"></a>
<h4 class="subsection">5.9.4 Tips</h4>
<p>Remember that a Regexp matches if the pattern matches any part of the
identifier. Use “^” and “$” to match the beginning (resp. end) of
the comment, or both.
</p>
<p>For “unnamed_begin”, the <condition> defines cases where the comment
is optional; however if a comment is present in an optional case, it
has to be the name of the corresponding unit. The fix replaces an
existing comment, on the ground that it is likely that the wrong
comment is actually the old name of an entity that has been renamed.
</p>
<a name="Limitations-4"></a>
<h4 class="subsection">5.9.5 Limitations</h4>
<p>This rule does not support wide characters outside the basic Latin-1 set.
</p>
<hr>
<a name="Declarations"></a>
<div class="header">
<p>
Next: <a href="#Default_005fParameter" accesskey="n" rel="next">Default_Parameter</a>, Previous: <a href="#Comments" accesskey="p" rel="prev">Comments</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Declarations-1"></a>
<h3 class="section">5.10 Declarations</h3>
<p>This rule controls usage of various kinds of declarations, possibly only
those occurring at specified locations.
</p><a name="Syntax-9"></a>
<h4 class="subsection">5.10.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> declarations (<subrule> {, <subrule>});
<subrule> ::= {[not] <location_kw>} <declaration_kw>
<location_kw> ::= all | block | library | local | nested |
own | private | public | in_generic | task_body
<declaration_kw> ::=
any_declaration |
abstract_function | abstract_operator |
abstract_procedure | abstract_type |
access_all_type | access_constant_type |
access_constrained_array_type | access_def_discriminated_type |
access_formal_Type | access_language_type |
access_nondef_discriminated_type | access_protected_type |
access_subprogram_type | access_task_type |
access_unconstrained_array_type | access_unknown_discriminated_type |
access_type | aliased_array_component |
aliased_constant | aliased_protected_component |
aliased_record_component | aliased_variable |
anonymous_access_component | anonymous_access_constant |
anonymous_access_discriminant | anonymous_access_parameter |
anonymous_access_variable | anonymous_subtype_allocator |
anonymous_subtype_case | anonymous_subtype_declaration |
anonymous_subtype_for | anonymous_subtype_indexing |
array | array_type |
binary_modular_type | box_defaulted_formal_function |
box_defaulted_formal_procedure | character_literal |
child_unit | class_wide_constant |
class_wide_variable | constant |
constrained_array_constant | constrained_array_type |
constrained_array_variable | controlled_type |
decimal_fixed_type | defaulted_discriminant |
defaulted_generic_parameter | defaulted_parameter |
deferred_constant | derived_type |
discriminant | empty_private_part |
empty_visible_part | enumeration_type |
entry | equality_operator |
exception | expression_function |
extension | fixed_type |
float_type | formal_function |
formal_package | formal_procedure |
formal_type | function |
function_call_renaming | function_instantiation |
generic | generic_function |
generic_package | generic_procedure |
handlers | incomplete_type |
in_out_generic_parameter | in_out_parameter |
initialized_protected_component | initialized_record_component |
initialized_variable | instantiation |
integer_type | interface_type |
library_unit_renaming | limited_private_type |
modular_type | multiple_names |
multiple_protected_entries | name_defaulted_formal_function |
name_defaulted_formal_procedure | named_number |
no_spec_function | no_spec_procedure |
non_binary_modular_type | non_identical_operator_renaming |
non_identical_renaming | non_joint_ce_ne_handler |
non_limited_private_type | non_ravenscar_task |
not_operator_renaming | null_defaulted_formal_procedure |
null_extension | null_ordinary_record_type |
null_procedure | null_procedure_body |
null_procedure_declaration | null_tagged_type |
operator | operator_renaming |
ordinary_fixed_type | ordinary_fixed_type_no_small |
ordinary_fixed_type_with_small | ordinary_record_type |
ordinary_record_variable | out_parameter |
package | package_instantiation |
package_statements | predefined_operator |
private_extension | procedure |
procedure_instantiation | protected |
protected_discriminant | protected_entry |
protected_type | protected_variable |
record_type | relay_function |
relay_package | relay_procedure |
renaming | renaming_as_body |
renaming_as_declaration | scalar_variable |
self_calling_function | self_calling_procedure |
separate | signed_type |
single_array | single_protected |
single_task | subtype |
synonym_renaming | tagged_incomplete_type |
tagged_private_type | tagged_type |
tagged_variable | task |
task_discriminant | task_entry |
task_type | task_variable |
type | unconstrained_array_constant |
unconstrained_array_type | unconstrained_array_variable |
unconstrained_subtype | uninitialized_protected_component |
uninitialized_record_component | uninitialized_variable |
unknown_discriminant | variable |
variant_part
</pre></div>
<a name="Action-9"></a>
<h4 class="subsection">5.10.2 Action</h4>
<p>The <location_kw> restricts the places where the occurrence of the
declaration is controlled. If it is preceded by “not”, the
declaration is controlled except at this location. Several
<location_kw> can be given, in which case the declaration is
controlled at places where all the keywords apply. If there is no
<location_kw>, it is assumed to be “all”.
</p><ul>
<li> <code>all</code>: puts no special restriction to the location. This keyword
can be specified for readability purposes, and if specified must
appear alone (not with other <location_kw>), and “not” is not
allowed.
</li><li> <code>block</code>: only declarations appearing in block statements are controlled.
</li><li> <code>library</code>: only library level declarations are controlled.
</li><li> <code>local</code>: only local declarations are controlled (i.e. only declarations
appearing in (generic) packages, possibly nested, are allowed).
</li><li> <code>own</code>: only declarations that are local to a (generic) package body
are controlled.
</li><li> <code>public</code>: only declarations appearing in the visible part of
(generic) packages are controlled.
</li><li> <code>private</code>: only declarations appearing directly in a private
part are controlled.
</li><li> <code>in_generic</code>: only declarations appearing directly or indirectly in a generic
specification or body are controlled.
</li><li> <code>task_body</code>: only declarations appearing directly in a task body
are controlled. Note that it would not make sense to have a
<location_kw> for task <i>specifications</i>, since only entries can
appear there, and they cannot appear anywhere else.
</li></ul>
<p>The <declaration_kw> specifies what kind of declaration to control:
</p><ul>
<li> Declaration keywords that are Ada keywords match the corresponding Ada
declarations.
</li><li> <code>any_declaration</code> controls all declarations. This is of course not
intended to forbid all declarations in a program (!), but
<em>counting</em> all declarations can be quite useful.
</li><li> <code>abstract_function</code>, <code>abstract_operator</code>, and
<code>abstract_procedure</code> control the declarations of abstract
functions, abstract operators, and abstract procedures, respectively.
</li><li> <code>abstract_type</code> controls the declaration of non-formal abstract
types.
</li><li> <code>access_type</code> controls all access type declarations, while
<code>access_subprogram_type</code>, <code>access_protected_type</code>, and
<code>access_task_type</code> control only access to procedures or
functions, access to protected types, or access to task types,
respectively. Similarly, <code>access_constrained_array_type</code> and
<code>access_unconstrained_array_type</code> control access to constrained
or unconstrained array types, <code>access_def_discriminated_type</code>,
<code>access_nondef_discriminated_type</code>, and
<code>access_unknown_discriminated_type</code> control access to types with
discriminants with default values, without default values, and unknown
discriminants, respectively. <code>access_formal_type</code> controls access
to (generic) formal types, <code>access_all_type</code> control generalized
access to variables types (aka "<code><b>access</b> <b>all</b> T</code>", and
<code>access_constant_type</code> control generalized access to constants
types (aka "<code><b>access</b> <b>constant</b> T</code>"). <code>access_language_type</code>
controls access to language defined private types.
</li><li> <code>aliased_variable</code> and <code>aliased_constant</code> control the
declarations of aliased variables or constants, respectively.
</li><li> <code>aliased_array_component</code> controls the declaration of arrays
(array types or single arrays) whose components are declared aliased.
</li><li> <code>aliased_record_component</code> and <code>aliased_protected_component</code>
control the declarations of aliased record (respectively protected)
components.
</li><li> <code>anonymous_access_component</code> controls array and record components
that are of an anonymous access type (but not discriminants, which are
controlled by <code>anonymous_access_discriminant</code>). Similarly,
<code>anonymous_access_constant</code> and <code>anonymous_access_variable</code>
control constants and variables that are of an anonymous access type
(including generic formal <code><b>in</b></code> and <code><b>in</b> <b>out</b></code>
parameters, respectively). <code>anonymous_access_parameter</code> controls
subprogram parameters that are of an anonymous access type, the only
ones that existed in Ada 95. Note that to avoid unnecessary messages,
if a subprogram has an explicit specification, the message for
<code>anonymous_access_parameter</code> is given on the specification and
not repeated on the body.
</li><li> <code>anonymous_subtype_declaration</code> controls the declarations of
anonymous subtypes and ranges that are part of some other
declaration. Similarly, <code>anonymous_subtype_allocator</code>,
<code>anonymous_subtype_case</code>, <code>anonymous_subtype_for</code>, and
<code>anonymous_subtype_indexing</code> control anonymous subtype
declarations and ranges that are part of allocators, <code><b>case</b></code>
statements (ranges in the <code><b>when</b></code> path), <code><b>for</b></code> loop
statements, and indexing of slices or array aggregates, respectively.
</li><li> <code>array</code> controls all array definitions (array types and single
arrays), while <code>array_type</code> controls only array types and
<code>single_array</code> controls only single arrays (objects of an
anonymous array type). <code>constrained_array_type</code> controls only
constrained array types, while <code>unconstrained_array_type</code>
controls only unconstrained array
types. <code>constrained_array_variable</code> controls variable
declarations where the given (or anonymous) array type is constrained,
while <code>unconstrained_array variable</code> controls variable
declarations where the given (or anonymous) array type is
unconstrained (and the constraint is provided by the initial value).
<code>constrained_array_constant</code> and
<code>unconstrained_array_constant</code> do the same with constants instead
of variables.
</li><li> <code>character_literal</code> controls the declaration of new character
literals, i.e. character literals defined as part of the values of an
enumeration type.
</li><li> <code>child_unit</code> controls the declaration of all child units.
</li><li> <code>constant</code> controls all constants, while
<code>class_wide_constant</code> control the declaration of constants of a
class-wide type, and <code>deferred_constant</code> controls the declaration
of deferred constants.
</li><li> <code>controlled_type</code> controls the declaration of controlled types,
i.e. descendants of <code>Ada.Finalization.Controlled</code> or
<code>Ada.Finalization.Limited_Controlled</code>. Note that this includes
also private types that are not visibly controlled.
</li><li> <code>defaulted_parameter</code> controls subprogram or entry (<b>in</b>)
parameters that provide a default value, while
<code>defaulted_generic_parameter</code> controls generic formal objects
that provide a default value.
</li><li> <code>derived_type</code> controls regular derived types, but not type
extensions (derivations of tagged types). These are controlled by
<code>extension</code> and <code>private_extension</code>.
</li><li> <code>discriminant</code> controls all declarations of types with
discriminants, while <code>protected_discriminant</code> and
<code>task_discriminant</code> control only discriminants of protected types
and task types, respectively. <code>defaulted_discriminants</code> controls
only discriminants where default values are
provided. <code>unknown_discriminants</code> controls only unknown
discriminants (AKA “<code>(<>)</code>” discriminants).
</li><li> <code>empty_private_part</code> controls package specification with an empty
private part, i.e. where the word <code><b>private</b></code> appears, but the
private part contains no declaration (even if it contains pragmas).
</li><li> <code>empty_visible_part</code> controls package specifications that contain
no declaration in the visible part (before the word <code><b>private</b></code>
if any), even if it contains pragmas.
</li><li> <code>enumeration_type</code> controls the declaration of enumeration types.
</li><li> <code>exception</code> controls exception declarations.
</li><li> <code>expression_function</code> controls declaration of expression functions
</li><li> <code>extension</code> controls type extensions, i.e. derivations from a tagged type
with a <code><b>with record</b></code> extension part.
</li><li> <code>fixed_type</code> controls all declarations of fixed point types while
<code>ordinary_fixed_type</code> controls only ordinary (binary) fixed point
types, <code>ordinary_fixed_type_no_small</code> controls ordinary fixed
point type without a representation clause for <code>'SMALL</code>,
<code>ordinary_fixed_type_with_small</code> controls ordinary fixed point
type with an explicit representation clause for <code>'SMALL</code>, and
<code>decimal_fixed_type</code> controls only decimal fixed point types
(those can never have a representation clause for <code>'SMALL</code>).
</li><li> <code>float_type</code> controls declarations of floating point types.
</li><li> <code>formal_function</code>, <code>formal_package</code>,
<code>formal_procedure</code>, and <code>formal_type</code> control all generic
formal functions, packages, procedures, and types,
respectively. <code>box_defaulted_formal_function</code>,
<code>box_defaulted_formal_procedure</code>, <code>name_defaulted_formal_function</code>,
<code>name_defaulted_formal_procedure</code>, and
<code>null_defaulted_formal_procedure</code> control generic formal
functions and procedures with a box default, a name default, and a
null default, respectively.
</li><li> <code>generic_function</code>, <code>generic_package</code>,
<code>generic_procedure</code> control generic function (respectively
package, procedure) declarations.
</li><li> <code>handlers</code> controls the presence of exception handlers in any
handled sequence of statements.
</li><li> <code>in_out_parameter</code> and <code>out_parameter</code> control subprogram
and entry parameters of modes <code><b>in</b></code> <code><b>out</b></code> and
<code><b>out</b></code> (respectively), while <code>in_out_generic_parameter</code>
and <code>out_generic_parameter</code> do the same for <i>generic</i> formal
parameters. Note that to avoid unnecessary messages, if a subprogram
has an explicit specification, the message is given on the
specification and not repeated on the body.
</li><li> <code>incomplete_type</code> controls (regular) incomplete type
declarations, while <code>tagged_incomplete_type</code> controls tagged
incomplete type declarations (Ada 2005).
</li><li> <code>initialized_variable</code> controls variable declarations that
include an initialization expression, unless they are of a class-wide
type since initialization is required in that case.
</li><li> <code>instantiation</code> controls all instantiations, while
<code>function_instantiation</code>, <code>package_instantiation</code>,
<code>procedure_instantiation</code> control function (respectively package,
procedure) instantiations.
</li><li> <code>integer_type</code> controls all declarations of integer types, while
<code>signed_type</code> controls only signed integer types, and
<code>modular_type</code> controls only modular types (both kinds);
<code>binary_modular_type</code> controls only modular types whose modulus
is a power of 2, and <code>non_binary_modular_type</code> controls only
modular types whose modulus is not a power of 2.
</li><li> <code>initialized_record_component</code> and
<code>initialized_protected_component</code> control the declaration of
record (respectively protected) component that include a default
initialization, while <code>uninitialized_record_component</code> and
<code>uninitialized_protected_component</code> control the declaration of record
(respectively protected) component that do not include a default
initialization, unless they are of a limited type since initialization would
not be allowed in that case.
</li><li> <code>limited_private_type</code> controls limited private type
declarations, while <code>non_limited_private_type</code> controls regular
(non limited) private type declarations. <code>tagged_private_type</code>
controls tagged private type declarations.
</li><li> <code>multiple_names</code> controls declarations where more than one
defining identifier is given in the same declaration.
</li><li> <code>multiple_protected_entries</code> controls protected definitions (from
protected types or single protected objects) that have more than one
entry declaration. Note that a protected definition with a single
entry family declaration is counted as a single entry declaration.
</li><li> <code>named_number</code> controls declarations of named numbers,
i.e. untyped constants.
</li><li> <code>no_spec_function</code> and <code>no_spec_procedure</code> control function
and procedure bodies respectively, including body stubs (but not
proper bodies since the control is on the stub), that do not have an
explicit specification.
</li><li> <code>non_joint_CE_NE_handler</code> controls exception handlers whose
choices include <code>Constraint_Error</code> or <code>Numeric_Error</code>, but
not both. This is intended for legacy Ada 83 code that required to
always handle these exceptions together; it makes little sense for
Ada95 or Ada2005 code (and to be honnest, this subrule is provided
because Gnatcheck has it).
</li><li> <code>null_extension</code> controls record extensions (derived tagged
types) that contain no new elements. Similarly,
<code>null_ordinary_record_type</code> and <code>null_tagged_type</code> control
ordinary records and tagged types that contain no elements. Note that
the record definitions may be plain “<code><b>null</b></code>
<code><b>record</b></code>” definitions, or full record definitions that
contain only null components. However, a definition is not considered
null if it contains a variant part.
</li><li> <code>null_procedure_body</code> controls procedure declarations whose
sequence of statements contain only <code><b>null</b></code> statements (or
blocks without declarations and containing only <code><b>null</b></code>
statements). <code>null_procedure_declaration</code> controls Ada2005 null
procedure declarations (i.e., “<b>procedure</b> P <b>is</b>
<b>null</b>;”). <code>null_procedure</code> controls both.
</li><li> <code>operator</code> controls the definition of operators (things like
<code>"+"</code>); note that the message is given on the specification if
there is an explicit specification, on the body
otherwise. <code>equality_operator</code> controls only equality operators
(<code>"="</code> and <code>"/="</code>) and <code>predefined_operator</code> controls
only operator definitions that overload a predefined operator (like
<code>"+"</code> on a numeric type, for example).
</li><li> <code>package_statements</code> controls the presence of elaboration
statements in the bodies of packages (or generic packages).
</li><li> <code>private_extension</code> controls private extensions, i.e. derivations
from a tagged type with a <code><b>with private</b></code> extension part.
</li><li> <code>record_type</code> controls all record type declarations (tagged or
not), while <code>ordinary_record_type</code> controls only non-tagged
record types, and <code>tagged_type</code> controls only tagged record types.
</li><li> <code>interface_type</code> controls interface type declarations.
</li><li> <code>relay_function</code> controls functions whose statement part includes
only a single <code><b>return</b></code> statement whose expression is another
function call; similarly, <code>relay_procedure</code> controls procedures
whose statement part includes only a call to another procedure, and
<code>relay_package</code> controls packages whose visible part includes
only the declaration of another package (regular package,
instantiation of a generic package, or renaming of package).
</li><li> <code>renaming</code> controls all renaming declarations, while
<code>renaming_as_body</code> controls only those that are renamings as
bodies of subprograms, <code>renaming_as_declaration</code> controls only
those that are regular renamings of subprograms (i.e. not as bodies),
<code>operator_renaming</code> controls only those that are renamings of an
operator, <code>not_operator_renaming</code> controls only those that are
<em>not</em> renamings of an operator, <code>function_call_renaming</code>
controls renaming of the result of a function call, and
<code>library_unit_renaming</code> controls renaming of library units.
<code>non_identical_renaming</code> controls only renamings where the new
name and the old name are not the same, and
<code>non_identical_operator_renaming</code> does the same, but only for
renamings of operators. <code>synonym_renaming</code> controls renamings declared in
the same declarative part as the entity being renamed (these serve no purpose
as far as visibility is concerned, and are thus pure synonyms).
</li><li> <code>self_calling_function</code> controls functions whose body contains
only a single (simple) <code><b>return</b></code> statement, and the return
expression is a (recursive) call to the same function. Similarly,
<code>self_calling_procedure</code> controls procedures whose body contains
only a single statement which is a (recursive) call to the same
procedure. Note that this corresponds to bodies automatically
generated by gnatstub.
</li><li> <code>subtype</code> controls all explicit subtype declarations (i.e. not
all anonymous subtypes that appear at various places in the
language), while <code>unconstrained_subtype</code> controls only the
subtype declarations that do not include a constraint.
</li><li> <code>task</code> controls task type declarations as well as single tasks
declarations while <code>single_task</code> and <code>task_type</code> control
only single task declarations or task type declarations respectively
(and similarly for <code>protected</code>). <code>non_ravenscar_task</code> controls
all task type and task object declarations from a unit to which no
<code>pragma Profile (Ravenscar)</code> applies.
</li><li> <code>type</code> controls all type (but not subtype) declarations.
</li><li> <code>uninitialized_variable</code> controls variable declarations that
do not include an initialization expression. Depending on the value of
the rule variable “limited_initialization” (see below), variables of
a limited type, or only variables of a task or protected type, are not
reported, since initialization would not be allowed in that case.
</li><li> <code>variable</code> controls all variable declarations.
<code>scalar_variable</code> controls the declarations of variables of a
scalar type (integer, enumeration, float, fixed).
<code>ordinary_record_variable</code> controls declarations of variables of
an untagged record type. <code>tagged_variable</code> controls declarations
of variables of a tagged type (including class-wide ones), while
<code>class_wide_variable</code> controls only the declarations of variables
of a class-wide type. <code>task_variable</code> and
<code>protected_variable</code> control task and protected objects
(respectively), whether given with a named or anonymous type.
</li><li> <code>variant_part</code> controls variant parts in record defintions.
</li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">-- No task, no exception:
search declarations (task, exception);
-- Don't declare subprograms or packages inside a block:
check declarations (block procedure, block function, block package);
-- No task in the public part of a package:
check declarations (public task);
-- Generics allowed only as top-level units
check declarations (not library generic);
</pre></div>
<a name="Variable"></a>
<h4 class="subsection">5.10.3 Variable</h4>
<p>The rule provides a variable that allows to adjust the handling of
limited types for the subrule
“uninitialized_variable”. Initialization of variables of a limited
type was not permitted until Ada 2005.
</p>
<table>
<tr><td width="25%"><b>Variable</b></td><td width="10%"><b>Values</b></td><td width="10%"><b>Default</b></td><td width="55%"><b>Effect</b></td></tr>
<tr><td width="25%">Limited_Initialization</td><td width="10%">off<br>on</td><td width="10%">off</td><td width="55%"><dl compact="compact">
<dt>off</dt>
<dd><p>uninitialized variables of a limited type are never reported.
</p></dd>
<dt>on</dt>
<dd><p>uninitialized variables of a limited type are are reported like
non-limited variables, unless they are of a task or protected type,
since no initialization would be allowed in that case.
</p></dd>
</dl></td></tr>
</table>
<a name="Tips-7"></a>
<h4 class="subsection">5.10.4 Tips</h4>
<p>Certain keywords are <i>not</i> exclusive, and it may be the case that
several keywords apply to the same declaration; in this case, they are
all reported. For example, if you specify:
</p><div class="example">
<pre class="example">check declarations (record_type, tagged_type);
</pre></div>
<p>tagged types will be reported both as “record_type” and
“tagged_type”.
</p>
<p>There is no subrule for checking functions whose result type is from
an anonymous access type; these are controlled by the rule
<code>return_type (anonymous_access)</code>. See <a href="#Return_005fType">Return_Type</a>.
</p>
<p>Some of the keyword do not seem very useful; it would be strange to
have a programming rule that prevents all type declarations... But
bear in mind that the <location_kw> can be used to restrict the check
to certain locations; moreover, AdaControl can be used not only for
checking, but also for searching; finding all type declarations in a
set of units can make sense. As another example, “search declarations
(own variable);” will find all variables declared directly in package
bodies.
</p>
<p>Some modifiers do not make sense with certain declarations; for
example, a “private out_parameter” is impossible (a parameter
occurs in a subprogram declaration, not <i>directly</i> in a private
part). This is not a problem as far as the rule is concerned, but
don’t expect to find any...
</p>
<p>Generally, discriminants are considered components of record
types. However, discriminants of an anonymous access type (so-called
access discriminants) play such a special role in the language that
they deserved their own control
(<code>anonymous_access_discriminant</code>).
</p>
<p>Private types are normally followed in determining the kind of access
type (i.e., an access to a private type will be controlled according
to the full declaration). However, this is not done for an access type
that designates a private type defined in a language defined unit
(since the full type depends on the implementation); these are
controlled as “access_language_type” instead. Of course, language
defined <i>visible</i> types are controlled normally.
</p>
<a name="Limitation-3"></a>
<h4 class="subsection">5.10.5 Limitation</h4>
<p>In some rare cases, AdaControl may not be able to evaluate the modulus
of a modular type definition, thus preventing correct operation of
“binary_modular_type” and “non_binary_modular_type” subrules. Such
cases are detected by the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Default_005fParameter"></a>
<div class="header">
<p>
Next: <a href="#Dependencies" accesskey="n" rel="next">Dependencies</a>, Previous: <a href="#Declarations" accesskey="p" rel="prev">Declarations</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Default_005fParameter-1"></a>
<h3 class="section">5.11 Default_Parameter</h3>
<p>This rule checks usage (or non-usage) of defaulted parameters.
</p><a name="Syntax-10"></a>
<h4 class="subsection">5.11.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> default_parameter (<place>, <formal>, <usage>);
<place> ::= <entity> | calls | instantiations
<formal> ::= <formal name> | all
<usage> ::= used | positional | not_used
</pre></div>
<a name="Action-10"></a>
<h4 class="subsection">5.11.2 Action</h4>
<p>The rule controls subprogram calls or generic instantiations that use
the default value for the indicated parameter, or conversely don’t use
it, either in positional notation or in any notation. If a subprogram
is called, or a generic instantiated, whose name matches <entity>, and
it has a formal whose name is <formal name>, then:
</p><ul>
<li> If the string <code>used</code> (case irrelevant) is given as the third
parameter, the rule reports when there is no corresponding actual
parameter (i.e. the default value is used for the parameter).
</li><li> If the string <code>positional</code> (case irrelevant) is given as the
third parameter, the rule reports when there is an explicit
corresponding actual parameter (i.e. the default is not used for the
parameter), and the actual uses positional (not named) notation.
</li><li> If the string <code>not_used</code> (case irrelevant) is given as the third
parameter, the rule reports when there is an explicit corresponding
actual parameter (i.e. the default is not used for the parameter),
independently of whether it uses positional or named notation.
</li></ul>
<p>As usual, the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. On the other hand,
<formal> is the simple name of the formal parameter.
</p>
<p>Alternatively, the <entity> can be specified as <code>calls</code>, to
control all calls or <code>instantiations</code>, to control all
instantiations. The <formal name> can be replaced by <code>all</code>, in
which case all formals are controlled.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check default_parameter (P, X, used);
check default_parameter (P, Y, not used);
search default_parameter (calls, all, positional);
</pre></div>
<a name="Tip"></a>
<h4 class="subsection">5.11.3 Tip</h4>
<p>If the <entity> is a generic subprogram, it is also possible to give a
formal parameter (a parameter of the subprogram, not a generic
parameter) as the <formal name>; in this case, all instantiations of
the indicated generic subprogram will be controlled for the use of the
indicated parameter.
</p>
<hr>
<a name="Dependencies"></a>
<div class="header">
<p>
Next: <a href="#Derivations" accesskey="n" rel="next">Derivations</a>, Previous: <a href="#Default_005fParameter" accesskey="p" rel="prev">Default_Parameter</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Dependencies-1"></a>
<h3 class="section">5.12 Dependencies</h3>
<p>This rule controls dependencies of units (i.e. <code><b>with</b></code>
clauses, parents, child units...), either according to a set of
allowed/forbidden units, or by count.
</p>
<a name="Syntax-11"></a>
<h4 class="subsection">5.12.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> dependencies (others, <unit> {,<unit>});
<control_kind> dependencies (with, <unit> {,<unit>});
<control_kind> dependencies (public_child | private_child);
<control_kind> dependencies (<counter>, <bound> [, <bound>]);
<counter> ::= raw | direct | parent
<bound> ::= min | max <value>
</pre></div>
<a name="Action-11"></a>
<h4 class="subsection">5.12.2 Action</h4>
<p>The kind of action depends on the specified subrule.
</p>
<p>The “others” subrule controls semantic dependencies to units other
than those indicated. This subrule can be specified only once, and at
least one unit must be given.
</p>
<p>The “with” subrule controls with clauses that reference the
indicated units. At least one unit must be given.
</p>
<p>Note that for these two rules, renamings are followed: if you give the
basic name of a unit, it will be identified even if used with other
names. Similarly, if you give the name of a generic, all of its
instantiations will also be controlled.
</p>
<p>“public_child” and “private_child” control units that depend on
their own public (respectively private) child units. Since these
subrules have no parameters, they can be given only once.
</p>
<p>Other subrules control that the number of various dependencies is
whithin a specified range. The second (and optionnally third)
parameter give the minimum and/or maximum allowed values (i.e. the
rule will control values outside the indicated interval). If not
specified, the minimum value is defaulted to 0 and the maximum value
to infinity.
</p><ul>
<li> “raw” controls the number of units textually given in
<code><b>with</b></code> clauses. Redundant <code><b>with</b></code> clauses are
counted, and a child unit counts for one.
</li><li> “direct” controls the number of different units that this unit
really depends on: if a unit is mentionned in several <code><b>with</b></code>
clauses, it is counted only once, but if a child unit is mentionned,
all parents of this child unit are added to the count.
</li><li> “parent” counts the number of parents of the current unit. A root
unit has no parent, a child of a root unit has one parent, etc.
</li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">check dependencies (others, Ada.Text_IO);
check dependencies (raw, max 15);
-- child units should not be nested more than 5 levels:
check dependencies (parent, max 5);
-- units that depend on nothing:
search dependencies (direct, min 1);
-- units that depend on their public children:
check dependencies (public_child);
</pre></div>
<a name="Tips-8"></a>
<h4 class="subsection">5.12.3 Tips</h4>
<p>If you give a name that’s already a renaming to the “others” or
“with” subrules, the rule will only apply to this name, not to what
has been renamed. Therefore:
</p><div class="example">
<pre class="example"> -- Allow only Ada.Text_IO:
check dependencies (others, Ada.Text_IO);
-- But not if the plain name Text_IO is used:
check dependencies (with, Text_IO);
</pre></div>
<p>The notion of public or private for the rules “public_child” or
“private_child” refer to the real unit, which is not necessarily the
name used in the with clause, if for example you have a private
library renaming of a public unit.
</p>
<p>There is a slight overlap between this rule and the rule
“entities’. But “entities” will find all uses of an entity (not
necessarily a compilation unit), while “dependencies” will control
occurrences only of compilation units, and only in <code><b>with</b></code>
clauses. See <a href="#Entities">Entities</a>.
</p>
<p>In certain contexts, only a set of the Ada predefined units is
allowed. For example, it can be useful to forbid units defined in
special needs annexes. The <code>rules</code> directory of Adacontrol
contains files with “Dependencies” rules that forbid the use of
various predefined Ada units. Comment out the lines for the units that
you want to allow. You can then simply “source” these files from
your own command file (or copy the content) if you want to disallow these
units. See <a href="#command-files-provided-with-AdaControl">command files provided with AdaControl</a>.
</p>
<hr>
<a name="Derivations"></a>
<div class="header">
<p>
Next: <a href="#Directly_005fAccessed_005fGlobals" accesskey="n" rel="next">Directly_Accessed_Globals</a>, Previous: <a href="#Dependencies" accesskey="p" rel="prev">Dependencies</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Derivations-1"></a>
<h3 class="section">5.13 Derivations</h3>
<p>This rule controls various properties of the declaration of derived types.
</p>
<a name="Syntax-12"></a>
<h4 class="subsection">5.13.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> derivations (from, <entity>|<category>
{, <entity>|<category>})
<control_kind> derivations (max_parents, <value>)
<category> ::= () | access | array | delta | digits | mod |
private | protected | range | record | tagged | task
</pre></div>
<a name="Action-12"></a>
<h4 class="subsection">5.13.2 Action</h4>
<p>The “from” subrule controls derivations according to the parent
type and progenitors.
</p>
<p>If <entity> is a type name, it controls types that are derived
(directly or indirectly) from the given type (including interfaces),
or one of its subtypes; however, if it is a <i>subtype</i> name, only
types that are derived (directly or indirectly) from the given subtype
are controlled. If <entity> is the name of a compilation unit, it
controls types that are derived (directly or indirectly) from a type
(or subtype) declared inside the given unit. As usual, the whole
syntax for entities is allowed for <entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</p>
<p>If <category> is given, it controls derived types whose parent type
belongs to the corresponding category. The meaning of <category> is:
</p><ul>
<li> “()”: The parent is of an enumerated type.
</li><li> “access”: The parent is of an access type.
</li><li> “array”: The parent is of an array type.
</li><li> “delta”: The parent is of a fixed point type (it is not currently
possible to distinguish ordinary fixed point types from decimal fixed
point types).
</li><li> “digits”: The parent is of a floating point type.
</li><li> “mod”: The parent is of a modular type.
</li><li> “private”: The parent is of a private type (including private
extensions).
</li><li> “protected”: The parent is of a protected type.
</li><li> “range”: The parent is of a signed integer type.
</li><li> “record”: The parent is of an (untagged) record type.
</li><li> “tagged”: The parent is of a tagged type (including type
extensions).
</li><li> “task”: The parent is of a task type.
</li></ul>
<p>It may be the case that several controls apply to a given parent
type. In this case, only one message is issued, that corresponds to
the most specific control according to the following priority order:
</p><ol>
<li> Specific subtype
</li><li> Specific type
</li><li> Type or subtype from a compilation unit
</li></ol>
<p>If a category also applies to the parent type, a separate message is
always issued.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check derivations (from, Standard.Integer);
-- Types derived from Integer
search derivations (from, standard);
-- Types derived from a type in Standard, except Standard.Integer
-- (caught above)
search derivations (from, range);
-- Types derived from an integer type
</pre></div>
<p>The “max_parents” subrule controls the maximum number of parents in
a derivation. The parents are the direct ancestor in a derived type
definition, plus all of the progenitors (the interfaces that are
implemented by the type). <n> is the maximum number of <i>allowed</i>
parents, i.e. the rule is triggered if the number of parents is
strictly greater than <n>.
</p>
<p>This subrule can be given once for each of check, search, and
count. This way, it is possible to have a number of parents
considered a warning (search), and one considered an error (check). Of
course, this makes sense only if the number for search is less than
the one for check.
</p>
<div class="example">
<pre class="example">check derivations (max_parents, 5); -- error if more than 5 parents
search derivations (max_parents, 3); -- warning if more than 3 parents
</pre></div>
<hr>
<a name="Directly_005fAccessed_005fGlobals"></a>
<div class="header">
<p>
Next: <a href="#Duplicate_005fInitialization_005fCalls" accesskey="n" rel="next">Duplicate_Initialization_Calls</a>, Previous: <a href="#Derivations" accesskey="p" rel="prev">Derivations</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Directly_005fAccessed_005fGlobals-1"></a>
<h3 class="section">5.14 Directly_Accessed_Globals</h3>
<p>This rule checks that global variables in package bodies are accessed
only through dedicated subprograms. Especially, it can be used to
prevent race conditions in multi-tasking programs.
</p><a name="Syntax-13"></a>
<h4 class="subsection">5.14.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> directly_accessed_globals [(<kind> {,<kind>})];
<kind> ::= plain | accept | protected
</pre></div>
<a name="Action-13"></a>
<h4 class="subsection">5.14.2 Action</h4>
<p>The rule controls global variables declared directly in (generic)
package bodies that are accessed outside of dedicated callable
entities (i.e. procedure or function, possibly protected, protected
entries, and <code><b>accept</b></code> statements).
</p>
<p>This rule can be specified only once. The parameters indicate which
kinds of callable entity are allowed: “plain” for non-protected
subprograms, “protected” for protected subprograms, and “accept”
for <code><b>accept</b></code> statements). Without parameters, all forms are
allowed.
</p>
<p>More precisely, the rule ensures that the global variables are read
from a single callable entity, and written by a single callable
entity. Note that the same callable entity can read and write a
variable, but in this case no other callable entity is allowed to read
or write the variable.
</p><ul>
<li> Subprograms used to read/write the variables must be declared at the
same level as the variable itself (i.e. not nested), and must not be
generic.
</li><li> Protected subprograms used to read/write the variables must both be
part of the same single protected object, which must be declared at
the same level as the variable itself (i.e. not nested); they are not
allowed to be declared in a protected <i>type</i>, since if there are
several protected objects of the same type, mutual exclusion would not
be enforced.
</li><li> <code><b>accept</b></code> statements used to read/write the variables must
both be part of the same single task object, which must be declared at
the same level as the variable itself (i.e. not nested); they are not
allowed to be declared in a task <i>type</i>, since if there are several
task objects of the same type, mutual exclusion would not be enforced.
</li></ul>
<p>In short, this rule enforces that all global variables are accessed by
dedicated access subprograms, and that only those subprograms access
the variables directly. If given with the keyword “protected” and/or
“accept”, it enforces that global variables are accessed only by
dedicated protected subprograms or tasks, ensuring that no race condition is
possible.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check directly_accessed_globals
</pre></div>
<a name="Tips-9"></a>
<h4 class="subsection">5.14.3 Tips</h4>
<p>Note that this rule controls global variables from package <i>bodies</i>,
not those from the specification. This is intended, since it makes
little sense to declare a variable in a specification, and then
require it not to be accessed directly, but through provided
subprograms. Obviously, in this case the variable should be moved to
the body.
</p>
<p>Note that AdaControl can check that no variable is declared in a
package specification with the following rule:
</p><div class="example">
<pre class="example">check usage (variable, from_spec);
</pre></div>
<p>see <a href="#Usage">Usage</a> for details.
</p>
<a name="Limitations-5"></a>
<h4 class="subsection">5.14.4 Limitations</h4>
<p>AdaControl cannot check entities accessed through dynamic names
(dynamic renaming, access on aliased variables). Use of such
constructs is detected by the rule “uncheckable”.
See <a href="#Uncheckable">Uncheckable</a>.
</p>
<p>Due to a weakness in the ASIS standard, it is not possible to know the
mode (<b>in</b>, <b>out</b>) of variables used as parameters of dispatching
calls. Such variables are considered to be read and written at the
point of the call, therefore possibly creating false positives (which
is safer than false negatives). Use of such constructs is detected by
the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Duplicate_005fInitialization_005fCalls"></a>
<div class="header">
<p>
Next: <a href="#Entities" accesskey="n" rel="next">Entities</a>, Previous: <a href="#Directly_005fAccessed_005fGlobals" accesskey="p" rel="prev">Directly_Accessed_Globals</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Duplicate_005fInitialization_005fCalls-1"></a>
<h3 class="section">5.15 Duplicate_Initialization_Calls</h3>
<p>This rule checks that some procedures (notably initialization
procedures) are not called several times in identical conditions.
</p><a name="Syntax-14"></a>
<h4 class="subsection">5.15.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> duplicate_initialization_calls (<entity> {, <entity>});
</pre></div>
<a name="Action-14"></a>
<h4 class="subsection">5.15.2 Action</h4>
<p>This rule controls calls to initialization procedures that are
duplicated. The <entity> parameters are the initialization procedures
to be controlled. As usual, the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</p>
<p>More precisely, the initialization procedures must follow one of these
patterns:
</p><ul>
<li> The procedure only has <code><b>in</b></code> parameters. All actual parameters
used in calls are static, and not two calls have the same values for
all parameters.
</li><li> The procedure has exactly one <code><b>out</b></code> parameter (and no
<code><b>in out</b></code> parameter). Not two calls refer the same actual variable
for the <code><b>out</b></code> parameter.
</li></ul>
<p>The rule controls any violation of these patterns. If a procedure passed as parameter
does not have a profile that corresponds to one of the above patterns, it is an error.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check duplicate_initialization_calls (pack.init_proc);
</pre></div>
<a name="Limitation-4"></a>
<h4 class="subsection">5.15.3 Limitation</h4>
<p>If a variable passed as an <code><b>out</b></code> parameter is not statically
determinable, it is not controlled by the rule. Such a case is
detected by the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Entities"></a>
<div class="header">
<p>
Next: <a href="#Entity_005fInside_005fException" accesskey="n" rel="next">Entity_Inside_Exception</a>, Previous: <a href="#Duplicate_005fInitialization_005fCalls" accesskey="p" rel="prev">Duplicate_Initialization_Calls</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Entities-1"></a>
<h3 class="section">5.16 Entities</h3>
<p>This rule is used to control usage of Ada entities, i.e. any declared
element (type, variables, packages, etc).
</p><a name="Syntax-15"></a>
<h4 class="subsection">5.16.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> entities ({[not] <location>} [instance] <entity>
{, {[not] <location>} [instance] <entity>});
<location> ::= block | library | local | nested | own |
private | public | in_generic | task_body
</pre></div>
<a name="Action-15"></a>
<h4 class="subsection">5.16.2 Action</h4>
<p>This rule controls all uses of the indicated entities,or only those
that appear within the specified locations. As usual, the whole syntax
for entities is allowed for <entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</p>
<p>When present, the <location_kw> restricts the places where the entity
is controlled. If it is preceded by “not”, the entity is
controlled except at this location. Several <location_kw> can be
given, in which case the entity is controlled at places where all the
keywords apply.
</p><ul>
<li> <code>block</code>: the entity appears in a block statement.
</li><li> <code>library</code>: the entity appears at library level.
</li><li> <code>local</code>: the entity appears in a local scope (i.e. not in
(generic) packages, possibly nested)
</li><li> <code>own</code>: the entity appers in a (generic) package body.
</li><li> <code>public</code>: the entity appears in the visible part of a
(generic) package.
</li><li> <code>private</code>: the entity appears directly in a private
part.
</li><li> <code>in_generic</code>: the entity appears directly or indirectly in a generic
specification or body.
</li><li> <code>task_body</code>: the entity appears directly in a task body.
</li></ul>
<p>If the given entity is a generic unit or an
entity declared inside a generic unit, all corresponding uses in all
instances will be reported. Uses of the generic entity itself will also
be reported normally, unless the keyword <code>instance</code> is given.
</p>
<p>Note that this rules reports on the use of the <i>entity</i>, not the
<i>name</i>: if an entity has been renamed, it will be found under its
various names.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search entities (Debug.Trace);
check entities (Ada.Text_IO.Float_IO.Put);
check entities (instance Ada.Unchecked_Conversion);
</pre></div>
<p>The second line will report on any use of a <code>Put</code> from any
instantiation of <code>Float_IO</code>. The third one will report only
on uses of instances of <code>Ada.Unchecked_Conversion</code>.
</p>
<a name="Tips-10"></a>
<h4 class="subsection">5.16.3 Tips</h4>
<p>This rule is safer than cross-references if you want to check where
certain entities are used, since it follows renamings but does not
report on homonyms of the intended entity.
</p>
<p>This rule can also be used to check for all occurrences of certain
attributes with the “<code>all <Attribute></code>” syntax. For example,
the following will report on any usage of <code>'Unchecked_Access</code>:
</p><div class="example">
<pre class="example">check entities (all 'Unchecked_Access);
</pre></div>
<p>If you want to make sure that certain compilation units are not used,
it is preferable to use the rule “Depencies (with,...)” rather than
“Entities”, because “Entities” will control all uses of the unit,
while “Dependencies” will control only those in <code><b>with</b></code>
clauses (which is of course sufficient).
</p>
<p>In certain contexts, it can be useful to forbid certain entities, like
those from <code>Standard</code>, <code>System</code>, or entities defined in
special needs annexes packages. The <code>rules</code> directory of
Adacontrol contains files with “Dependencies” and “Entities” rules
that forbid the use of various predefined Ada elements. Comment out
the lines for the elements that you want to allow. You can then
simply “source” these files from your own command file (or copy the
content) if you want to disallow these elements. See <a href="#command-files-provided-with-AdaControl">command files provided with AdaControl</a>.
</p>
<a name="Limitation-5"></a>
<h4 class="subsection">5.16.4 Limitation</h4>
<p>GNAT defines <code>Unchecked_Conversion</code> and
<code>Unchecked_Deallocation</code> as separate entities, rather than
renamings of <code>Ada.Unchecked_Conversion</code> and
<code>Ada.Unchecked_Deallocation</code>. As a consequence, it is necessary
to specify explicitely both forms if you want to make sure that the
corresponding generics are not used.
</p>
<hr>
<a name="Entity_005fInside_005fException"></a>
<div class="header">
<p>
Next: <a href="#Exception_005fPropagation" accesskey="n" rel="next">Exception_Propagation</a>, Previous: <a href="#Entities" accesskey="p" rel="prev">Entities</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Entity_005fInside_005fException-1"></a>
<h3 class="section">5.17 Entity_Inside_Exception</h3>
<p>This rule controls entities that appear within exception handlers.
</p><a name="Syntax-16"></a>
<h4 class="subsection">5.17.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> entity_inside_exception (<spec> {, <spec>});
<spec> ::= [not] <entity> | calls | entry_calls
</pre></div>
<a name="Action-16"></a>
<h4 class="subsection">5.17.2 Action</h4>
<p>This rule controls exception handlers that contain references to one
or several Ada entities specified as parameters. If the keyword
“calls” is given, it stands for all subprogram and entry calls. If
the keyword “entry_calls” is given, it stands for all entry calls
(task or protected). If an <entity> (or “calls” or “entry_calls”)
is preceded by the keyword “not”, it is not included in the list of
controlled entities (i.e. the entity is allowed in the exception
handler). This allows to make exceptions to a more general
specification of an entity, or to allow calls to well-defined
procedures if the keyword “calls” is given.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- No Put_Line in exception handlers:
check entity_inside_exception (ada.text_io.put_line);
-- No entry calls in exception handlers:
check entity_inside_exception (entry_calls);
-- No calls allowed, except to the Report_Exception procedure:
check entity_inside_exception (calls, not Reports.Report_Exception);
-- No Put allowed, except the one on Strings:
check entity_inside_exception (all Put,
not Ada.Text_IO.Put{Standard.String});
</pre></div>
<hr>
<a name="Exception_005fPropagation"></a>
<div class="header">
<p>
Next: <a href="#Expressions" accesskey="n" rel="next">Expressions</a>, Previous: <a href="#Entity_005fInside_005fException" accesskey="p" rel="prev">Entity_Inside_Exception</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Exception_005fPropagation-1"></a>
<h3 class="section">5.18 Exception_Propagation</h3>
<p>This rule controls that certain program units are guaranteed to never
propagate exceptions, or that local exceptions cannot propagate out of
their scope.
</p><a name="Syntax-17"></a>
<h4 class="subsection">5.18.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> exception_propagation
(local_exception);
<control_kind> exception_propagation
([<level>,] interface, <convention> {, <convention> });
<control_kind> exception_propagation
([<level>,] parameter, <entity> {, <entity>});
<control_kind> exception_propagation
([<level>,] task);
<control_kind> exception_propagation
(<level>, declaration);
</pre></div>
<a name="Action-17"></a>
<h4 class="subsection">5.18.2 Action</h4>
<p>The “local_exception” subrule controls a design pattern that ensures
that a local exception cannot propagate outside the scope where it is
declared. If an exception is declared within a block, a subprogram
body, an entry body, or a task body, then this body must have either a
handler for this exception or for <code><b>others</b></code>; this handler must
not reraise the exception; and no handler is allowed to raise
explicitely the exception. The subrule controls explicit
<code><b>raise</b></code> statements and calls to <code>Raise_Exception</code> and
<code>Reraise_Occurrence</code>, but it does not control exceptions raised
as a consequence of calling other subprograms.
</p>
<p>The other subrules control subprograms, tasks, or all declarations
that can propagate exceptions, while being used in contexts where it
is desirable to ensure that no exception can be propagated.
</p>
<p>A subprogram or task is considered as <em>not</em> propagating if:
</p><ol>
<li> it has an exception handler with a “<code><b>when others</b></code>” choice
</li><li> no exception handler contains a <code><b>raise</b></code> statement, nor any
call to <code>Ada.Exception.Raise_Exception</code> or
<code>Ada.Exception.Reraise_Occurrence</code>.
</li><li> no declaration from its own declarative part propagates exceptions.
</li></ol>
<p>A declaration is considered propagating if it includes elements that
could propagate exceptions. This is impossible to assess fully using
only static analysis, therefore the <level> parameter determines how
pessimistic (or optimistic) AdaControl is in determining the possibility
of exceptions. Possible values of the <level> parameter, and
their effect, are:
</p><ul>
<li> 0: expressions in declarative parts are not considered as propagating
(anything allowed, this is the default value for “interface”,
“parameter” and “task”. Not allowed for “declaration”).
</li><li> 1: all function calls (including operators) in declarations are
considered as potentially propagating exceptions, except those
appearing in named number declarations or scalar types declarations,
since those are required by the language to be static.
</li><li> 2: same as 1, plus every use of variables in expressions is considered
as potentially propagating.
</li><li> 3: same as 2, plus any declaration of objects (constants or variables)
is considered potentially propagating (not very useful for
“declaration”).
</li></ul>
<p>These subrules serve several purposes:
</p><ul>
<li> The “interface” subrule analyzes all subprograms to which an
<code>Interface</code> or <code>Export</code> pragma applies (with the given
convention(s)), and reports on those that can propagate
exceptions.
<p>Since it is dangerous to call an Ada subprogram that can propagate
exceptions from a language that has no exception (and especially C),
any such subprogram should have a “catch-all” exception handler.
</p></li><li> The “parameter” subrule accepts one or more fully qualified formal
parameter names (i.e. in the form of the parameter name prefixed by
the full name of its subprogram, see <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>). The subrule reports any subprogram that can propagate
exceptions and is used as the prefix of a <code>'Access</code> or
<code>'Address</code> attribute that appears as part of an actual value for
the indicated formal. Similarly, the indicated formal can also be the
name of a formal procedure or function of a generic. In this case, the
rule will report on any subprogram that can propagate exceptions and
is used as an actual in an instantiation for the given formal.
<p>Many systems (typically windowing systems) use call-back
subprograms. Although the native interface is generally hidden behind
an Ada binding, the call-back subprograms will eventually be called
from another language, and like for the “interface” subrule, any
such subprogram should have a “catch-all” exception handler.
</p></li><li> The “task” subrule reports any task that can propagate exceptions.
<p>Since tasks die silently if an exception is propagated out of
their body, it is generally desirable to ensure that every task has an
exception handler that (at least) reports that the task is being
completed due to an exception.
</p></li><li> The “declaration” subrule reports
any declaration that can propagate exceptions, irrespectively of where
it appears. In this case, the specification of <level> is required
and cannot be 0.
<p>It is sometimes desirable to make sure that no declaration raises an
exception, ever.
</p></li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">-- Make sure that C-compatible subprograms don't propagate exceptions:
check exception_propagation (interface, C);
-- Parameter CB of of procedure Pack.Register is used as a call-back
-- Make sure that not procedure passed to it can propagate exceptions.
check exception_propagation (parameter, Pack.Register.CB);
-- Make sure that tasks do not die silently due to unhandled exception:
check exception_propagation (task);
-- Make sure that no exception is raised by elaboration of declarations:
check exception_propagation (2, declaration);
</pre></div>
<p>The first example will report on any subprogram to which a
<code><b>pragma</b> Interface (C,...)</code> applies that can propagate
exceptions.
</p>
<p>If <code>Proc</code> is a procedure that can propagate exceptions, the
second example will report on every call like:
</p><div class="example">
<pre class="example">Pack.Register (CB => Proc'Access);
</pre></div>
<p>The third example will report on any task that can terminate silently due
to an unhandled exception.
</p>
<p>The fourth example will report on any declaration that makes use of
function calls or variables.
</p>
<a name="Tips-11"></a>
<h4 class="subsection">5.18.3 Tips</h4>
<p>Note that the registration procedure for a call-back can be designated
by an access type, but in this case, use the name of the formal for
the access type. For example, given:
</p><div class="example">
<pre class="example"><b>package</b> Pack <b>is</b>
<b>type</b> Acc_Proc <b>is</b> <b>access</b> <b>procedure</b>;
<b>type</b> Acc_Reg <b>is</b> <b>access</b> <b>procedure</b> (CB : Acc_Proc);
...
Ptr : Acc_Reg := ...;
</pre></div>
<p>You can give a rule such as:
</p><div class="example">
<pre class="example">check exception_propagation (parameter, Pack.Acc_Reg.CB);
</pre></div>
<p>All procedures registered by a call to <code>Pack.Ptr.<b>all</b></code> will be considered.
</p>
<p>The declaration of a <b>for</b> loop parameter is not checked by this
rule. In other words, the rule “check exception_propagation (2,
declaration)” will not issue a message for:
</p><div class="example">
<pre class="example"><b>for</b> I <b>in</b> Positive <b>range</b> 1 .. X <b>loop</b> ...
</pre></div>
<p>although formally the <i>declaration</i> of I could raise
Constraint_Error if X is negative. We consider that for the casual
user, Constraint_Error appears to be raised by the <b>for</b> loop
<i>statement</i>.
</p>
<a name="Limitations-6"></a>
<h4 class="subsection">5.18.4 Limitations</h4>
<p>An exception may be raised in a subprogram considered as not
propagating by this rule, if an exception handler calls a subprogram
that propagates an exception.
</p>
<p>The rule will not consider subprograms whose body is missing, or that
are not statically known (i.e. if a subprogram is registered through a
dereference of a pointer to subprogram), like in the following
example:
</p><div class="example">
<pre class="example">Pack.Register (CB => Pointer.<b>all</b>'Access);
</pre></div>
<p>Due to a weakness of the ASIS standard, references to subprograms that
appear in dispatching calls are not considered. This limitation will
be removed as soon as we find a way to work around this problem, but
the issue is quite difficult!
</p>
<p>These last two cases are detected by the rule
“uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Expressions"></a>
<div class="header">
<p>
Next: <a href="#Generic_005fAliasing" accesskey="n" rel="next">Generic_Aliasing</a>, Previous: <a href="#Exception_005fPropagation" accesskey="p" rel="prev">Exception_Propagation</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Expressions-1"></a>
<h3 class="section">5.19 Expressions</h3>
<p>This rule controls usage of various kinds of expressions.
</p><a name="Syntax-18"></a>
<h4 class="subsection">5.19.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> expressions (<subrule> {, <subrule>});
<subrule> ::= {<category>} <expression_kw>
<expression_kw> ::=
and | and_array |
and_binary | and_boolean |
and_then | array_aggregate |
array_named_others | array_non_static_range |
array_others | array_partial_others |
array_positional_others | array_range |
case | complex_parameter |
downward_conversion | dispatching_function_calls |
dynamic_function_calls | extendable_aggregate |
extension_aggregate | explicit_dereference |
fixed_multiplying_op | for_all |
for_some | function_calls |
if | if_elsif |
if_no_else | implicit_dereference |
in | inconsistent_attribute_dimension |
inherited_function_call | mixed_operators |
not | not_in |
or | or_array |
or_binary | or_boolean |
or_else | parameter_view_conversion |
prefixed_operator | real_equality |
record_partial_others | record_aggregate |
record_others | redispatching_function_calls |
slice | static_membership |
type_conversion | upward_conversion |
unconverted_multiplying_op | underived_conversion |
universal_range | unqualified_aggregate |
xor | xor_array |
xor_binary | xor_boolean
<category> ::=
<> | () | range | mod | delta | digits | array |
record | tagged | access | new | private | task | protected
</pre></div>
<a name="Action-18"></a>
<h4 class="subsection">5.19.2 Action</h4>
<p>This rule controls usage of certain forms of expressions. The rule can
be specified at most once for each subrule (i.e. subrules that accept
categories can be specified once for each combination of categories
and expression keyword).
</p>
<p>Categories are used by certain subrules to further refine the control.
They define categories of types to which they apply:
</p><ul>
<li> “<>”: Any type
</li><li> “()”: Enumerated types
</li><li> “range”: Signed integer types
</li><li> “mod”: Modular types
</li><li> “delta”: Fixed point types (no possibility to differentiate ordinary
and decimal fixed point types yet).
</li><li> “digits”: Floating point types
</li><li> “array”: Array types
</li><li> “record”: (untagged) record types
</li><li> “tagged”: Tagged types (including type extensions)
</li><li> “access”: Access types
</li><li> “new”: Derived types
</li><li> “private”: Private types
</li><li> “task”: Task types
</li><li> “protected”: Protected types
</li></ul>
<p>The subrule define the kind of expression being controlled:
</p><ul>
<li> <code>not</code>, <code>and</code>, <code>or</code>, <code>xor</code>, <code>and_then</code>,
<code>or_else</code>, <code>in</code>, and <code>not_in</code> control usage of the
corresponding logical operator (or short circuit form, or membership
test).
</li><li> <code>and_array</code>, <code>or_array</code>, and <code>xor_array</code> do the same,
but only for operators whose result type is an array type.
</li><li> <code>and_binary</code>, <code>or_binary</code>, and <code>xor_binary</code> do the same,
but only for operators whose result type is a modular type.
</li><li> <code>and_boolean</code>, <code>or_boolean</code>, and <code>xor_boolean</code> do the same,
but only for operators whose result type is <code>Standard.Boolean</code>.
</li><li> <code>array_aggregate</code> and <code>record_aggregate</code> control array and
record aggregates, respectively, while <code>unqualified_aggregate</code>
controls aggregates (both arrays and records) that do not appear
directly within a qualified expression. <code>extension_aggregate</code>
controls extension aggregates, while <code>extendable_aggregate</code>
controls aggregates that are <i>not</i> extension aggregates, but whose
type is a non-root tagged type, or are extension aggregates whose ancestor part
is not their immediate parent (such aggregates could be written as
extension aggregates).
</li><li> <code>array_others</code> and <code>record_others</code> control the occurrence of
a <code><b>others</b> =></code> association in array and record
aggregates, respectively.
</li><li> <code>array_partial_others</code> and <code>record_partial_others</code> do the
same, but only if there are other associations in addition to the
<code><b>others</b> =></code> in the aggregate. <code>array_named_others</code> and
<code>array_positional_others</code> do the same, but only for named
(respectively positional) array aggregates.
</li><li> <code>array_range</code> controls array aggregates that include a range
(i.e. an association like <code>A .. B =></code>).
<code>array_non_static_range</code> does the same, but only if (at least)
one of the bounds is not static.
</li><li> <code>case</code> controls <b>case</b> expressions (introduced in Ada 2012).
</li><li> <code>complex_parameter</code> controls complex expressions used as actual
parameters in subprogram (or entry) calls. A complex expression is any
expression that includes a function call (including operators). This
rule is not applied to the parameters of operators, since otherwise
it would forbid any expression with more than a single operator.
</li><li> <code>explicit_dereference</code> controls explicit dereferences of access
values (i.e. with an explicit <code>.<b>all</b></code>).
</li><li> <code>fixed_multiplying_op</code> controls calls to predefined fixed-point
multiplication and division (regular fixed-point or decimal-fixed
point). <code>unconverted_fixed_multiplying_op</code> does the same, but
only when both operands are objects (not literals) of a fixed_point
type (not Integer); this is when type conversion is required by Ada
83.
</li><li> <code>for_all</code> and <code>for_some</code> control the two forms of
quantifiers introduced by Ada 2012.
</li><li> <code>if</code> controls all <b>if</b> expressions (introduced in Ada 2012),
while <code>if_elsif</code> only controls those that have an <b>elsif</b> part,
and <code>if_no_else</code> only controls those that have no <b>else</b> part.
</li><li> <code>implicit_dereference</code> controls implicit dereferences of access
values (i.e. when the <code>.<b>all</b></code> is omitted).
</li><li> <code>inconsistent_attribute_dimension</code> controls when no dimension is
explicitely given for a <code>'First</code>, <code>'Last</code>, <code>'Range</code> or
<code>'Length</code> attribute and the attribute applies to a
multi-dimensional array, or conversely, when an explicit dimension is
given, but the attribute applies to a one-dimensional array.
</li><li> <code>function_call</code> controls all calls to functions, incuding user
defined operators, but not predefined operators (including the latter
would generate too much noise). <code>dispatching_function_call</code> does
the same, but only for dispatching calls while
<code>redispatching_function_call</code> does the same, but only for
dispatching calls that are (directly or indirectly) inside a primitive
operation of a tagged type. <code>dynamic_function_call</code> does the
same, but only for calls through
pointers. <code>inherited_function_call</code> controls calls to functions
that have been inherited by a derived type and not redefined.
<p>For all <code>*_function_call</code> subrules, if a category is specified,
only calls whose result type belongs to the category are controlled.
Derived types are followed, i.e. the “real” category from the
original type is used for the matching; as a consequence, the “new”
category cannot be specified for this subrule. In addition, the amount
of information displayed can be selected with the rule variable
“called_info” (see below).
</p>
</li><li> <code>mixed_operators</code> controls expressions that involve several
different operators, without parentheses. In a sense, it extends the
language rule that forbids mixing <code><b>and</b></code> and <code><b>or</b></code> in
logical expressions to all other operators. Note that for the purpose
of this subrule, membership tests (<code><b>in</b></code>, <code><b>not in</b></code>)
and short circuit forms (<code><b>and then</b></code>, <code><b>or else</b></code>) are
considered operators.
</li><li> <code>prefixed_operator</code> controls calls to operators that use prefixed
notation (i.e. <code>"+"(A, B)</code>). If a category is specified, only
calls whose result type belongs to the category are controlled.
<p>Derived types are followed, i.e. the “real” category from the
original type is used for the matching; as a consequence, the “new”
category cannot be specified for this subrule.
</p></li><li> <code>real_equality</code> controls usage of predefined exact equality or
inequality (“=” or “/=”) between real (floating point or fixed
point) values.
</li><li> <code>slice</code> controls usage of array slices.
</li><li> <code>static_membership</code> controls membership tests (<code><b>in</b></code> and
<code><b>not in</b></code>) where the expression on the left is statically
known to belong to the range (or subtype) on the right, and is
therefore always True (or false for <code><b>not in</b></code>).
</li><li> <code>type_conversion</code> controls all (sub)type conversions, while
<code>underived_conversion</code> controls conversions between types that do
<i>not</i> belong to the same derivation
family. <code>downward_conversion</code> and <code>upward_conversion</code>
control conversions between types that belong to the same family,
converting away from the root or toward the root,
respectively. <code>parameter_view_conversion</code> controls conversions
that appear as <code><b>out</b></code> or <code><b>in out</b></code> actual parameters.
<p>One or two categories can be specified; if only one category is
specified, only conversions whose result type belong to that category
are controlled. If two categories are specified, only conversions
whose souce type belongs to the first category and whose target type
belong to the second category are controlled.
</p>
<p>Derived types are followed, i.e. the “real” category from the
original type is used for the matching; as a consequence, the “new”
category cannot be specified for this subrule.
</p></li><li> <code>universal_range</code> controls discrete ranges that are a part of an
index constraint, constrained array definition, or for-loop parameter
specification (but not type or subtype defintions), and whose bounds
are both of type universal_integer.
</li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">search expressions (real_equality, slice);
check expressions (mixed_operators);
-- Find logical operators that could be replaced by short-circuits forms:
check expressions (and_boolean, or_boolean);
-- Find all conversions between integer and floating point types
search expression (range digits type_conversion);
-- Find all conversions from a fixed point type:
search expressions (delta <> type_conversion);
-- Find all view conversions between array types:
search expressions (array parameter_view_conversions);
-- Find all "structural" conversions between arrays
search expressions (array underived_conversion);
-- Some think that downward conversions of tagged types are evil:
check expressions (tagged downward_conversion);
</pre></div>
<a name="Fixes-2"></a>
<h4 class="subsection">5.19.3 Fixes</h4>
<p>The following subrules generate fixes:
</p><ul>
<li> “Mixed_Operators”: Parentheses are inserted appropriately.
</li></ul>
<a name="Variable-1"></a>
<h4 class="subsection">5.19.4 Variable</h4>
<p>The rule provides a variable that allows to specify the amount of information
displayed with the various *_function_calls subrules.
</p>
<table>
<tr><td width="12%"><b>Variable</b></td><td width="18%"><b>Values</b></td><td width="10%"><b>Default</b></td><td width="60%"><b>Effect</b></td></tr>
<tr><td width="12%">Called_Info</td><td width="18%">none<br>compact<br>detailed<br>root_detailed</td><td width="10%">none</td><td width="60%"><dl compact="compact">
<dt>“none”</dt>
<dd><p>No extra information.
</p></dd>
<dt>“compact”</dt>
<dd><p>display the name of the called function.
</p></dd>
<dt>“detailed”</dt>
<dd><p>display the name of the called function with overloading
information.
</p></dd>
<dt>“root_detailed”</dt>
<dd><p>display the name of the root called function (i.e. the
original function if the called function is a renaming) with overloading
information.
</p></dd>
</dl></td></tr>
</table>
<a name="Tips-12"></a>
<h4 class="subsection">5.19.5 Tips</h4>
<p>The <code>real_equality</code> subrule does not control calls to an equality
operator that has been defined by the user; actually, it would make
little sense to write a function and then forbid its use! However, if
control of calls to such a function is desired, it can be easily
accomplished by using the <code>entities</code> rule. See <a href="#Entities">Entities</a>.
</p>
<p>This rule does not check the use of allocators (<code><b>new</b></code>), use
the rule <code>Allocators</code> instead. See <a href="#Allocators">Allocators</a>.
</p>
<p>“inherited_function_call” controls only <i>function</i> calls. For
procedure calls, see rule <a href="#Statements">Statements</a>.
</p>
<p>Specifying <code>array_partial_others</code> is the same as specifying both
<code>array_named_others</code> and <code>array_positional_others</code>. It is
retained for compatibility, and also for symetry with
<code>record_partial_others</code>.
</p>
<p>Per language rules, underived conversions are allowed only between
numeric types, and between structurally equivalent array types.
</p>
<p>“static_membership” is handy for finding a common misuse of
membership tests, where the user assigns an external value (obtained
with Unchecked_Conversion for example) to a variable, then checks that the
variable belongs to its subtype to make sure the value is valid. Such a check
can be optimized away by the compiler; the ’Valid attribute should be
used instead.
</p>
<a name="Limitations-7"></a>
<h4 class="subsection">5.19.6 Limitations</h4>
<p>“static_membership” does not control the complex membership tests
with several choices that are possible with Ada 2012.
</p>
<hr>
<a name="Generic_005fAliasing"></a>
<div class="header">
<p>
Next: <a href="#Global_005fReferences" accesskey="n" rel="next">Global_References</a>, Previous: <a href="#Expressions" accesskey="p" rel="prev">Expressions</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Generic_005fAliasing-1"></a>
<h3 class="section">5.20 Generic_Aliasing</h3>
<p>This rule controls instantiations where the same actual is given to
more than one formal.
</p><a name="Syntax-19"></a>
<h4 class="subsection">5.20.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> generic_aliasing [(<subrule> {, <subrule>})];
<subrule> ::= [<condition>] <entity>
<condition> ::= unlikely | possible | certain
<entity> ::= all | variable | type | subprogram | package
</pre></div>
<a name="Action-19"></a>
<h4 class="subsection">5.20.2 Action</h4>
<p>This rule identifies instantiations where the same variable, type,
subprogram, or package is given several times (to different formal
parameters). Such aliasing of variables is dangerous, since it can
induce subtile bugs. Other elements are less dangerous, although often
questionable (depending on the generic).
</p>
<p>The <entity> parameter indicates for which elements aliasing is
controlled; “all” stands for all kinds of elements.
</p>
<p>There are many cases where aliasing cannot be determined
statically. The optional parameter specifies how aggressively the rule
will check for possible aliasings (see <a href="#Parameter_005fAliasing">Parameter_Aliasing</a> for a
more detailed description of these modifiers). Possible values are
(case irrelevant):
</p><ul>
<li> Certain (default): Only cases where aliasing is statically certain are
output.
</li><li> Possible: In addition, cases where aliasing may occur depending on the
value of an indexed component are output. This can be specified only
for variables.
</li><li> Unlikely: In addition, cases where aliasing may occur due to access
variables designating the same element are output. This can be
specified only for variables and subprograms.
</li></ul>
<p>Without any parameter, the rule is the same as “certain all”. The
rule can be specified only once for each combination of <condition>
and <entity>.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check generic_aliasing (certain variable);
search generic_aliasing (possible variable, type, subprogram, package);
</pre></div>
<a name="Limitations-8"></a>
<h4 class="subsection">5.20.3 Limitations</h4>
<p>Due to a limitation of ASIS for Gnat, AdaControl might not be able to
differentiate predefined operators of different types, and may thus
give false positives if a generic is instantiated with, for example,
two different functions that are actually <code>"+"</code> on Integer and
<code>"+"</code> on Float. This possibility of false positives is detected
by the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Global_005fReferences"></a>
<div class="header">
<p>
Next: <a href="#Header_005fComments" accesskey="n" rel="next">Header_Comments</a>, Previous: <a href="#Generic_005fAliasing" accesskey="p" rel="prev">Generic_Aliasing</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Global_005fReferences-1"></a>
<h3 class="section">5.21 Global_References</h3>
<p>This rule controls accesses to global elements that may be subject to
race conditions, or otherwise shared.
</p>
<a name="Syntax-20"></a>
<h4 class="subsection">5.21.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> global_references (<subrule> {, <root>});
<subrule> ::= all | read | written | multiple | multiple_non_atomic
<root> ::= <entity> | function | procedure | task | protected
</pre></div>
<a name="Action-20"></a>
<h4 class="subsection">5.21.2 Action</h4>
<p>This rule controls access to global variables from several entities
(the roots). The <code><entity></code> must be subprograms, task types,
single task objects, protected types, or single protected objects. As
usual, the whole syntax for entities is allowed for <entity>.
See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. The special keywords
<code>function</code>, <code>procedure</code>, <code>task</code>, and <code>protected</code>
are used to refer to all functions, procedures, tasks, and protected
entities, respectively.
</p>
<p>The <subrule> determines the kind of references that are
controlled. If it is <code>all</code>, all references to global elements
from the indicated entities are reported. If <subrule> is <code>read</code>
or <code>written</code>, only read (respectively write) accesses are
reported. If <subrule> is <code>multiple</code>, only global elements that
are accessed by more than one of the indicated entities (i.e. shared
elements) are reported. Note however that if a reference is found from
a task type or protected type, it is always reported, since there are
potentially several objects of the same type. If <subrule> is
<code>multiple_non_atomic</code>, references reported are the same as with
<code>multiple</code>, except that global variables that are <code>atomic</code>
or <code>atomic_components</code> and written from at most one of the
indicated entities are not reported. Note that this latter case
corresponds to a safe reader/writer use of atomic variables.
</p>
<p>This rule follows the call graph, and therefore finds references from
subprogram and protected calls made (directly or indirectly) from the
indicated entities. However, calls to subprograms from the Ada
standard library are not followed.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- Find global variables used by P1 or P2:
search global_references (all, P1, P2);
-- Find global variables modified by functions:
check global_references (written, function);
-- Find possible race conditions:
check global_references (multiple, task, protected);
</pre></div>
<p>This rule can be given several times, and conflicts (with
<code>multiple</code>) are reported on a per-rule basis, i.e. given:
</p><div class="example">
<pre class="example">check global_references (multiple, P1, P2);
check global_references (multiple, P1, P3);
</pre></div>
<p>the first rule will report on global variables shared between P1 and
P2, and the second rule will report on global variables shared between
P1 and P3.
</p>
<a name="Tips-13"></a>
<h4 class="subsection">5.21.3 Tips</h4>
<p>The notion of “global” is relative, i.e. it designates every
variable whose scope encloses (strictly) the indicated entities. This
means that a same reference may or may not be global, depending on the
indicated entity. Consider:
</p>
<div class="example">
<pre class="example"><b>procedure</b> Outer <b>is</b>
Inner_V : Integer;
<b>procedure</b> Inner_P <b>is</b>
<b>begin</b>
Inner_V := 1;
<b>end</b> Inner_P;
<b>begin</b>
Inner_P;
<b>end</b> Outer;
</pre></div>
<p>The rule
</p><div class="example">
<pre class="example">check global_references (all, outer);
</pre></div>
<p>will not report any global reference, while the rule
</p><div class="example">
<pre class="example">check global_references (all, outer.inner_p);
</pre></div>
<p>will report a reference to <code>Inner_V</code>. This is as it should be,
since there is no race condition if several tasks call <code>Outer</code>,
while there is a risk if several tasks (declared inside <code>Outer</code>)
call <code>Inner_P</code>.
</p>
<p>Specifying:
</p><div class="example">
<pre class="example">check global_references (all, function);
</pre></div>
<p>will report on any function that access variables outside of their
scope, i.e. all functions that have potential side effects. On the
other hand, this check must follow the whole call graph for any
function encountered, and can therefore be quite costly in execution
time.
</p>
<a name="Limitations-9"></a>
<h4 class="subsection">5.21.4 Limitations</h4>
<p>Calls through pointers to subprograms and dispatching calls are
unknown statically; they are assumed to not access any global. Such
calls are detected by the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Header_005fComments"></a>
<div class="header">
<p>
Next: <a href="#Improper_005fInitialization" accesskey="n" rel="next">Improper_Initialization</a>, Previous: <a href="#Global_005fReferences" accesskey="p" rel="prev">Global_References</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Header_005fComments-1"></a>
<h3 class="section">5.22 Header_Comments</h3>
<p>This rule controls that every compilation unit starts with a
standardized comment.
</p><a name="Syntax-21"></a>
<h4 class="subsection">5.22.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> header_comments (minimum, <comment lines>);
<control_kind> header_comments (model, "<file name>");
</pre></div>
<a name="Action-21"></a>
<h4 class="subsection">5.22.2 Action</h4>
<p>If the keyword “minimum” is given as first parameter, this rule
controls that every compilation unit starts with at least the number
of comment lines indicated by the second parameter. If several forms
of headers are possible, checking that the headers follow the
project’s standard requires manual inspection, but this rule is useful
to control that unit headers have not been inadvertantly forgotten.
</p>
<p>If the keyword “model” is given as first parameter, the second
parameter is a string, interpreted as a file name. If the file name is
not an absolute path, it is interpreted as relative to the directory
of the file that contains the rule, or to the current directory if the
rule is given on the command line. Each line of the indicated file is
a regular expression, and the rule controls that the corresponding
line of the source file matches the expression. See <a href="#Syntax-of-regular-expressions">Syntax of regular expressions</a>. In addition, it is possible to specify a repetition
for a line. If the first character of a line is a <code>'{'</code>, the line
must have the following syntax:
</p><div class="example">
<pre class="example">{<min>,[<max>]}
</pre></div>
<p>where <min> and <max> specify the minimum and maximum number of
occurrences of the pattern in the line that follows this one. <min>
must be at least 0, and <max> must be at least 1, and be equal or
greater than <min>. If <max> is omitted, it means that the line may
occur any number of times.
</p>
<p>As a convenience, if the first character of a line is a <code>'*'</code>
it means that the next line is a pattern that can occur any number of
times (same as <code>{0,}</code>). If the first character is a
<code>'+'</code>, it means that the next line is a pattern that must occur
at least once (same as <code>{1,}</code>). If the first character is a
<code>'?'</code>, it means that the next line is an optional pattern (same
as <code>{0,1}</code>).
</p>
<p>Note that the repetition lines all start with a special character
which is not allowed at the start of a regular expression; there is
therefore no ambiguity. Everything after the special character (or the
closing <code>'}'</code>) is ignored, and can be used to provide comments.
</p>
<p>This rule can be given at most once with “minimum” for each of
“check”, “search”, and “count”. The rule can be given only once
with “model” (but it can be given together with one or more
“minimum” rules).
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check header_comments (minimum, 10);
search header_comments (model, "header.pat");
count header_comments (minimum, 20);
</pre></div>
<p>This makes an error for every unit that starts with less than 10
comment lines, and a warning for units that do not follow the pattern
contained in the file <code>header.pat</code>. A count of units that start
with less than 20 comment lines is reported.
</p>
<p>Example of a pattern file:
</p><div class="example">
<pre class="example">{1,3} 1 to 3 occurrences of next line
^--$
^-- Author: .+$
^-- Date: \d{2}/\d{2}/\\d{4}$
</pre></div>
<a name="Tips-14"></a>
<h4 class="subsection">5.22.3 Tips</h4>
<p>Remember that the lines of the file are regular expressions; every
character that is specially interpreted (like “+”, “*”, etc.) must
be quoted with “\” if it must appear textually. To ease the process
of generating the model file, the directory <code>source</code> contains a
script file for sed named <code>makepat.sed</code>; if you run this script
on a file that contains a standard header, it will produce a pattern
file where each line starts with “^”, ends with “$”, and every
special character is quoted with “\”.
</p>
<p>When the model contains an indication of repeated lines (“*”), the
repetition is not “greedy”, i.e. matching will stop as soon as what
follows the repetition matches. This is very useful to check header
comments that have sections, but where you don’t want to impose a
precise content to each section. Imagine for example that the structure is:
</p><ul>
<li> A comment with “HISTORY”
</li><li> Any number of comment lines
</li><li> A comment with “AUTHORS”
</li><li> Any number of comment lines
</li></ul>
<p>the following pattern will work as expected:
</p><div class="example">
<pre class="example">^-- HISTORY$
*
^--
^-- AUTHORS
*
^--
</pre></div>
<a name="Limitation-6"></a>
<h4 class="subsection">5.22.4 Limitation</h4>
<p>Since the “model” subrule analyzes the content of comments, there is
a conflict with the disabling mechanism of AdaControl that uses
special comments. See <a href="#Disabling-controls">Disabling controls</a>.
</p>
<p>Specifically, line disabling is not possible at all. Block disabling
is possible, provided the disabling line is allowed by the pattern. In
short, if you want to be able to disable this rule, the first lines of
the model file should be:
</p><div class="example">
<pre class="example">?
--##
</pre></div>
<p>i.e. allow an optional block disabling comment as the first line of
the file. Note that there is no need to re-enable this rule, since it
is checked only at the start of a compilation unit.
</p>
<hr>
<a name="Improper_005fInitialization"></a>
<div class="header">
<p>
Next: <a href="#Instantiations" accesskey="n" rel="next">Instantiations</a>, Previous: <a href="#Header_005fComments" accesskey="p" rel="prev">Header_Comments</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Improper_005fInitialization-1"></a>
<h3 class="section">5.23 Improper_Initialization</h3>
<p>This rule enforces a coding pattern that ensures that variables and
<code><b>out</b></code> parameters are properly initialized befor use.
</p><a name="Syntax-22"></a>
<h4 class="subsection">5.23.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> improper_initialization [(<subrule> {,<subrule>})]
<subrule> ::= {<extra>} <target>
<extra> ::= access | limited | package | return
<target> ::= out_parameter | variable | initialized_variable
</pre></div>
<a name="Action-22"></a>
<h4 class="subsection">5.23.2 Action</h4>
<p>This rule controls variables and/or <code><b>out</b></code> parameters that are
not “properly” initialized, i.e. those that are not “safely”
initialized, those that have a useless initialization in their
declaration, and those where the value is known to be used before
having been assigned. The notion of variable includes the return
object of an extended return statement (Ada 2005+).
</p>
<p>A variable (or <code><b>out</b></code> parameter) is considered safely
initialized if there is an initialization expression in its
declaration, or if it is given a value in the first statements of the
corresponding body, before any “non-trivial” statement. The goal is
not to perform a complete data-flow analysis, but rather to follow a
design pattern where all variables are initialized before entering the
“active” part of the algorithm. This makes it easier to ensure that
variables are properly initialized.
</p>
<p>“Trivial” statements are:
</p><ul>
<li> <code>null</code> statements;
</li><li> assignment statements;
</li><li> procedure calls;
</li><li> return statements;
</li><li> raise statements;
</li><li> extended return statements, unless they contain a nested non-trivial
statement.
</li><li> <code><b>if</b></code> and <code><b>case</b></code> statements, unless they contain a
nested non-trivial statement.
</li></ul>
<p>The <target> parameters determines what is to be checked:
</p><ul>
<li> <code>out_parameter</code> controls that <code><b>out</b></code> parameters are
safely initialized before the first non-trivial statement, and before
every (trivial) <code><b>return</b></code> statement. Note that <code><b>out</b></code>
parameters are <i>not</i> checked before <code><b>raise</b></code> statements,
since the language does not guarantee that <code><b>out</b></code> parameters
are transmitted back in the case of exceptions.
</li><li> <code>variable</code> controls that local variables are safely initialized
before the first non-trivial statement. If the <extra> modifier
<code>return</code> is specified, only return objects of extended return
statements are controlled.
</li><li> <code>initialized_variable</code> controls variables that are safely
initialized before the first non-trivial statement, but also have an
explicit (and therefore useless) explicit initialization in their
declaration. If the modifier <code>return</code> is specified, only return
objects of extended return statements are controlled.
</li></ul>
<p>In all cases, variables used in trivial statements before being
initialized are reported.
</p>
<p>A variable is considered initialized if it is the target of an
assignment statement, or if it is used as an actual for an
<code><b>out</b></code> (but not <code><b>in out</b></code>) parameter of a procedure
call. Variables assigned in <code><b>if</b></code> or <code><b>case</b></code>
statements must receive a value in all paths to be considered
initialized after the statement. Note that the variable must be
assigned to globally, i.e. assigning to some elements of an array, or
some fields of a record, does not count as an initialization of the
variable.
</p>
<p>Some variables are <i>not</i> controlled, unless the corresponding
<extra> modifier is given:
</p><ul>
<li> Variables declared immediately within a (generic) package
specification or body, since in general, package state variables are
initialized through calls to dedicated procedures. Use the “package”
modifier to control also package variables.
</li><li> Variables of an access types, or arrays whose components are of an
access type, since these are always initialized by the compiler. Use
the “access” modifier to control also variables of an access type.
</li><li> Variables of a limited type, since global assignment is not available
for them. Use the “limited” modifier to control also variables of a
limited type.
</li></ul>
<p>This rule can be given only once for each value of <target>. Without
parameters, it is equivalent to giving all, without any <extra>.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check improper_initialization (out_parameter);
check improper_initialization (access limited variable);
search improper_initialization (initialized_variable);
</pre></div>
<a name="Tips-15"></a>
<h4 class="subsection">5.23.3 Tips</h4>
<p><code>variable</code> and <code>initialized_variable</code> control also return
objects from extended return statements, since it would be strange to
guarantee safe initialization of local variables and not return
objects. On the other hand, the design pattern enforced by this rule
may seem to limitative for regular variables, but it might be
desirable to enforce it for return objects; hence the possibility to
limit the rule to return objects by specifying the <code>return</code>
modifier.
</p>
<a name="Limitations-10"></a>
<h4 class="subsection">5.23.4 Limitations</h4>
<p>Due to a weakness of the ASIS standard, dispatching calls and calls to
procedures that are attributes are not considered for the
initialization of variables. Note that for attributes, only
<code>'Read</code> and <code>'Input</code> have an <code><b>out</b></code> parameter.
</p>
<p>In the rare case where a variable is initialized by a dispatching call
or an attribute call, this limitation will result in a false
positive. Such a case is detected by the rule
“uncheckable”. See <a href="#Uncheckable">Uncheckable</a>. It is then easy to disable the
rule for this variable. See <a href="#Disabling-controls">Disabling controls</a>.
</p>
<p>The rule analyzes only initializations and uses that are directly in
the unit, not those from nested units, since these are in the general
case not statically checkable.
</p>
<p>There are other cases where an object is automatically initialized by
the declaration, like controlled types that have redefined the
<code>Initialize</code> procedure, records where all components have a
default initialization, etc. The rule does not consider these as
automatically initialized, as it does for access types. Maybe later...
</p>
<hr>
<a name="Instantiations"></a>
<div class="header">
<p>
Next: <a href="#Insufficient_005fParameters" accesskey="n" rel="next">Insufficient_Parameters</a>, Previous: <a href="#Improper_005fInitialization" accesskey="p" rel="prev">Improper_Initialization</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Instantiations-1"></a>
<h3 class="section">5.24 Instantiations</h3>
<p>This rule controls all instantiations of a generic, or only
instantiations that are made with specific values of the
parameters. Control can be restricted to instantiations in specified
places.
</p>
<a name="Syntax-23"></a>
<h4 class="subsection">5.24.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> instantiations (<generic_spec>);
<generic_spec> ::= {[not] <location_kw>} <entity> {, <formal_spec>}
<formal_spec> ::= <entity> | <category> | <> | =
<location_kw> ::= all | block | library | local | nested |
own | private | public | in_generic | task_body
<category> ::= () | access | array | delta | digits | mod |
private | protected | range | record | tagged | task
</pre></div>
<a name="Action-23"></a>
<h4 class="subsection">5.24.2 Action</h4>
<p>The rule controls instantiations of the specified <entity>. As usual,
the whole syntax for entities is allowed for <entity>.
See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</p>
<p>The <location_kw> restricts the places where the occurrence of the
instantiation is controlled. If it is preceded by “not”, the
instantiation is controlled except at this location. Several
<location_kw> can be given, in which case the instantiation is
controlled at places where all the keywords apply. If there is no
<location_kw>, it is assumed to be “all”.
</p><ul>
<li> <code>all</code>: puts no special restriction to the location. This keyword
can be specified for readability purposes, and if specified must
appear alone (not with other <location_kw>), and “not” is not
allowed.
</li><li> <code>block</code>: only instantiations appearing in block statements are
controlled.
</li><li> <code>library</code>: only library level instantiations are controlled.
</li><li> <code>local</code>: only local instantiations are controlled (i.e. only
instantiations appearing in (generic) packages, possibly nested, are
allowed).
</li><li> <code>own</code>: only instantiations that are local to a (generic) package
body are controlled.
</li><li> <code>public</code>: only declarations appearing in the visible part of
(generic) packages are controlled.
</li><li> <code>private</code>: only instantiations appearing directly in a private
part are controlled.
</li><li> <code>in_generic</code>: only instantiations appearing directly or indirectly in a generic
specification or body are controlled.
</li><li> <code>task_body</code>: only instantiations appearing directly in a task
body are controlled. Note that it would not make sense to have a
<location_kw> for task <i>specifications</i>, since instantiations are
not allowed there.
</li></ul>
<p>An instantiation matches if it appears at a specified location (if
any) and either:
</p><ol>
<li> No <formal_spec> is given in the rule
</li><li> The actual parameters of the instantiation match the corresponding
<formal_spec>, in order (there can be more actual parameters in the
instantiation than specified in the rule). An actual parameter matches
an <entity> at a given place if it is the same entity, or if the
<entity> designates a (sub)type and the actual is a subtype of this
type. As usual, the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. In addition, it
matches if the actual is a type name that belongs to the indicated
category:
<ul>
<li> “()”: The parameter is of an enumerated type.
</li><li> “access”: The parameter is of an access type.
</li><li> “array”: The parameter is of an array type.
</li><li> “delta”: The parameter is of a fixed point type (it is not currently
possible to distinguish ordinary fixed point types from decimal fixed
point types).
</li><li> “digits”: The parameter is of a floating point type.
</li><li> “mod”: The parameter is of a modular type.
</li><li> “private”: The parameter is of a private type (including private
extensions).
</li><li> “protected”: The parameter is of a protected type.
</li><li> “range”: The parameter is of a signed integer type.
</li><li> “record”: The parameter is of an (untagged) record type.
</li><li> “tagged”: The parameter is of a tagged type (including type
extensions).
</li><li> “task”: The parameter is of a task type.
</li></ul>
<p>In addition, two special signs can be given instead of an <entity> (or
<category>): a box (<code><></code>) matches any actual parameter
(i.e. it stands for any value), and an equal sign (<code>=</code>) matches
if there has been already an instantiation with the same value for
this parameter (i.e. it matches the second time it is encountered).
</p></li></ol>
<p>Formal <code><b>in</b></code> parameters cannot be matched, since the actual
can be any expression and it is not clear how to specify it in the
rule; therefore, the rule should normally specify a box (<code><></code>) at
the place of such parameters.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- Check all instantiations of Unchecked_Deallocation:
search instantiations (ada.unchecked_deallocation);
-- Check all instantiations of Unchecked_Conversion from or to String:
check instantiations (ada.unchecked_conversion, standard.string);
check instantiations (ada.unchecked_conversion, <>, standard.string);
-- Check all instantiations of Unchecked_Conversion from address
-- to an integer type:
check instantiations (ada.unchecked_conversion, system.address, range);
-- Check that Unchecked_Conversion is instantiated only once
-- for any pair of arguments:
check instantiations (ada.unchecked_conversion, =, =);
</pre></div>
<a name="Tips-16"></a>
<h4 class="subsection">5.24.3 Tips</h4>
<p>The various forms of <formal_spec> make the rule quite powerful. For
example:
</p><div class="example">
<pre class="example">-- Not two instantiations of Gen with the same first parameter:
check instantations (Gen, =);
-- Not two instantiations of Gen with same first and third parameters:
check instantiations (Gen, =, <>, =);
-- Not two instantiations of Gen with the same first parameter if the
-- second parameter is Pack.Proc:
check instantiations (Gen, =, Pack.Proc);
-- Not two instantiations of Gen with the same first parameter if the
-- second parameter is any procedure named Proc:
check instantiations (Gen, =, all Proc);
</pre></div>
<p>Note that a generic actual wich is a subtype matches all types (and subtypes)
above it. Therefore,
</p><div class="example">
<pre class="example">check instantiations (ada.unchecked_deallocation (standard.natural));
</pre></div>
<p>will find only instantiations that use <code>Natural</code>, while:
</p><div class="example">
<pre class="example">check instantiations (ada.unchecked_deallocation (standard.integer));
</pre></div>
<p>will find instantiations that use either <code>Integer</code>,
<code>Positive</code>, or <code>Natural</code>.
</p>
<p>If an equal sign (<code>=</code>) is provided for a formal <code><b>in</b></code>
parameter, it is <i>not</i> part of the comparison of existing
instantiations (it behaves like a box (<code><></code>)), i.e. given:
</p><div class="example">
<pre class="example">generic
type T1 is private;
Val : String := "";
package Gen;
package body Gen is ... end Gen;
package Inst1 is new Gen (Float, "Some Message");
package Inst2 is new Gen (Float, "Some Other Message");
</pre></div>
<p>and the rule:
</p><div class="example">
<pre class="example">check instantiations (Gen, =, =);
</pre></div>
<p>Adacontrol will issue a message for Inst2 that it has already been
instantiated with the same parameters, although the second
(<code><b>in</b></code>) parameter is different.
</p>
<a name="Limitation-7"></a>
<h4 class="subsection">5.24.4 Limitation</h4>
<p>GNAT defines <code>Unchecked_Conversion</code> and
<code>Unchecked_Deallocation</code> as separate entities, rather than
renamings of <code>Ada.Unchecked_Conversion</code> and
<code>Ada.Unchecked_Deallocation</code>. As a consequence, it is necessary
to specify explicitely both forms if you want to make sure that the
corresponding generics are not instantiated.
</p>
<hr>
<a name="Insufficient_005fParameters"></a>
<div class="header">
<p>
Next: <a href="#Local_005fAccess" accesskey="n" rel="next">Local_Access</a>, Previous: <a href="#Instantiations" accesskey="p" rel="prev">Instantiations</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Insufficient_005fParameters-1"></a>
<h3 class="section">5.25 Insufficient_Parameters</h3>
<p>This rule controls calls to subprograms and entries where the values
of parameters does not provide sufficient information to the reader to
correctly identify the parameter’s purpose.
</p>
<a name="Syntax-24"></a>
<h4 class="subsection">5.25.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> insufficient_parameters (<max_allowed> {, <entity>});
</pre></div>
<a name="Action-24"></a>
<h4 class="subsection">5.25.2 Action</h4>
<p><max_allowed> is the maximum number of allowed “insufficient”
parameters (can be 0). The <entity> parameters designate enumeration
types whose values should be included in the check. As usual, the
whole syntax for entities is allowed for <entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</p>
<p>An actual parameter is deemed "insufficient" if it is given in
positional (as opposed to named) notation, it is an expression whose
primaries are all numeric literals, or enumeration literals belonging
to one of the types passed as parameters to the rule
(<code>Standard.Boolean</code> for example).
</p>
<p>This rule can be given once for each of check, search, and count. This
way, it is possible to have a level considered a warning (search), and
one considered an error (check).
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search Insufficient_Parameters (1, Standard.Boolean);
check Insufficient_Parameters (2, Standard.Boolean);
</pre></div>
<a name="Tips-17"></a>
<h4 class="subsection">5.25.3 Tips</h4>
<p>This rule does not apply to operators that use infix notation, nor to
calls to subprograms that are attributes, since named notation is not
allowed for these.
</p>
<p>This rule controls the use of positional parameters according to their
values; it is also possible to control the use of positional
parameters according to the number of parameters with the rule
<code>positional_associations</code>. See <a href="#Positional_005fAssociations">Positional_Associations</a>.
</p>
<p>Note also that this rules applies only to calls, while
<code>positional_associations</code> applies to all forms of associations.
</p>
<hr>
<a name="Local_005fAccess"></a>
<div class="header">
<p>
Next: <a href="#Local_005fHiding" accesskey="n" rel="next">Local_Hiding</a>, Previous: <a href="#Insufficient_005fParameters" accesskey="p" rel="prev">Insufficient_Parameters</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Local_005fAccess-1"></a>
<h3 class="section">5.26 Local_Access</h3>
<p>This rule controls the taking of access values (through the <code>'Access</code>,
<code>'Unchecked_Access</code>, or the GNAT specific <code>'Unrestricted_Access</code>
attributes) of local (i.e. non global) entities.
</p>
<a name="Syntax-25"></a>
<h4 class="subsection">5.26.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> local_access [(<subrule> {,<subrule>})];
<subrule> ::= constant | variable | procedure | function |
protected_procedure | protected_function
</pre></div>
<a name="Action-25"></a>
<h4 class="subsection">5.26.2 Action</h4>
<p>Without parameters, the rule controls all entities given as prefixes
of <code>'Access</code>, <code>'Unchecked_Access</code>, or
<code>'Unrestricted_Access</code> attributes and reports on those that are
not global, i.e. not defined in (possibly nested) library packages.
</p>
<p>If parameters are specified, only entities belonging to the
corresponding categories are controlled.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">Dangerous_Objects: check local_access (Constant, Variable);
</pre></div>
<a name="Tips-18"></a>
<h4 class="subsection">5.26.3 Tips</h4>
<p>In Ada 95, accessibility rules make sure that taking the
<code>'Access</code> of an entity cannot create dangling pointers, but this
check can be circumvented by using <code>'Unchecked_Access</code> (but not
on subprograms), or in GNAT, by using
<code>'Unrestricted_Access</code>. Moreover, Ada 2005 generalized anonymous
access types create more cases where accessibility levels are
dynamically checked.
</p>
<p>Taking an access value on a global entity is never a risk, but every
use of access values designating local entities has a potential of a
failing dynamic accessibility check or even of a dangling
pointer. This rule is helpful in finding the places that need careful
inspection - or for disallowing taking accesses on anything but global
entities.
</p>
<hr>
<a name="Local_005fHiding"></a>
<div class="header">
<p>
Next: <a href="#Max_005fBlank_005fLines" accesskey="n" rel="next">Max_Blank_Lines</a>, Previous: <a href="#Local_005fAccess" accesskey="p" rel="prev">Local_Access</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Local_005fHiding-1"></a>
<h3 class="section">5.27 Local_Hiding</h3>
<p>This rule controls declarations that hide an outer declaration with
the same name.
</p>
<a name="Syntax-26"></a>
<h4 class="subsection">5.27.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> local_hiding [(<subrule> {,"<allowed pattern>"})];
<subrule> ::= {<exception>} strict | overloading
<exception> ::= not_operator | not_enumeration |
not_identical_renaming | not_different_families
</pre></div>
<a name="Action-26"></a>
<h4 class="subsection">5.27.2 Action</h4>
<p>If “strict” is given (or if there is no subrule), the rule controls
strict hiding (an inner subprogram that overloads an outer one is not
considered hiding). If “overloading” is given, only subprograms that
overload another subprogram in the same scope or in an outer scope are
controlled. Note that following the normal Ada model, the declarations
of enumeration literals are considered functions (and thus
controlled).
</p>
<p>Modifiers are used to exclude some controls (i.e. to allow the corresponding hiding):
</p><ul>
<li> “not_operator”: the subrule does not apply to the declarations of
operators (i.e. things like “<code>"+"</code>”).
</li><li> “not_enumeration”: the subrule does not apply to the
hiding/overloading of enumeration literals by other enumeration
literals (the rule still applies to the hiding/overloading of
functions by enumeration litterals, for example).
</li><li> “not_identical_renaming” (only allowed with “strict”): the subrule
does not apply to renamings where the renaming name is the same as the
name of the renamed entity. Such renamings are commonly used to
provide visibility of identifiers in a controlled way.
</li><li> “not_different_families” (only allowed with “strict”): the subrule
does not apply if the hiding identifier and the hidden one do not
belong to the same “family”. Families are either data (constant,
variables, numbers, etc.), types, subprograms (including entries),
packages, generics, exceptions, and labels (including block and loop
names).
</li></ul>
<p>If one or more <allowed pattern> are given, hiding (or overloading) of
identifiers that match one of the patterns are not reported. The whole
syntax for regular expressions is allowed for the pattern, but the
matching is always case insensitive. See <a href="#Syntax-of-regular-expressions">Syntax of regular expressions</a>.
</p>
<p>This rule can be given only once for “strict” and once for
“overloading”.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">Hiding: check local_hiding (strict);
Overloading: search local_hiding (not_operator overloading);
</pre></div>
<a name="Variable-2"></a>
<h4 class="subsection">5.27.3 Variable</h4>
<p>The rule provides a variable that allows to adjust the verbosity
of messages for the subrule “overloading”.
</p>
<table>
<tr><td width="23%"><b>Variable</b></td><td width="15%"><b>Values</b></td><td width="12%"><b>Default</b></td><td width="50%"><b>Effect</b></td></tr>
<tr><td width="23%">Overloading_Report</td><td width="15%">compact<br>detailed</td><td width="12%">detailed</td><td width="50%">when the “overloading” subrule encounters a construct that
overloads several other constructs:
<dl compact="compact">
<dt>detailed</dt>
<dd><p>issue a message for each overloaded construct
</p></dd>
<dt>compact</dt>
<dd><p>issue a single message mentionning how many constructs are overloaded,
and a pointer to the last one.
</p></dd>
</dl></td></tr>
</table>
<a name="Tips-19"></a>
<h4 class="subsection">5.27.4 Tips</h4>
<p>If you have a naming convention like having all tagged types named
“instance” (with a meaningful name for the enclosing package), and
if in addition your package structure follows the inheritance
hierarchy (i.e. a descendent class is in a child package), then all
“instance” will hide each other - but this is of course
intended. Specifying “<code>^instance$</code>” as an allowed pattern will
prevent error messages for these declarations.
</p>
<p>Note that the name is given between “<code>^</code>” and
“<code>$</code>”. Otherwise, following normal regexp syntax, any
identifier <i>containing</i> “instance” would be allowed.
</p>
<p>A confusion between names belonging to different “families” (as
defined here) always leads to a compilation error; it may be
acceptable to allow local hiding of names belonging to different
families, since there is no risk involved.
</p>
<hr>
<a name="Max_005fBlank_005fLines"></a>
<div class="header">
<p>
Next: <a href="#Max_005fCall_005fDepth" accesskey="n" rel="next">Max_Call_Depth</a>, Previous: <a href="#Local_005fHiding" accesskey="p" rel="prev">Local_Hiding</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Max_005fBlank_005fLines-1"></a>
<h3 class="section">5.28 Max_Blank_Lines</h3>
<p>This rule controls excessive spacing in the program text.
</p>
<a name="Syntax-27"></a>
<h4 class="subsection">5.28.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> max_blank_lines (<max allowed blank lines>);
</pre></div>
<a name="Action-27"></a>
<h4 class="subsection">5.28.2 Action</h4>
<p>This rule controls the occurrence of more than the indicated number of
consecutive blank lines (empty lines, or lines that contain only
spaces). This rule can be given once for each of check, search, and
count. This way, it is possible to have a number of blank lines
considered a warning (search), and one considered an error (check). Of
course, this makes sense only if the number for search is less than
the one for check.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search max_blank_lines (2);
check max_blank_lines (5);
</pre></div>
<a name="Fixes-3"></a>
<h4 class="subsection">5.28.3 Fixes</h4>
<p>This rule generates fixes: Extra blank lines are removed.
</p>
<hr>
<a name="Max_005fCall_005fDepth"></a>
<div class="header">
<p>
Next: <a href="#Max_005fLine_005fLength" accesskey="n" rel="next">Max_Line_Length</a>, Previous: <a href="#Max_005fBlank_005fLines" accesskey="p" rel="prev">Max_Blank_Lines</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Max_005fCall_005fDepth-1"></a>
<h3 class="section">5.29 Max_Call_Depth</h3>
<p>This rule controls the maximum depth of subprograms (or entry) calls.
</p><a name="Syntax-28"></a>
<h4 class="subsection">5.29.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> max_call_depth (<allowed depth> | finite {, <entity>});
</pre></div>
<a name="Action-28"></a>
<h4 class="subsection">5.29.2 Action</h4>
<p>Roughly speaking, the call depth is the number of frames that are
stacked by a call: if you call a subprogram that calls another
subprogram that calls nothing, then the call depth is 2. Note that a
call to a task (not protected) entry has always a depth of 1, since
the accept body that corresponds to the entry is executed on a
different stack.
</p>
<p>The value of the first parameter is the maximum <i>allowed</i> depth,
i.e. the rule will trigger if the call depth is strictly greater than
the indicated value. A call to a (directly or indirectly) recursive
procedure is considered of infinite depth, and will be therefore
signaled (with an appropriate message) for any value of <allowed
depth>. Alternatively, the keyword “finite” can be given in place of
the <allowed depth>: in this case, only calls to recursive subprograms
will be signalled.
</p>
<p>If entity names are given after the first parameter, they are
interpreted as callable entities that are not to be analyzed, and
assumed of depth 0 (not calling anything else). As usual, the whole
syntax for entities is allowed for <entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. This can be useful, for example, when a subprogram
appears to be recursive (but is not, due to the algorithm), to prevent
all those who call it to be flagged as having infinite call depth.
</p>
<p>This rule can be given once for each of check, search, and count. This
way, it is possible to have a call depth considered a warning
(search), and one considered an error (check). Of course, this makes
sense only if the number for search is less than the one for check.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search max_call_depth (9);
check max_call_depth (finite);
</pre></div>
<a name="Variable-3"></a>
<h4 class="subsection">5.29.3 Variable</h4>
<p>The rule provides a variable that allows to specify how to handle
expression functions (Ada 2012).
</p>
<table>
<tr><td width="25%"><b>Variable</b></td><td width="10%"><b>Values</b></td><td width="10%"><b>Default</b></td><td width="55%"><b>Effect</b></td></tr>
<tr><td width="25%">Count_Expr_Fun_Calls</td><td width="10%">on<br>off</td><td width="10%">on</td><td width="55%"><dl compact="compact">
<dt>on</dt>
<dd><p>calls to expression functions are counted like regular calls
</p></dd>
<dt>off</dt>
<dd><p>calls to expression functions are assumed to be inlined and do not add
an extra depth level.
</p></dd>
</dl></td></tr>
</table>
<a name="Tip-1"></a>
<h4 class="subsection">5.29.4 Tip</h4>
<p>It is possible to give the value 0 for <allowed depth>. Of course,
it would not make sense to forbid all subprogram calls in an Ada program,
but this can be useful for inspection purposes, since every call will be
reported, and the message indicates the depth of the call.
</p>
<p>If the message says that the call depth “is N”, it is exactly N. If
the message says that the call depth is “at least N”, it means that
the call chain includes a call to a subprogram whose depth is unknown
(see “Limitations” below); “N” is the call depth if this
subprogram does not call anything else. Of course, the rule issues a
message if this minimal value is greater than the maximum allowed
value.
</p>
<p>There is only one set of entities that are forced to depth 0;
therefore, if the control is given several times, each with various
<entity>, all controls will use the union of all entities given.
</p>
<a name="Limitations-11"></a>
<h4 class="subsection">5.29.5 Limitations</h4>
<p>Calls to subprograms that are attributes are assumed to have a depth
of 1. Calls to predefined operators are assumed to be in-lined (i.e. a
depth of 0).
</p>
<p>Calls through pointers to subprograms and dispatching calls are
unknown statically; in addition, some subprograms may not have a body
available for analysis, like imported subprograms, or possibly
subprograms from the standard library; they are all assumed to have a
depth of 1. Such calls are detected by the rule
“uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Max_005fLine_005fLength"></a>
<div class="header">
<p>
Next: <a href="#Max_005fNesting" accesskey="n" rel="next">Max_Nesting</a>, Previous: <a href="#Max_005fCall_005fDepth" accesskey="p" rel="prev">Max_Call_Depth</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Max_005fLine_005fLength-1"></a>
<h3 class="section">5.30 Max_Line_Length</h3>
<p>This rule controls that no line exceeds a given length.
</p>
<a name="Syntax-29"></a>
<h4 class="subsection">5.30.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> max_line_length (<max allowed length>);
</pre></div>
<a name="Action-29"></a>
<h4 class="subsection">5.30.2 Action</h4>
<p>This rule controls the maximum length of source lines. This rule can
be given once for each of check, search, and count. This way, it
is possible to have a length considered a warning (search), and one
considered an error (check). Of course, this makes sense only if the
length for search is less than the one for check.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search max_line_length (80);
check max_line_length (120);
</pre></div>
<hr>
<a name="Max_005fNesting"></a>
<div class="header">
<p>
Next: <a href="#Max_005fSize" accesskey="n" rel="next">Max_Size</a>, Previous: <a href="#Max_005fLine_005fLength" accesskey="p" rel="prev">Max_Line_Length</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Max_005fNesting-1"></a>
<h3 class="section">5.31 Max_Nesting</h3>
<p>This rule controls excessive nesting of declarations.
</p>
<a name="Syntax-30"></a>
<h4 class="subsection">5.31.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> max_nesting ([<subrule>,] <max allowed depth>);
<subrule> ::= all | generic | separate | task
</pre></div>
<a name="Action-30"></a>
<h4 class="subsection">5.31.2 Action</h4>
<p>If “all” (or no subrule) is given as the first parameter, this rule
controls the nesting of declarative constructs (like subprograms,
packages, generics, block statements…) that exceed a given
depth. Nesting of statements (<code><b>loop</b></code>, <code><b>case</b></code>) is not
considered.
</p>
<p>If “generic” is given as the first parameter, this rule controls the
nesting of generics, ignoring all non-generic units.
</p>
<p>If “separate” is given as the first parameter, this rule controls the
nesting of separate bodies.
</p>
<p>If “task” is given as the first parameter, this rule controls the
nesting of tasks (task types and single task objects), ignoring all
non-task units.
</p>
<p>This rule can be given once for each subrule and each of check,
search, and count. This way, it is possible to have a level considered
a warning (search), and one considered an error (check). Of course,
this makes sense only if the level for search is less than the one for
check.
</p>
<p>Note that the value given is the maximum <i>allowed</i> nesting; f.e. if the
value given for “generic” is 1, it means that a generic inside a
generic is allowed, but not more.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search max_nesting (5);
check max_nesting (all, 7);
check max_nesting (generic, 1);
check max_nesting (separate, 0); -- Do not allow separate in separate
check max_nesting (task, 0); -- Do not allow a task in another task
</pre></div>
<hr>
<a name="Max_005fSize"></a>
<div class="header">
<p>
Next: <a href="#Max_005fStatement_005fNesting" accesskey="n" rel="next">Max_Statement_Nesting</a>, Previous: <a href="#Max_005fNesting" accesskey="p" rel="prev">Max_Nesting</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Max_005fSize-1"></a>
<h3 class="section">5.32 Max_Size</h3>
<p>This rule controls the maximum size, in source lines of code, of
various statements and declarations.
</p>
<a name="Syntax-31"></a>
<h4 class="subsection">5.32.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> max_size (<subrule>, <max allowed lines>);
<subrule> ::= accept | block | case | case_branch |
if | if_branch | loop | simple_block |
unnamed_block | unnamed_loop |
package_spec | package_body | procedure_body |
function_body | protected_spec | protected_body |
entry_body | task_spec | task_body |
unit
</pre></div>
<a name="Action-31"></a>
<h4 class="subsection">5.32.2 Action</h4>
<p>The first parameter is a subrule keyword that determines which
elements are controlled:
</p><ul>
<li> “accept” controls accept statements.
</li><li> “block” controls all block statements, while “simple_block”
controls only blocks without a <code><b>declare</b></code> part, and
“unnamed_block” controls only blocks without a name.
</li><li> “loop” controls all loop statement, while “unnamed_loop” controls
only loops without a name.
</li><li> “if_branch” and “case_branch” control the length of each
alternative of an <code><b>if</b></code> (respectively <code><b>case</b></code>)
statement.
</li><li> “package_spec”, “package_body”, “procedure_body”,
“function_body”, “protected_spec”, “protected_body”,
“entry_body”, “task_spec”, and “task_body” control the length of
the declaration of the corresponding element.
</li><li> “unit” controls the whole length of compilation units.
</li></ul>
<p>For each kind of element, the indicated value is the maximum allowed
size of the full element; however, for branches (“if_branch” and
“case_branch”) it is the maximum size of the sequence of statements
in the branch (i.e., the line that contains the <code><b>elsif</b></code> is
not counted as part of an “if_branch”).
</p>
<p>This rule can be given once for each of check, search, and count for
each kind of element. This way, it is possible to have a level
considered a warning (search), and one considered an error (check). Of
course, this makes sense only if the number of lines for search is
less than the one for check.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check Max_Size (if_branch, 30);
search Max_Size (if_branch, 50);
check Max_Size (unnamed_loop, 20);
</pre></div>
<a name="Tip-2"></a>
<h4 class="subsection">5.32.3 Tip</h4>
<p>Note that “procedure_body” and “function_body” apply to protected
subprograms as well as regular ones, and that there is no subrule for
the length of the declaration of subprograms. Such fine specifications
didn’t seem useful, but could be added if someone expresses a need for
it.
</p>
<hr>
<a name="Max_005fStatement_005fNesting"></a>
<div class="header">
<p>
Next: <a href="#Movable_005fAccept_005fStatements" accesskey="n" rel="next">Movable_Accept_Statements</a>, Previous: <a href="#Max_005fSize" accesskey="p" rel="prev">Max_Size</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Max_005fStatement_005fNesting-1"></a>
<h3 class="section">5.33 Max_Statement_Nesting</h3>
<p>This rule controls the nesting of compound statements.
</p>
<a name="Syntax-32"></a>
<h4 class="subsection">5.33.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> max_statement_nesting (<subrule>, <max allowed depth>);
<subrule> ::= block | case | if | loop | all
</pre></div>
<a name="Action-32"></a>
<h4 class="subsection">5.33.2 Action</h4>
<p>If one of “block”, “case”, “if”, or “loop” is specified, it
controls the nesting of statements of the same kind, i.e. an
<code><b>if</b></code> within a <code><b>loop</b></code> within an <code><b>if</b></code> counts
only 2 for the “if” keyword. If “all” is specified, all kinds of
compound statements are counted together, i.e. an <code><b>if</b></code> within
a <code><b>loop</b></code> within an <code><b>if</b></code> counts for 3. This rule can
be given once for each of check, search, and count, and for each of
the subrules. This way, it is possible to have a level considered a
warning (search), and one considered an error(check). Of course, this
makes sense only if the level for search is less than the one for
check.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check max_statement_nesting (loop, 3);
search max_statement_nesting (all, 5);
</pre></div>
<hr>
<a name="Movable_005fAccept_005fStatements"></a>
<div class="header">
<p>
Next: <a href="#Naming_005fConvention" accesskey="n" rel="next">Naming_Convention</a>, Previous: <a href="#Max_005fStatement_005fNesting" accesskey="p" rel="prev">Max_Statement_Nesting</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Movable_005fAccept_005fStatements-1"></a>
<h3 class="section">5.34 Movable_Accept_Statements</h3>
<p>This rule controls statements that are inside accept statements and
could safely be moved outside.
</p>
<a name="Syntax-33"></a>
<h4 class="subsection">5.34.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> movable_accept_statements (certain|possible {, <entity>})
</pre></div>
<a name="Action-33"></a>
<h4 class="subsection">5.34.2 Action</h4>
<p>Since it is good practice to block a client for the shortest time
possible, any action that does not depend on the accept parameters
should not be part of an accept statement.
</p>
<p>Statements that involve synchronisation (delay statements, accept or
entry calls...) are not movable. Statements (including compound
statements) that reference the parameters of the enclosing accept are
not movable. In addition, statements that use one of the <entity>
given as parameters are never considered movable. As usual, the whole
syntax for entities is allowed for <entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. Note that if a generic entity, or an entity declared in
a generic package, is given, all statements that use the corresponding
instantiated entity are considered not movable.
</p>
<p>If the first parameter of the rule is <code>certain</code>, only statements
after the last non-movable statement are reported. If the first
parameter is <code>possible</code>, a simple data flow analysis is
performed, and every statement that does not reference a variable that
appears to depend (directly or indirectly) on a parameter is also
reported.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check movable_accept_statements (possible, Log.Report_Rendezvous);
</pre></div>
<a name="Tips-20"></a>
<h4 class="subsection">5.34.3 Tips</h4>
<p>The list of <entity> given to the rule can be, for example, procedures
whose execution must be part of the accept statement for logical
reasons. They can also be global variables, when the rendezvous is
intended to prevent concurrent access to these variables.
</p>
<hr>
<a name="Naming_005fConvention"></a>
<div class="header">
<p>
Next: <a href="#No_005fOperator_005fUsage" accesskey="n" rel="next">No_Operator_Usage</a>, Previous: <a href="#Movable_005fAccept_005fStatements" accesskey="p" rel="prev">Movable_Accept_Statements</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Naming_005fConvention-1"></a>
<h3 class="section">5.35 Naming_Convention</h3>
<p>This rule controls the form of identifiers to make sure that they
follow the project’s naming conventions. Different naming conventions
can be specified, depending on the kind of Ada entity that the name is
refering to.
</p>
<a name="Syntax-34"></a>
<h4 class="subsection">5.35.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> naming_convention
([root] [others] {<location>} [<type_spec>] <filter_kind>,
[case_sensitive|case_insensitive] [not] "<pattern>"
{, ...});
<location> ::= global | local | unit
<type_spec> ::= <entity> | {<category>}
<category> ::= () | access | array | delta | digits | mod |
private | protected | range | record | tagged | task
<filter_kind> ::= All |
Type |
Discrete_Type |
Enumeration_Type |
Integer_Type |
Signed_Integer_Type |
Modular_Integer_Type |
Floating_Point_Type |
Fixed_Point_Type |
Binary_Fixed_Point_Type |
Decimal_Fixed_Point_Type |
Array_Type |
Record_Type |
Regular_Record_Type |
Tagged_Type |
Interface_Type |
Class_Type |
Access_Type |
Access_To_Regular_Type |
Access_To_Tagged_Type |
Access_To_Class_Type |
Access_To_SP_Type |
Access_To_Task_Type |
Access_To_Protected_Type |
Private_Type |
Private_Extension |
Generic_Formal_Type |
Variable |
Regular_Variable |
Field |
Discriminant |
Record_Field |
Protected_Field |
Procedure_Formal_Out |
Procedure_Formal_In_Out |
Generic_Formal_In_Out |
Constant |
Regular_Constant |
Regular_Static_Constant |
Regular_Nonstatic_Constant |
Named_Number |
Integer_Number |
Real_Number |
Enumeration |
Sp_Formal_In |
Generic_Formal_In |
Loop_Control |
Occurrence_Name |
Entry_Index |
Label |
Stmt_Name |
Loop_Name |
Block_Name |
Subprogram |
Procedure |
Regular_Procedure |
Protected_Procedure |
Generic_Formal_Procedure |
Function |
Regular_Function |
Protected_Function |
Generic_Formal_Function |
Entry |
Task_Entry |
Protected_Entry |
Package |
Regular_Package |
Generic_Formal_Package |
Task |
Task_Type |
Task_Object |
Protected |
Protected_Type |
Protected_Object |
Exception |
Generic |
Generic_Package |
Generic_Sp |
Generic_Procedure |
Generic_Function |
Renaming |
Object_Renaming |
Exception_Renaming |
Package_Renaming |
Subprogram_Renaming |
Procedure_Renaming |
Function_Renaming |
Generic_Renaming |
Generic_Package_Renaming |
Generic_Sp_Renaming |
Generic_Procedure_Renaming |
Generic_Function_Renaming
</pre></div>
<a name="Action-34"></a>
<h4 class="subsection">5.35.2 Action</h4>
<p>The first parameter defines the kind of declaration to which the rule
is applicable, and other parameters are strings, interpreted as
regular expressions that define the patterns that must be
matched (or not). See <a href="#Syntax-of-regular-expressions">Syntax of regular expressions</a>.
</p>
<p>If one or more <location> keyword is specified, the pattern applies
only to identifiers declared at the corresponding place. Otherwise,
the pattern applies to all identifiers, irrespectively of where they
are declared. The definition of locations is as follows:
</p><ul>
<li> “unit”: The identifier is the defining name of a compilation unit.
</li><li> “global”: The identifier is declared in a package or a generic
package, possibly nested in other packages or generic packages.
</li><li> “local”: All other cases.
</li></ul>
<p>In the case of objects (corresponding to filters in the “variable”
and “constant” families) and functions (in the “function” family),
it is possible to be more specific, depending on the type of the
object (or the return type of the function), as specified by the
<type_spec> modifier. The <type_spec> modifier is either a single
<entity> giving the type of the object or one or more <category>
keywords. As usual, the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. The meaning of
<category> is:
</p><ul>
<li> “()”: The object is of an enumerated type.
</li><li> “access”: The object is of an access type.
</li><li> “array”: The object is of an array type.
</li><li> “delta”: The object is of a fixed point type (it is not currently
possible to distinguish ordinary fixed point types from decimal fixed
point types).
</li><li> “digits”: The object is of a floating point type.
</li><li> “mod”: The object is of a modular type.
</li><li> “private”: The object is of a private type (including private
extensions).
</li><li> “protected”: The object is of a protected type.
</li><li> “range”: The object is of a signed integer type.
</li><li> “record”: The object is of an (untagged) record type.
</li><li> “tagged”: The object is of a tagged type (including type
extensions).
</li><li> “task”: The object is of a task type.
</li></ul>
<p>For a given layer of the hierarchy (i.e. “variable”,
“regular_variable”), only the most specific filter is applicable,
i.e. “standard.boolean variable” will apply to all boolean
variables, while plain “variable” will apply to other variables. See
examples below.
</p>
<p>If “case_sensitive” is specified, pattern matching considers
casing. Otherwise (“case_insensitive”), casing is irrelevant. The
default is “case_insensitive”, and can be changed by setting the
rule variable “Default_Case_Sensitivity”, see below. Note that the
rule checks the name only at the place where it is declared; casing
might be different when the name is used later.
</p>
<p>If a pattern is preceded by “not”, then the pattern must <i>not</i> be
matched (i.e. the rule reports when there is a match).
</p>
<p>The rule will be activated if an identifier is declared that does not
match any of the “positive” patterns (the ones without “not”), or
if it matches any of the ”negative” patterns (the ones with a
“not”). If only negative patterns are given, it is implicitely
assumed that all other identifiers are OK. In other words, accepted
identifiers must have the form of (at least) one of the “positive”
patterns (if any), but not the form of one of the “negative”
patterns.
</p>
<p>The filter kinds are organized hierarchically, as reflected by
indentation in the syntax above. To be valid, the name must match the
patterns specified for its own filter, and for all filters above it in
the hierarchy. For example, a modular type declaration must follow
the rules (if specified) for “all”, “type”,”discrete_type”,
“integer_type” and “modular_integer_type”. However, if a filter
kind is preceded by “others”, the rule will apply only if there is
no applicable positive pattern deeper in the hierarchy; similarly, if
a filter kind is preceded by “root”, no rule above it in the
hierarchy is considered (neither for itself nor its children). This is
useful to make exceptions to a more general rule. For example:
</p>
<div class="example">
<pre class="example">-- All identifiers must have at least 3 characters:
check naming_convention (all, "...");
-- And start with an upper-case letter
-- (will not apply to types and access types, because of "others" and
-- other rules given below)
check naming_convention (others all, case_sensitive "^[A-Z]");
-- Exception to the rule for "all":
-- No minimum length for "for loop" identifiers, but must be
-- all uppercase
check naming_convention (root loop_control, case_sensitive "^[A-Z]+$");
-- Types must start with "t", then an upper-case letter:
-- (will not apply to access types, because of "others" and
-- other rule given below)
check naming_convention (others type, case_sensitive "^t[A-Z]");
-- Access types must start with "ta", then an upper-case letter:
check naming_convention (access_type, case_sensitive "^ta[A-Z]");
-- Boolean variables, and only these, must start with "Is_" or
-- "Has_":
check naming_convention (variable, not "^Is_", not "^Has_");
check naming_convention (standard.boolean variable, "^Is_", "^Has_");
-- Functions returning Wide_String must start with "Wide_", and
-- similarly for Wide_Wide_String, and no other:
check naming_convention (standard.wide_string function,
"^Wide_",
not "^Wide_Wide_");
check naming_convention (standard.wide_wide_string function,
"^Wide_Wide_");
check naming_convention (function, not "^Wide_");
</pre></div>
<p>It is of course not necessary to specify all the filter kinds, nor to
specify filters down to the deepest level; if you specify a rule for
“type”, it will be applied to all type declarations, whether there
is a more specific rule or not.
</p>
<p>Subtypes and derived types must follow the rule for their respective
original (full) type. Incomplete type declarations are <i>not</i>
checked, since their corresponding full declaration is (normally)
checked. Private types (including of course the full declaration of a
private type) follow the rule for private types, <i>not</i> the rules for
their full type view (otherwise it would be privacy breaking).
</p>
<p>Renamings are treated specially: if there is no explicit rule for a
given renaming, the applicable rule is the one for the renamed entity.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- Predefined name is forbidden:
check naming_convention (all, not "Integer");
-- Types must either start or end with T
check naming_convention (type, case_sensitive "^T_",
case_sensitive "_T$");
-- "Upper_Initials" naming convention:
check naming_convention
(all, case_sensitive "^[A-Z][a-z0-9]*(_[A-Z0-9][a-z0-9]*)*$");
-- All global variables must start with "G_"
check naming_convention (global variable, "G_");
</pre></div>
<a name="Fixes-4"></a>
<h4 class="subsection">5.35.3 Fixes</h4>
<p>This rule generate fixes to help in refactoring the improper name. The
fix is ignored by <code>adactl_fix</code>, since automatic fixing is not
possible. Under GPS (interactive fixing) the “fix” icon launches the
“rename entity” dialog, allowing to give a proper name to the
entity, and changing all occurrences.
</p>
<a name="Variable-4"></a>
<h4 class="subsection">5.35.4 Variable</h4>
<p>The rule provides a variable that allows to specify the default
casing.
</p>
<table>
<tr><td width="25%"><b>Variable</b></td><td width="10%"><b>Values</b></td><td width="10%"><b>Default</b></td><td width="55%"><b>Effect</b></td></tr>
<tr><td width="25%">Default_Case_Sensitivity</td><td width="10%">on<br>off</td><td width="10%">off</td><td width="55%"><dl compact="compact">
<dt>on</dt>
<dd><p>controls that do not explicitely specify case sensitivity are case sensitive.
</p></dd>
<dt>off</dt>
<dd><p>controls that do not explicitely specify case sensitivity are not case sensitive.
</p></dd>
</dl></td></tr>
</table>
<a name="Tips-21"></a>
<h4 class="subsection">5.35.5 Tips</h4>
<p>The rule only checks the casing of identifiers at the place where they
are declared. A useful companion rule is “style (casing_identifier,
original)”, which ensures that every use of the identifier will use
the same casing as in the declaration. See <a href="#Style">Style</a>. Similarly, in
the case of a subprogram and its parameters, the check is not done on
the body if there is an explicit specification (since specification
and body have to match anyway).
</p>
<p>The rule does <i>not</i> check the names of operators, since it would
make little sense to have naming conventions for things whose name is
imposed. If you want to prevent the definition of operators, refer to
the rule “declarations” and its subrules “operator”,
“equality_operator”, and“predefined_operator”.
See <a href="#Declarations">Declarations</a>.
</p>
<p>Remember that a Regexp matches if the pattern matches any part of the
identifier. Use “^” and “$” to match the beginning (resp. end) of
the name, or both.
</p>
<p>A constant is considered static for the purpose of
“Regular_Static_Constant” and “Regular_Nonstatic_Constant” if it
is of a discrete type initialized by a static expression, or if it is
an aggregate whose components all have static values. This is
different from the official definition of “static” in the language,
but corresponds to what most users would expect.
</p>
<p>“class_type” is applicable to subtypes that designate a class-wide
type. Similarly, “access_to_class_type” is applicable to access
types whose designated type is class-wide.
</p>
<p>If you don’t want any special rule for renamings (not even the one that
applies to the renamed entity), specify:
</p><div class="example">
<pre class="example">check naming_convention (renaming, "");
</pre></div>
<p>This imposes no constraint on renamings, but since it is specified
explicitely, the implicit rule for the renamed entity won’t apply.
</p>
<p>The <code>rules</code> directory of Adacontrol contains two files named
<code>no_standard_entity.aru</code> and <code>no_system_entity.aru</code>. These
are files that contain a naming_convention rule that forbids the
declaration of names declared in packages <code>Standard</code> and <code>System</code>,
respectively. You can simply “source” these files from your own rule
file (or copy the content) if you want to disallow these identifiers.
</p>
<p>Like usual, naming_convention rule can be given multiple times, and
can be disabled. However, consider the following:
</p><div class="example">
<pre class="example">Rule1 : check naming_convention (constant, "^c_");
Rule2 : check naming_convention (constant, "^const_");
</pre></div>
<p>The rule will trigger if a constant is declared that does not start
with either “c_” or “const_”. But here, we have two different
rule labels. The message will refer to the first label encountered in the
command file; this is the label that must be mentionned in a disabling
comment, unless you simply disable “naming_convention”.
</p>
<a name="Limitations-12"></a>
<h4 class="subsection">5.35.6 Limitations</h4>
<p>This rule does not support wide characters outside the basic Latin-1 set.
</p>
<hr>
<a name="No_005fOperator_005fUsage"></a>
<div class="header">
<p>
Next: <a href="#Non_005fStatic" accesskey="n" rel="next">Non_Static</a>, Previous: <a href="#Naming_005fConvention" accesskey="p" rel="prev">Naming_Convention</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="No_005fOperator_005fUsage-1"></a>
<h3 class="section">5.36 No_Operator_Usage</h3>
<p>This rule controls integer types that do not use any arithmetic
operators, which indicates that they might be replaceable with other
kinds of types.
</p><a name="Syntax-35"></a>
<h4 class="subsection">5.36.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> no_operator_usage [([<category>] <parameter>
[,<parameter>])];
<category> ::= range | mod
<parameter> ::= [<filter>] <observed>
<filter> ::= not | ignore | report
<observed> ::= relational | logical | indexing
</pre></div>
<a name="Action-35"></a>
<h4 class="subsection">5.36.2 Action</h4>
<p>This rule controls integer types where no arithmetic operator of the
type is used in the program. If the <category> is <code>range</code>, the
control applies only to signed integer types; if it is <code>mod</code>, it
applies only to modular integer types; otherwise, it applies to both.
</p>
<p>When such a type is found, it migh be interesting to find out other
usages to determine a possible better kind of type. “relational”
means that relational operators (<code><</code>, <code><=</code>, <code>></code>,
<code>>=</code>, <code><b>in</b></code>, <code><b>not in</b></code>) are used, “logical”
means that logical operators (<code><b>and</b></code>, <code><b>or</b></code>,
<code><b>xor</b></code>) are used, and “indexing” means that the type is
used as an index in some array type.
</p>
<p>If an <observed> property is given as parameter, only types that
feature the property are controlled, or those that do <i>not</i> feature
the property if the <observed> is preceded by “not”. If the
<observed> is preceded by “ignore” the type is controlled
irrrespectively of the property, and the message does not mention it
at all, while if it is preceded by “report”, the message still
mentions whether the <observed> is used or not.
</p>
<p>Without parameters, the rule is equivalent to “ignore relational,
ignore logical, ignore indexing” (i.e. it controls all types that do
not use any arithmetic operator).
</p>
<p>This rule can be given only once for each combination of values of the
parameters.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- Simply report types that don't use arithmetic operators:
check no_operator_usage;
-- Do the same, but mention if indexing/logical ops are used:
check no_operator_usage (report indexing, report logical);
-- Find modular integer types that use only logical operators:
check no_operator_usage (mod logical);
-- Find integer types that don't use artihmetic operators and are
-- not used for indexing nor in relational operators:
check no_operator_usage (not indexing, not relational);
</pre></div>
<a name="Tips-22"></a>
<h4 class="subsection">5.36.3 Tips</h4>
<p>An integer type that uses no operator at all is a good candidate to be
replaced by an enumerated type. A modular type where only logical
operators are used is likely to be used as a bit field or a set, and
is a good canditate for being replaced by an array of booleans.
</p>
<p>The rule does not make a distinction between predefined and
user-defined operators. On the other hand, only calls to operators are
considered, operators used for example as actual generic parameters in
instantiations are not considered.
</p>
<p>The rule applies also to private types whose full declaration is an
integer type.
</p>
<hr>
<a name="Non_005fStatic"></a>
<div class="header">
<p>
Next: <a href="#Not_005fElaboration_005fCalls" accesskey="n" rel="next">Not_Elaboration_Calls</a>, Previous: <a href="#No_005fOperator_005fUsage" accesskey="p" rel="prev">No_Operator_Usage</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Non_005fStatic-1"></a>
<h3 class="section">5.37 Non_Static</h3>
<p>This rule controls that expressions used in certain contexts are
static.
</p><a name="Syntax-36"></a>
<h4 class="subsection">5.37.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> non_static [(<subrule> {, <subrule>})];
<subrule> ::= constant_initialization | variable_initialization |
index_constraint | discriminant_constraint |
instantiation | index_check
</pre></div>
<a name="Action-36"></a>
<h4 class="subsection">5.37.2 Action</h4>
<p>The <subrule> defines the elements that are required to be static:
</p><ul>
<li> “constant_initialization”: expressions used as initial value in
constant declarations.
</li><li> “variable_initialization”: expressions used as initial value in
variable declarations.
</li><li> “index_constraint”: expressions used in index constraints (aka array
sizes).
</li><li> “discriminant_constraint”: expressions used in discriminant
constraints
</li><li> “instantiation”: expressions used as generic actual parameters in
instantiations.
</li><li> “index_check”: expressions used as indices must satisfy statically
the index check. I.e., the expression needs not be static, but it
should be statically provable that the index check cannot fail.
</li></ul>
<p>If no keyword is given, all contexts are controlled.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check non_static (index_constraint);
</pre></div>
<a name="Limitations-13"></a>
<h4 class="subsection">5.37.3 Limitations</h4>
<p>Currently, “constant_initialization” and “variable_initialization”
do not control structured (record and array) variables. For access
variables, the initial value is considered static only if it is a plain
<code><b>null</b></code>. This may improve in future versions of AdaControl.
</p>
<a name="Tips-23"></a>
<h4 class="subsection">5.37.4 Tips</h4>
<p>If all index and discriminant constraints are static, the space
occupied by data structures is computable from the program text. This
rule is useful to enforce this in contexts where the memory space must
be statically determined.
</p>
<hr>
<a name="Not_005fElaboration_005fCalls"></a>
<div class="header">
<p>
Next: <a href="#Not_005fSelected_005fName" accesskey="n" rel="next">Not_Selected_Name</a>, Previous: <a href="#Non_005fStatic" accesskey="p" rel="prev">Non_Static</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Not_005fElaboration_005fCalls-1"></a>
<h3 class="section">5.38 Not_Elaboration_Calls</h3>
<p>This rule controls that certain subprograms (or allocators) are called
only during program initialization.
</p><a name="Syntax-37"></a>
<h4 class="subsection">5.38.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> not_elaboration_calls (<entity>|new {, <entity>|new});
</pre></div>
<a name="Action-37"></a>
<h4 class="subsection">5.38.2 Action</h4>
<p>The <entity> parameters are callable entities (procedure, function or
entry calls). As usual, the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. This rule controls
calls to the indicated callable entities, or allocators if “new” is
given, that are performed at any time except during the elaboration of
library packages.
</p>
<p>If <entity> is the name of a generic procedure or function, then calls
to all instances are controlled.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search not_elaboration_calls (Data.Initialize, new);
</pre></div>
<a name="Tips-24"></a>
<h4 class="subsection">5.38.3 Tips</h4>
<p>Note that renamings are followed: if <entity> has been renamed, it
will be found under all its various names; on the other hand, if <entity>
is the name of a renaming declaration, the rule will only apply to
this name, not to the entity that has been renamed.
</p>
<a name="Limitations-14"></a>
<h4 class="subsection">5.38.4 Limitations</h4>
<p>Due to an (allowed by ASIS standard) limitation of ASIS-for-Gnat, the
rule will not detect calls to subprograms that are implicitely
defined, like calling a <code>"+"</code> on <code>Integer</code>. Fortunately,
it is very unlikely that the user would want to forbid that kind of
calls in non-elaboration code.
</p>
<p>Note also that calls that cannot be statically determined, like calls
to dispatching operations or calls through pointers to subprograms
cannot be detected either.
</p>
<hr>
<a name="Not_005fSelected_005fName"></a>
<div class="header">
<p>
Next: <a href="#Object_005fDeclarations" accesskey="n" rel="next">Object_Declarations</a>, Previous: <a href="#Not_005fElaboration_005fCalls" accesskey="p" rel="prev">Not_Elaboration_Calls</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Not_005fSelected_005fName-1"></a>
<h3 class="section">5.39 Not_Selected_Name</h3>
<p>This rule controls that certain entities are always refered to using
selected notation, even in the presence of <code><b>use</b></code> clauses.
</p><a name="Syntax-38"></a>
<h4 class="subsection">5.39.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> not_selected_name
(<exception places>, <entity> {, <entity>});
<exception places> ::= none | unit | compilation | family
</pre></div>
<a name="Action-38"></a>
<h4 class="subsection">5.39.2 Action</h4>
<p>A name is “selected” if it is prefixed by the name of the construct
where it is declared. Only one level of prefix is required, unless the
prefix itself is the target of a not_selected_name rule.
</p>
<p>The first parameter specifies places where the rule is <i>not</i>
enforced, i.e. where simple notation is allowed:
</p><ul>
<li> “none”: selected notation is always required.
</li><li> “unit”: selected notation is not required within the program unit
where the entity is declared.
</li><li> “compilation”: selected notation is not required within the
compilation unit where the entity is declared.
</li><li> “family”: selected notation is not required within the compilation
unit where the entity is declared, nor within its (direct or indirect)
children.
</li></ul>
<p>Other parameters indicate the <entity> to which the rule applies. As
usual, the whole syntax for entities is allowed for <entity>.
See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check not_selected_name (unit, all Instance);
search not_selected_name (none, Pack.T);
</pre></div>
<a name="Tip-3"></a>
<h4 class="subsection">5.39.3 Tip</h4>
<p>Note that, as usual, the entity can be given in the form “all
name”. This is especially useful for types that must always be
declared with a special name (like <code>Instance</code>, <code>Object</code>,
<code>T</code>) and are intended to be always used with the name of the
enclosing package.
</p>
<hr>
<a name="Object_005fDeclarations"></a>
<div class="header">
<p>
Next: <a href="#Parameter_005fAliasing" accesskey="n" rel="next">Parameter_Aliasing</a>, Previous: <a href="#Not_005fSelected_005fName" accesskey="p" rel="prev">Not_Selected_Name</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Object_005fDeclarations-1"></a>
<h3 class="section">5.40 Object_Declarations</h3>
<p>This rule controls various aspects of object (constants and variables)
declarations.
</p>
<a name="Syntax-39"></a>
<h4 class="subsection">5.40.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> object_declarations (min_integer_span, <min_spec>
{, <min_spec>});
<control_kind> object_declarations (type, <type_spec> {, <type_spec>});
<control_kind> object_declarations (volatile_no_address);
<control_kind> object_declarations (address_not_volatile);
<min_spec> ::= [constant | variable] <value>
<type_spec> ::= [constant | variable] <entity>
</pre></div>
<a name="Action-39"></a>
<h4 class="subsection">5.40.2 Action</h4>
<p>The action depends on the subrule.
</p><ul>
<li> “min_integer_span”: controls that every object of an integer type
has a subtype that covers at least the indicated number of
values. Different values can be specified for variables and constants;
if no modifier (“constant” or “variable”) is supplied, the value
applies to both.
<p>This subrule can be given only once for each combination of
check/search/count and constant/variable.
</p></li><li> “type”: controls every object whose (sub)type matches <entity>. As usual,
the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. If the <entity> is a
subtype, only objects of that exact subtype are controlled; if the
<entity> is a type, objects declared with the type or any subtype of
it are controlled. The control can be restricted to only variables or
only constants; if no modifier (“constant” or “variable”) is
supplied, both are controlled.
<p>This subrule can be given only once for each combination of <entity>
and constant/variable.
</p></li><li> “volatile_no_address”: controls variables that are the target of a
pragma volatile, but have no address clause. Constants are not
controlled, since it would be very strange to have a volatile
constant...
<p>Since this subrule has no parameters, it can be given only once.
</p></li><li> “address_not_volatile”: controls variables that have an address
clause, but are not the target of a pragma volatile. Constants are not
controlled, since it would be very strange to have a volatile
constant...
<p>Since this subrule has no parameters, it can be given only once.
</p></li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">check object_declarations (min_integer_span, variable 5, constant 10);
count object_declarations (min_integer_span, 8);
-- Same value for variables and constants
search object_declarations (volatile_no_address);
search object_declarations (address_not_volatile);
</pre></div>
<a name="Tip-4"></a>
<h4 class="subsection">5.40.3 Tip</h4>
<p>The “min_integer_span” rule can be useful for detecting variables
that should use an enumerated type rather than an integer type.
</p>
<a name="Limitation-8"></a>
<h4 class="subsection">5.40.4 Limitation</h4>
<p>Due to a shortcomming of the ASIS interface, the subrules
“volatile_no_address” and “address_not_volatile” will not detect
variables of a class-wide type that are volatile due to a pragma
volatile applying to the class-wide type. If the pragma applies to the
variable, the subrule will work correctly. A pragma volatile applied
to a class-wide type is detected by the rule
“uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<p>Declaring a class-wide <em>type</em> as volatile seems very peculiar
anyway...
</p>
<hr>
<a name="Parameter_005fAliasing"></a>
<div class="header">
<p>
Next: <a href="#Parameter_005fDeclarations" accesskey="n" rel="next">Parameter_Declarations</a>, Previous: <a href="#Object_005fDeclarations" accesskey="p" rel="prev">Object_Declarations</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Parameter_005fAliasing-1"></a>
<h3 class="section">5.41 Parameter_Aliasing</h3>
<p>This rule controls aliased use of variables in subprogram
calls.
</p>
<a name="Syntax-40"></a>
<h4 class="subsection">5.41.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> parameter_aliasing [([with_in] <level>)];
<level> ::= Certain | Possible | Unlikely
</pre></div>
<a name="Action-40"></a>
<h4 class="subsection">5.41.2 Action</h4>
<p>This rule identifies calls (including function calls) where the same
variable is given as an actual to more than one <code><b>out</b></code> or
<code><b>in out</b></code> parameter, like in the following example:
</p><div class="example">
<pre class="example"><b>procedure</b> Proc (X, Y : <b>out</b> Integer);
...
Proc (X => V, Y => V);
</pre></div>
<p>If the modifier “<code>with_in</code>” is given, aliasing between
<code><b>out</b></code> or <code><b>in out</b></code> parameters and <code><b>in</b></code>
parameters is also considered (unless the <code><b>in</b></code> parameter is
of a user-defined by-copy type). Although aliasing of <code><b>in</b></code>
parameters is generally considered less of an issue, it can lead to
unexpected results when the parameter is passed by reference.
</p>
<p>There are many cases where aliasing cannot be determined
statically. The optional parameter specifies how aggressively the
rule will check for possible aliasings. Possible values are (case
irrelevant):
</p><ul>
<li> Certain (default): Only cases where aliasing is statically certain are
output.
</li><li> Possible: In addition, cases where aliasing may occur depending on
the value of an indexed component are output. These may or may not be
true aliasing, depending on the algorithm. For example, given:
<div class="example">
<pre class="example">Swap (Tab (I), Tab (J));
</pre></div>
<p>there is no aliasing, unless <code>I</code> equals <code>J</code>.
</p>
<p>If all expressions used for indexing in both variables are static, the
rule will be able to eliminate the diagnosis of aliasing (if the
values are different). This avoids unnecessary messages in cases like:
</p><div class="example">
<pre class="example">Swap (Tab (1), Tab (2));
</pre></div>
</li><li> Unlikely: In addition, cases where aliasing may occur due to access
variables pointing to the same variable are output. These may or may
not be true aliasing, depending on the algorithm, but should normally
occur only as the result of very strange practices, like in the
following example:
<div class="example">
<pre class="example"><b>type</b> R <b>is</b>
<b>record</b>
X : <b>aliased</b> Integer;
<b>end</b> <b>record</b>;
X : R;
Y : Access_All_Integer := R.X'access;
...
P (X, Y.all);
</pre></div>
</li></ul>
<p>There will be no false positive with “Certain”. There will be no
false negative with “Unlikely” (but many false
positives). “Possible” is somewhere in-between.
</p>
<p>The rule may be specified at most once for each value of the
parameter. This allows for example to “check” for “Certain” and
“search” for “Possible”.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check parameter_aliasing (with_in certain);
search parameter_aliasing (Possible);
</pre></div>
<p>Note that the rule is quite clever: it will consider partial aliasing
(like a record variable as one parameter, and one of its components as
another parameter), and will not be fooled by renamings.
</p>
<a name="Limitation-9"></a>
<h4 class="subsection">5.41.3 Limitation</h4>
<p>Due to a weakness of the ASIS standard, dispatching calls are not
analyzed. Some calls cannot obviously have aliasing (if there is only
one parameter, or if there are no variables in the parameters f.e.);
other calls are detected by the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Parameter_005fDeclarations"></a>
<div class="header">
<p>
Next: <a href="#Positional_005fAssociations" accesskey="n" rel="next">Positional_Associations</a>, Previous: <a href="#Parameter_005fAliasing" accesskey="p" rel="prev">Parameter_Aliasing</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Parameter_005fDeclarations-1"></a>
<h3 class="section">5.42 Parameter_Declarations</h3>
<p>This rule controls various characteristics of the declaration of parameters
for all callable entities (i.e. functions, procedures and entries).
</p>
<a name="Syntax-41"></a>
<h4 class="subsection">5.42.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> parameter_declarations (<subrule> [,<bounds>]
{,<callable>});
<subrule> ::= all_parameters | in_parameters |
defaulted_parameters | out_parameters |
in_out_parameters | access_parameters |
tagged_parameters | class_wide_parameters |
single_out_parameter
<bounds> ::= min|max <value> [, min|max <value> ]
<callable> ::= function | procedure |
dispatching_function | dispatching_procedure |
protected_function | protected_procedure |
protected_entry | task_entry
</pre></div>
<a name="Action-41"></a>
<h4 class="subsection">5.42.2 Action</h4>
<p>The first parameter is a subrule keyword. “single_out_parameter” has
no parameter; all other subrules require one or two bounds.
</p><ul>
<li> “all_parameters”: Controls callable entities whose number of
parameters is less than the given “min” or greater than the given
“max”. “min” defaults to 0 and “max” to infinity.
</li><li> “in_parameters”, “out_parameters”, “in_out_parameters”: Do the
same, counting only parameters of modes <code><b>in</b></code>,
<code><b>out</b></code>, or <code><b>in out</b></code> respectively.
</li><li> “defaulted_parameters”: Does the same, counting only parameters
declared with an explicit default expression.
</li><li> “access_parameters”: Does the same, counting only (anonymous) access
parameters.
</li><li> “tagged_parameters”: Does the same, counting only parameters of
a specific tagged type.
</li><li> “class_wide_parameters”: Does the same, counting only parameters of
a class-wide type.
</li><li> “single_out_parameter”: Controls callable entities that have exactly
one <code><b>out</b></code> parameter. Procedures with a single <code><b>out</b></code>
parameter might be candidates to becoming functions.
</li></ul>
<p>If one or more <callable_kind> is specified after the <value>, the
rule applies only to the corresponding declaration(s), otherwise it
applies to all callable entities. “dispatching_function” and
“dispatching_procedure” allow different counts for dispatching
subprograms (i.e. primitive subprograms of a tagged type). If
“dispatching_function” or “dispatching_procedure” is not
explicitely specified, “function” (conversely “procedure”) applies
also to dispatching functions (conversely dispatching procedures).
</p>
<p>This rule can be given once for each of check, search, and count for
each subrule and each kind of entity. This way, it is possible to have
a level considered a warning (search), and one considered an error
(check).
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- Callable entities should preferably not have more than 5
-- parameters, and in any case not have more that 10 parameters,
check parameter_declarations (all_parameters, max 10);
search parameter_declarations (all_parameters, max 5);
-- All functions must have parameters and no out or in out
-- parameters (allowed in Ada 2012):
check parameter_declarations (all_parameters, min 1, function);
check parameter_declarations (out_parameters, max 0, function);
check parameter_declarations (in_out_parameters, max 0, function);
-- A regular (not protected) procedure with one out parameter
-- should be replaced by a function
check parameter_declarations (single_out_parameter, procedure);
-- Find all callable entities with class-wide parameters:
search parameter_declarations (class_wide_parameters, max 0);
-- Dispatching operations may have only one parameter of a tagged type:
check parameter_declarations (tagged_parameter,
max 1,
dispatching_function,
dispatching_procedure);
</pre></div>
<a name="Tips-25"></a>
<h4 class="subsection">5.42.3 Tips</h4>
<p>This rule applies to generic subprograms as well as to regular ones.
On the other hand, it does not apply to generic formal subprograms,
since instantiations would only be possible with subprograms which
are supposed to have been already controlled.
</p>
<p>Instantiations are also controlled; the number of parameters is taken
from the corresponding generic.
</p>
<p>Note that this rule controls only “regular” parameters, not generic
formal parameters.
</p>
<p>Note that dispatching operations have necessarily at least one tagged
parameter, although a “max 0” could be specified in the example
above. If you do this, all declarations of dispatching subprograms
will be controlled. Maybe that’s what you want...
</p>
<hr>
<a name="Positional_005fAssociations"></a>
<div class="header">
<p>
Next: <a href="#Potentially_005fBlocking_005fOperations" accesskey="n" rel="next">Potentially_Blocking_Operations</a>, Previous: <a href="#Parameter_005fDeclarations" accesskey="p" rel="prev">Parameter_Declarations</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Positional_005fAssociations-1"></a>
<h3 class="section">5.43 Positional_Associations</h3>
<p>This rule controls the use of positional associations (as opposed to
named associations) in all kinds of associations.
</p>
<a name="Syntax-42"></a>
<h4 class="subsection">5.43.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> positional_associations [(<subrule>, <max_allowed>
[, <category> {, <entity>}])];
<subrule> ::= all | all_positional | same_type
<category> ::= [not_operator] call | discriminant | pragma |
array_aggregate | record_aggregate | instantiation |
enumeration_representation
</pre></div>
<a name="Action-42"></a>
<h4 class="subsection">5.43.2 Action</h4>
<p>The rule controls pragmas, discriminants, calls, aggregates, or
instantiations that use too many positional associations. The
definition of “too many” depends on the subrule:
</p><ul>
<li> “all”: when positional associations are given in a place where there
is more than <max_allowed> associations (both positional and named).
</li><li> “all_positional”: when there is more than <max_allowed> positional
associations.
</li><li> “same_type”: when more than <max_allowed> positional parameters are
of the same type.
</li></ul>
<p>In addition, a <category> can be specified to restrict the rule to
specific kinds of associations; if not specified, all associations are
controlled. The categories carry their obvious meaning, with the
distinction that “array_aggregate” applies only to “true” array
aggregates, while “enumeration_representation” applies to the
special array aggregate used in enumeration representation
clauses. Note that the “same_type” subrule is not allowed for the
“pragma” category. For “pragma”, ”call”, and “instantiation”,
entities can also be specified; such entities are exempted from the
rule (i.e. the rule will not control these entities). See examples
below.
</p>
<p>For calls, positional association is <i>not</i> reported for operators
that use infix notation (since named notation is not possible); in
addition, if the “not_operator” modifier is specified before the
“call” keyword (not allowed elsewhere), positional association is
never reported for operators, even if they are called with the syntax
of a normal function call (i.e. <code>Pack."+" (A,B)</code>). Calls to
subprograms that are attributes are not reported either, since named
notation is not allowed for them.
</p>
<p>This rule can be specified once for each combination of <subrule>,
<category>, and <control_kind>. This way, it is possible to have a
number of positional associations considered a warning (search), and
one considered an error (check). Of course, this makes sense only if
<max_allowed> for search is greater than the one for check. It is also
possible to have different criteria for each category.
</p>
<p>If no parameter is given, it is equivalent to
“<code>positional_associations (all, 0)</code>”, i.e. all positional
associations are controlled.
</p>
<p>Ex:
</p><div class="example">
<pre class="example"> -- All positional associations:
check positional_associations;
-- All positional associations in aggregates:
check positional_associations(all, 0, array_aggregate);
check positional_associations(all, 0, record_aggregate);
-- All positional associations with more than 3 elements:
search positional_associations (all, 3);
-- Positional associations in calls
-- with more than 3 params of the same type
search positional_associations (same_type, 3, call);
-- Positional associations in calls with more than 2 elements (except
-- calls to any subprogram called Put)
search positional_associations(all, 2, call, all put);
</pre></div>
<a name="Variable-5"></a>
<h4 class="subsection">5.43.3 Variable</h4>
<p>The rule provides a variable to define how to count parameters in the
case of calls that use the prefix notation (i.e. the “object.method”
syntax).
</p>
<table>
<tr><td width="25%"><b>Variable</b></td><td width="10%"><b>Values</b></td><td width="10%"><b>Default</b></td><td width="55%"><b>Effect</b></td></tr>
<tr><td width="25%">Count_Prefix_Operand</td><td width="10%">off<br>on</td><td width="10%">on</td><td width="55%"><dl compact="compact">
<dt>off</dt>
<dd><p>The parameter given as prefix is not counted as a positional parameter.
</p></dd>
<dt>on</dt>
<dd><p>The parameter given as prefix is counted as a positional parameter,
just like if the prefix notation had not been used.
</p></dd>
</dl></td></tr>
</table>
<a name="Fixes-5"></a>
<h4 class="subsection">5.43.4 Fixes</h4>
<p>This rule generates fixes: in calls and instantiations, names are added
to transform positional associations into named associations.
</p>
<a name="Tips-26"></a>
<h4 class="subsection">5.43.5 Tips</h4>
<p>There are two kinds of calls where the rule does not complain about
usage of positional association: infix operator calls (since requiring
named notation would not allow infix notation any more), and calls to
subprograms that are attributes (since named notation is not allowed
for these).
</p>
<p>For the purpose of the “same_type” subrule, integer literals are
considered of the same type as any parameter of an integer type, and
similarly for other universal values. The reason is that this rule is
intended to avoid confusion between parameters, when strong typing
would not detect an inversion of parameters for example; such a case
would happen between parameters of a universal type.
</p>
<p>For calls, another rule controls positional associations according to
the value of parameters rather than their number:
See <a href="#Insufficient_005fParameters">Insufficient_Parameters</a>.
</p>
<hr>
<a name="Potentially_005fBlocking_005fOperations"></a>
<div class="header">
<p>
Next: <a href="#Pragmas" accesskey="n" rel="next">Pragmas</a>, Previous: <a href="#Positional_005fAssociations" accesskey="p" rel="prev">Positional_Associations</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Potentially_005fBlocking_005fOperations-1"></a>
<h3 class="section">5.44 Potentially_Blocking_Operations</h3>
<p>This rule controls usage of potentially blocking operations (as
defined in LRM 9.5.1 (8..16)) from within protected operations.
</p>
<a name="Syntax-43"></a>
<h4 class="subsection">5.44.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> potentially_blocking_operations;
</pre></div>
<a name="Action-43"></a>
<h4 class="subsection">5.44.2 Action</h4>
<p>The rule follows the call graph, starting from every protected
operation, and identifies all (direct and indirect) potentially
blocking operations encountered. All protected types in the program
are controlled.
</p>
<p>Of course, calls to standard subprograms (notably IOs) that are
defined to be potentially blocking are recognized.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check potentially_blocking_operation;
</pre></div>
<a name="Tips-27"></a>
<h4 class="subsection">5.44.3 Tips</h4>
<p>This rule is very clever at finding potentially blocking operations
resulting from external calls (or requeues) to the current protected
object, even if this happens through a long chain of subprogram
calls. Typically, this happens when a protected operation calls a
subprogram, which in turn makes a call to an operation of the same
protected object. Such calls generally result in dead-locks.
</p>
<p>Therefore, it is advisable to run this rule on any program that
exhibits mysterious (and hard to find) deadlocks that seem to involve
protected objects.
</p>
<p>When a single protected object is being analyzed, the rule will
diagnose a circularity if there is a call to an operation of the same
object in the call chain; however, if a protected type is being
analyzed, the rule will diagnose a circularity if there is a call to
any object of the same type in the call chain. Although it is possible
to construct examples of this latter case where there is no risk of
deadlock, it is so contrieved that it certainly deserves being looked
at. But since the call is not 100% certain to be potentially blocking,
the message will tell “possible external call” instead of “external
call” in this case.
</p>
<a name="Limitation-10"></a>
<h4 class="subsection">5.44.4 Limitation</h4>
<p>There is one case defined in LRM E.4(17) which is not recognized:
remote subprograms calls.
</p>
<p>Calls through pointers to subprograms, dispatching calls and calls to
generic formal subprograms are unknown statically; they are assumed to
be non potentially blocking. Such calls are detected by the rule
“uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Pragmas"></a>
<div class="header">
<p>
Next: <a href="#Record_005fDeclarations" accesskey="n" rel="next">Record_Declarations</a>, Previous: <a href="#Potentially_005fBlocking_005fOperations" accesskey="p" rel="prev">Potentially_Blocking_Operations</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Pragmas-1"></a>
<h3 class="section">5.45 Pragmas</h3>
<p>This rule controls usage of one or several specific pragmas.
</p>
<a name="Syntax-44"></a>
<h4 class="subsection">5.45.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> pragmas (<pragma spec> {, <pragma spec>});
<pragma spec> ::= [multiple] all|nonstandard|<pragma name>
</pre></div>
<a name="Action-44"></a>
<h4 class="subsection">5.45.2 Action</h4>
<p>If the special name “nonstandard” is given, then all
implementation-defined and unrecognized pragmas will be controlled.
If the special name “all” is given, then all pragmas will be
controlled. Otherwise, the parameters are the names of pragmas to be
controlled. Note that <pragma name> must be the simple name of the
pragma, since pragma names are predefined and do not follow the rules
for regular Ada entities.
</p>
<p>If “multiple” is specified before the pragma spec (or the special
name), the corresponding pragma(s) are controlled only if they apply
to multiple entities, because one of the parameters is an overloaded
name.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check pragmas (elaborate_all, elaborate_body);
-- Search pragma Convention that apply to several entities:
search pragmas (multiple convention);
</pre></div>
<a name="Tips-28"></a>
<h4 class="subsection">5.45.3 Tips</h4>
<p>If “all” and/or “nonstandard” is given together with a specific
pragma name in a “search” or “check” rule, a message is issued
only for the most specific occurrence. However, for “count”, all
appropriate occurrences are counted, i.e. given the following rules:
</p><div class="example">
<pre class="example">C1 : count pragmas (annotate);
C2 : count pragmas (nonstandard);
C3 : count pragmas (all);
</pre></div>
<p>Counter C1 will report the number of occurrences of <code><b>pragma</b>
Annotate</code> (a non-standard GNAT pragma), counter C2 will report the
number of non-standard pragmas (including occurrences of
<code>Annotate</code>), and counter C3 will report the total number of
pragmas (including occurrences of <code>Annotate</code>).
</p>
<hr>
<a name="Record_005fDeclarations"></a>
<div class="header">
<p>
Next: <a href="#Reduceable_005fScope" accesskey="n" rel="next">Reduceable_Scope</a>, Previous: <a href="#Pragmas" accesskey="p" rel="prev">Pragmas</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Record_005fDeclarations-1"></a>
<h3 class="section">5.46 Record_Declarations</h3>
<p>This rule controls various aspects of the components of records.
</p>
<a name="Syntax-45"></a>
<h4 class="subsection">5.46.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> record_declarations (component, <compo_kind>
{,<repr_cond>});
<compo_kind> ::= <entity>|<category>
<category> ::= () | access | array | delta | digits | mod |
private | protected | range | record | tagged | task
<repr_cond> ::= [not] in_variant | aligned | initialized | packed |
sized
</pre></div>
<a name="Action-45"></a>
<h4 class="subsection">5.46.2 Action</h4>
<p>The first parameter is a subrule keyword:
</p><ul>
<li> “Component” controls record components whose type is the indicated
<entity>, or whose type belongs to the indicated <category>. If the
<entity> is a subtype, only record components that are of that subtype
are controlled. If the indicated <entity> is a type, all record
components that are of that type (including subtypes) are
controlled. The meaning of <category> is:
<ul>
<li> “()”: The component is of an enumerated type.
</li><li> “access”: The component is of an access type.
</li><li> “array”: The component is of an array type.
</li><li> “delta”: The component is of a fixed point type (it is not currently
possible to distinguish ordinary fixed point types from decimal fixed
point types).
</li><li> “digits”: The component is of a floating point type.
</li><li> “mod”: The component is of a modular type.
</li><li> “private”: The component is of a private type (including private
extensions).
</li><li> “protected”: The component is of a protected type.
</li><li> “range”: The component is of a signed integer type.
</li><li> “record”: The component is of an (untagged) record type.
</li><li> “tagged”: The component is of a tagged type (including type
extensions).
</li><li> “task”: The component is of a task type.
</li></ul>
<p>If <repr_cond> are specified, the rule controls only record components
to which all the corresponding representation items apply:
</p><ul>
<li> “in_variant”: The component appears inside the variant part of the
record.
</li><li> “not in_variant”: The component appears inside the fixed part of the
record.
</li><li> “aligned”: Either no component clause applies to the component, or
the corresponding first bit is a multiple of <code>Storage_Unit</code>.
</li><li> “not aligned”: A component clause applies to the component, and the
corresponding first bit is not a multiple of <code>Storage_Unit</code>.
</li><li> “initialized”: The component has a default initialization
expression.
</li><li> “not initialized”: The component has no default initialization
expression.
</li><li> “packed”: A pragma Pack applies to the component type.
</li><li> “not packed”: No pragma Pack applies to the component type.
</li><li> “sized”: A component clause applies to the component (therefore
imposing the size).
</li><li> “not sized”: No component clause applies to the component.
</li></ul>
</li></ul>
<p>This rule can be specified several times for the “component”
subrule.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- All record components of a discrete type should be initialized:
check record_declarations (component, (), not initialized);
-- The size of all components of type HW_Types.Squeezed must
-- have a component clause:
check record_declarations (component, HW_Types.Squeezed, not sized);
-- Find unaligned components of a packed array type:
check record_declarations (component, array, packed, not aligned);
</pre></div>
<a name="Tips-29"></a>
<h4 class="subsection">5.46.3 Tips</h4>
<p>It may seem strange to have a rule with only one subrule, but we
expect to add more in the near future. Stay tuned...
</p>
<a name="Limitations-15"></a>
<h4 class="subsection">5.46.4 Limitations</h4>
<p>If “[not] aligned” is specified, there are some rare cases where
AdaControl cannot evaluate whether a component is aligned or not; in
this case, it will “assume the worse” (i.e. report as if the
component had the specified alignment), thus creating possible false
positives. Such cases are detected by the rule “uncheckable”.
See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Reduceable_005fScope"></a>
<div class="header">
<p>
Next: <a href="#Representation_005fClauses" accesskey="n" rel="next">Representation_Clauses</a>, Previous: <a href="#Record_005fDeclarations" accesskey="p" rel="prev">Record_Declarations</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Reduceable_005fScope-1"></a>
<h3 class="section">5.47 Reduceable_Scope</h3>
<p>This rule controls declarations that could be moved to some inner
scope.
</p>
<a name="Syntax-46"></a>
<h4 class="subsection">5.47.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> reduceable_scope [(<subrule> {, <subrule>})];
<subrule> ::= {<restriction>} all | variable | constant |
subprogram | type | package |
exception | generic | use
<restriction> ::= no_blocks | to_body
</pre></div>
<a name="Action-46"></a>
<h4 class="subsection">5.47.2 Action</h4>
<p>The rule reports on any declaration that is referenced only from a
single, inner scope, or in the case of <code><b>use</b></code> clauses, it will
report on packages named in a <code><b>use</b></code> clause whose elements are
used only in a single, inner scope. For entitities declared in package
specifications, the rule reports if they are used only from the
corresponding package body.
</p>
<p>The initialization of an object is considered a usage of the object at
the place where it is declared, thus preventing it from being
moved. Therefore, constants and initialized variables are never
reported as being movable to inner scopes; they are reported as being
movable to package bodies however. Entities that are used as prefixes
of a ’Access or ’Address attribute are never reported, since moving
them would change their accessibility level. Similarly, task objects
are not reported since moving them would change their master. Finally,
dispatching operations (primitive operations of tagged types) are not
reported either, since they can be the target of an “invisible”
(dispatching) call.
</p>
<p>If no <subrule> is given, or the <subrule> is “all”, all declarations
are controlled. If <code>no_blocks</code> is specified in front of a
<subrule>, the rule will not consider blocks as possible targets for a
reduced scope for the corresponding category. If <code>to_body</code> is
specified in front of a <subrule>, the rule will report only elements
declared in a package specification that could be moved into the body.
Specifying “all” explicitely is only useful in the case where there
is a <restriction>.
</p>
<p>As a side effect, the rule will report about entities that are
declared but not used (i.e. whose scope reduces to nothing).
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- Types and variables shall be declared in the innermost scope
-- where they are useful:
check reduceable_scope (variable, type);
-- Packages and subprograms shall be declared in the innermost
-- scope where they are useful, but they are not allowed in blocks:
check reduceable_scope (no_blocks subprogram, no_blocks package);
-- Use clause should be as restricted as possible:
search reduceable_scope (use);
</pre></div>
<a name="Tips-30"></a>
<h4 class="subsection">5.47.3 Tips</h4>
<p>If you think that <code><b>use</b></code> clauses are acceptable, but should be
limited to the smallest possible scope, you would generally specify:
</p><div class="example">
<pre class="example">check unnecessary_use_clause;
check reduceable_scope (use);
</pre></div>
<a name="Limitation-11"></a>
<h4 class="subsection">5.47.4 Limitation</h4>
<p>Currently, the rule does not report <code><b>use</b></code> clauses declared in
a package specification that could be moved to the body. Such clauses
appear as “unused” (but of course, the compiler will complain on the
body if the clause is removed).
</p>
<hr>
<a name="Representation_005fClauses"></a>
<div class="header">
<p>
Next: <a href="#Return_005fType" accesskey="n" rel="next">Return_Type</a>, Previous: <a href="#Reduceable_005fScope" accesskey="p" rel="prev">Reduceable_Scope</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Representation_005fClauses-1"></a>
<h3 class="section">5.48 Representation_Clauses</h3>
<p>This rule controls usage of representation clause.
</p>
<a name="Syntax-47"></a>
<h4 class="subsection">5.48.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> representation_clauses [(<subrule> {, <subrule>})];
<subrule> ::= {<category>} <repr_kw> | [global] [object] <attribute>
<repr_kw> ::=
at | at_mod | enumeration |
fractional_size | incomplete_layout | layout |
non_aligned_component | non_contiguous_layout | non_power2_size |
no_bit_order_layout | overlay
<category> ::=
() | range | mod | delta | digits | array | record |
tagged | extension | access | new | private | task | protected
</pre></div>
<a name="Action-47"></a>
<h4 class="subsection">5.48.2 Action</h4>
<p>Without parameter, the rule controls all representation clauses,
otherwise it will control the representation clauses given as
parameter.
</p>
<p>If a representation keyword or attribute is preceded by one or several
categories, the rule controls only the representation items that apply
to types belonging to the categories (the type of the component for
the <code>non_aligned_component</code> subrule):
</p><ul>
<li> “()”: Enumerated types
</li><li> “range”: Signed integer types
</li><li> “mod”: Modular types
</li><li> “delta”: Fixed point types (no possibility to differentiate ordinary
and decimal fixed point types yet).
</li><li> “digits”: Floating point types
</li><li> “array”: Array types
</li><li> “record”: (untagged) record types
</li><li> “tagged”: Root tagged types
</li><li> “extension”: Type extensions (tagged derived types)
</li><li> “access”: Access types
</li><li> “new”: Derived types
</li><li> “private”: Private types
</li><li> “task”: Task types
</li><li> “protected”: Protected types
</li></ul>
<p>The meaning of the representation keywords is:
</p><ul>
<li> “at” controls address clauses given in Ada 83 style (“for XXX use
at”).
</li><li> “at_mod” controls alignment clauses given in Ada 83 style (“for T
use record at mod XX;”).
</li><li> “enumeration” controls enumeration representation clauses.
</li><li> “fractional_size” controls size clauses whose value is not an
integral multiple of <code>System.Storage_Unit</code>. “non_power2_size”
controls size clauses whose value in <code>System.Storage_Unit</code> is not
a power of 2 (i.e. for most machines, it will mean a value different
from 8, 16, 32, and 64).
</li><li> “incomplete_layout” controls record representation clauses that miss
the specification of some components of the record’s type.
</li><li> “layout” controls all record representation clauses, while
“no_bit_order_layout” controls record representation clauses whose
type is not also the target of a bit_order attribute specification
(such types have a non-portable representation).
</li><li> “non_aligned_component” controls components that do not start on a
storage unit boundary. The message gives the offset (in bits) relative
to the closest storage unit boundary.
</li><li> “non_contiguous_layout” controls record representation clauses where
there are unused bits between components (or before the first
component). A message is issued for each “gap” between
components. In addition, if a size clause is given for the type, the
rule will report if there are unused bits at the end of the component
(i.e. the size clause is bigger than the end of the last
component). In the case of variant records, there can be
overlapping fields; the rule will control only the bits that belong to
no variant at all.
</li><li> “overlay” controls address clauses (given in either style), where the value
given is the <code>'Address</code> of some other element.
</li></ul>
<p>In addition to these keyword, any specifiable attribute can be given
(including the initial “<code>'</code>”); the rule will control
specifications of this attribute. If the modifier “global” is given
before the attribute, only attribute specifications for global
entities are controlled. If the modifier “object” is given before
the attribute, only attribute specifications for objects are
controlled (as opposed to types for example). Note that double
attributes (like “<code>'CLASS'INPUT</code>”) can be given, and are
considered different from the simple attribute (“<code>'INPUT</code>”). It
is of course possible to specify both.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">All_Addresses: check representation_clauses (at, 'address);
All_Input: check representation_clauses ('input, 'class'input);
Sized_Objects: check representation_clauses (object 'size);
count representation_clauses ('SIZE);
-- check layout clauses for derived types:
check representation_clauses (new layout);
-- check layout clauses for root tagged types and type extensions:
check representation_clauses (tagged extension layout);
</pre></div>
<a name="Limitation-12"></a>
<h4 class="subsection">5.48.3 Limitation</h4>
<p>For the “fractional_size” and “non_contiguous_layout” subrules,
there are some rare cases where AdaControl cannot evaluate the given
size or elements of the record representation clause, and thus not
detect the corresponding situation. Such cases are detected by the
rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<a name="Tips-31"></a>
<h4 class="subsection">5.48.4 Tips</h4>
<p>The specifiable attributes (the ones that can be given as parameters
to this rule) are <code>'Address</code>, <code>'Size</code>,
<code>'Component_Size</code>, <code>'Alignment</code>, <code>'External_Tag</code>,
<code>'Small</code>, <code>'Bit_Order</code>, <code>'Storage_Pool</code>,
<code>'Storage_Size</code>, <code>'Write</code>, <code>'Output</code>, <code>'Read</code>,
<code>'Input</code>, and <code>'Machine_Radix</code>. See Ada Reference Manual
13.3(77).
</p>
<p>Ada allows partial record representation clauses, i.e. it does not
require all fields to be specified. This means that if you add a field
to a record and forget to update the associated representation clause,
there will be no compilation error. The “incomplete_record” subrule
is handy for making sure that this does not happen.
</p>
<p>Derived types with a representation clause may suffer an efficiency
penalty, since calling an inherited subrograms requires a change of
representation. Representation clauses for tagged types are dubious,
since these types have hidden fields added by the compiler.
</p>
<hr>
<a name="Return_005fType"></a>
<div class="header">
<p>
Next: <a href="#Side_005fEffect_005fParameters" accesskey="n" rel="next">Side_Effect_Parameters</a>, Previous: <a href="#Representation_005fClauses" accesskey="p" rel="prev">Representation_Clauses</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Return_005fType-1"></a>
<h3 class="section">5.49 Return_Type</h3>
<p>This rule controls that certain form of types are not used for
function results.
</p>
<a name="Syntax-48"></a>
<h4 class="subsection">5.49.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> return_type [(<subrule> {, <subrule>})];
<subrule> ::= class_wide | limited_class_wide |
constrained_array | protected |
task | unconstrained_array |
unconstrained_discriminated | anonymous_access
</pre></div>
<a name="Action-48"></a>
<h4 class="subsection">5.49.2 Action</h4>
<p>This rule controls functions whose return type belongs to one of the
indicated type kinds:
</p><ul>
<li> <code>class_wide</code> controls all class-wide types, while
<code>limited_class_wide</code> controls only limited class-wide types.
</li><li> <code>constrained_array</code> controls constrained array types
</li><li> <code>unconstrained_discriminated</code> controls types with discriminants
(but not constrained subtypes of such types)
</li><li> <code>unconstrained_array</code> controls unconstrained array types
</li><li> <code>task</code> controls task types, or composite types that include tasks
as subcomponents.
</li><li> <code>protected</code> controls protected types, or composite types that include protected
objects as subcomponents.
</li><li> <code>anonymous_access</code> controls anonymous access types.
</li></ul>
<p>If no subrule is specified, all type kinds are controlled. Note that
more than one kind may apply to a type: for example, a function can
return a class-wide type with discriminants that includes tasks and
protected objects as subcomponents. In this case, several messages are
issued for the same type.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check return_type (unconstrained_discriminated, unconstrained_array);
</pre></div>
<hr>
<a name="Side_005fEffect_005fParameters"></a>
<div class="header">
<p>
Next: <a href="#Silent_005fExceptions" accesskey="n" rel="next">Silent_Exceptions</a>, Previous: <a href="#Return_005fType" accesskey="p" rel="prev">Return_Type</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Side_005fEffect_005fParameters-1"></a>
<h3 class="section">5.50 Side_Effect_Parameters</h3>
<p>This rule controls calls that may depend on the order of evaluation of
parameters.
</p>
<a name="Syntax-49"></a>
<h4 class="subsection">5.50.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> side_effect_parameters (<entity> {, <entity>});
</pre></div>
<a name="Action-49"></a>
<h4 class="subsection">5.50.2 Action</h4>
<p>This rule controls subprogram calls or generic instantiations where
different actual parameters call functions known to have side
effects. This is dangerous practice, since correct behaviour may
depend on a certain evaluation order of parameters, which is not
specified by the language.
</p>
<p>All <entity> are functions that are assumed to interfere, i.e. the
rule will signal if any of these functions is called more than once in
the parameters of a call. As usual, the whole syntax for entities is
allowed for <entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</p>
<p>It is allowed to give the name of a generic function, or of a function
declared in a generic package; in this case, all functions resulting
from instantiations of these generics will be considered.
</p>
<p>In the case of renamings, you must give the name of the original
function; the rule will work correctly if the call is made through a
renaming of this function.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check side_effect_parameters (F1);
check side_effect_parameters (G1, G2);
</pre></div>
<p>Here, F1 has a side effect, and the rule will signal if it is called
more than once. G1 and G2 are assumed to interfere, and therefore the
rule will signal if either is called more than once, or if both are
called. However, having a call that mentions F1 and G2 is OK.
</p>
<a name="Limitation-13"></a>
<h4 class="subsection">5.50.3 Limitation</h4>
<p>Due to the size of internal structures, this rule may not be given
more than 100 times.
</p>
<p>Due to an unimplemented feature of ASIS-for-Gnat, this rule will not
process defaulted parameters, and hence not detect interferences due
to calling a side-effect function through the default value.
</p>
<hr>
<a name="Silent_005fExceptions"></a>
<div class="header">
<p>
Next: <a href="#Simplifiable_005fExpressions" accesskey="n" rel="next">Simplifiable_Expressions</a>, Previous: <a href="#Side_005fEffect_005fParameters" accesskey="p" rel="prev">Side_Effect_Parameters</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Silent_005fExceptions-1"></a>
<h3 class="section">5.51 Silent_Exceptions</h3>
<p>This rule controls exception handlers that can cause exceptions to
silently disappear.
</p>
<a name="Syntax-50"></a>
<h4 class="subsection">5.51.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> silent_exceptions (<element> {, <element>});
element ::= <control-item> | <report-item>
control-item ::= not | with <entity> | others
report-item ::= raise | explicit_raise | reraise | return |
requeue | <entity>
</pre></div>
<a name="Action-50"></a>
<h4 class="subsection">5.51.2 Action</h4>
<p>The rule controls handlers that do <i>not</i> call one of the given
subprograms (for example a reporting procedure) nor perform other
required operations, like returning, requeuing, or re-raising an
exception.
</p>
<p>A parameter that starts with “not” or “with” is a <control-item>
and defines wich exceptions are controlled; the <entity> should be
either an exception, or the name of a library unit (in which case, it
applies to all exceptions declared in the library unit). As usual, the
whole syntax for entities is allowed here. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. If the <entity> is (part of) a generic, then it applies
to all exceptions from all corresponding instantiations. If there is
no <control-item>, then all exceptions are controlled.
</p>
<p>If several <control-item> are given, the ones with “with” add
exceptions to the set of controlled exceptions, and the ones with
“not” remove exceptions, in order, starting from the empty set if
the first <control-item> is a “with”, or starting from the set of
all exceptions if the first <control-item> is a “not”. See examples
below.
</p>
<p>“<code><b>when others</b></code>” handlers are always controlled, unless
there is an explicit “not others” <control-item>. A “with others”
<control-item> can be specified to check <em>only</em> “<code><b>when
others</b></code>” handlers.
</p>
<p>The other parameters are <report-item> and define the constructs
considered “reporting”. <entity> should correspond to an Ada
callable entity or generic package; as usual, the whole syntax for
entities is allowed here. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>. If a
generic procedure or function is given, then all corresponding
instances are considered reporting subprograms. If a generic package
is given, any instantiation (in an inner block of the handler) is
considered reporting. In addition, the special names
“explicit_raise”, “reraise”, “return” and “requeue” mark raise
statements with an explicit exception name, raise statements without
an exception name, return statements (including extended return
statements), and requeue statements (respectively) as
reporting. “raise” is a shorthand for both “explicit_raise” and
“reraise”.
</p>
<p>If “explicit_raise” is given as a parameter, the procedure
<code>Ada.Exceptions.Raise_Exception</code> is automatically added to the
list of procedures for both Check and Search, unless it is
explicitely specified as a parameter in a rule; and similarly
<code>Ada.Exceptions.Reraise_Occurrence</code> is added for “reraise”.
This way, it is possible to consider them as reporting procedures for
Check (for example) and not for Search.
</p>
<p>A handler where <em>all</em> exceptions are uncontrolled is not
controlled at all (i.e. it is allowed to be non reporting). Otherwise,
the rule reports if the handler does not contain at least one of the
<report-item> in each possible path of the handler. If the
<report-item> appear only in <code><b>if</b></code> or <code><b>case</b></code>
statements, but not in all possible paths, or if they appear only in
the body of <code><b>loop</b></code> statements, the rule will issue a message
asking for a manual verification, since it cannot be statically
determined whether the proper treatment happens in every case.
</p>
<p>Note that the purpose of this rule is to require the reporting calls
to be “eye-visible”, i.e. textually written in the exception
handler. For example, the rule will accept a call to a procedure
inside the sequence of statements of a package body declared in some
inner block; however, it will not accept the same call if it is in the
sequence of statements of a package instantiation (unless the generic
package is itself mentionned as reporting), because the call is not
“eye-visible”. For the same reason, a call to a reporting function
which happens as the default value of an omitted parameter in some
other call will not be accepted.
</p>
<p>This rule can be given once for each of check, search and count. This
way, it is possible to have a level considered a warning (search), and
one considered an error (check).
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- Make an error if exception is not reraised and does not call
-- Reports.Trace, but make it only a warning if the exception is an
-- IO exception or Constraint_Error:
check silent_exceptions (not ada.io_exceptions,
not standard.constraint_error,
raise,
reports.trace);
search silent_exceptions (raise, reports.trace);
-- check handlers that do not reraise the exception, except for
-- IO exceptions:
check silent_exceptions (not Ada.IO_Exceptions, reraise);
-- Same for predefined exceptions, except Constraint_Error:
check silent_exceptions (not Standard, with Standard.Constraint_Error,
reraise);
-- Same for all exceptions named User_Error, wherever they are declared,
-- and no others
check silent_exceptions (with all User_Error, reraise);
-- Same for "when others" handlers
check silent_exceptions (with others, reraise);
</pre></div>
<a name="Limitations-16"></a>
<h4 class="subsection">5.51.3 Limitations</h4>
<p>Currently, “return” includes all return statements. It would be nice
to separate function returns from procedure or accept returns. This is
expected to be done in some future version of AdaControl.
</p>
<p>There are two cases that are not statically checkable, and
thus may not be identified by this rule: if an exception is raised in
an inner block statement and handled locally, and if the exception
handler aborts the current task.
</p>
<p>If a reporting function is given, there are a few cases where the
calls will not be recognized:
</p><ul>
<li> inside a pragma
</li><li> in a representation clause
</li><li> in a code statement (i.e. as a field of a machine code instruction)
</li></ul>
<p>This limitation is intentional: these are such weird places to call a
reporting function that it seems better to draw attention to it...
</p>
<hr>
<a name="Simplifiable_005fExpressions"></a>
<div class="header">
<p>
Next: <a href="#Simplifiable_005fStatements" accesskey="n" rel="next">Simplifiable_Statements</a>, Previous: <a href="#Silent_005fExceptions" accesskey="p" rel="prev">Silent_Exceptions</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Simplifiable_005fExpressions-1"></a>
<h3 class="section">5.52 Simplifiable_Expressions</h3>
<p>This rule controls expressions that can be simplified in various ways.
</p>
<a name="Syntax-51"></a>
<h4 class="subsection">5.52.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> simplifiable_expressions [(<subrule> {, <subrule>})];
<subrule> ::= conversion | logical | logical_false | logical_not |
logical_true | parentheses | range
</pre></div>
<a name="Action-51"></a>
<h4 class="subsection">5.52.2 Action</h4>
<p>Without parameters, all kinds of simplifiable expressions are
controlled; otherwise, the controlled expressions depend on the
subrule:
</p><ul>
<li> “conversion” controls type conversions where the expression is of a
universal type (a litteral or named number), or where the target
subtype is either the same as the expression’s subtype, or the first
named subtype of the expression.
</li><li> “logical_true” controls redundant boolean expressions of the form
<code><expr> = True</code> (or <code>/=</code>), and “logical_false” does the
same for comparisons with <code>false</code>.
</li><li> “logical_not” controls <code><b>not</b></code> operators whose argument is a
comparison (which could be inverted).
</li><li> “logical” is the same as specifying “logical_true”,
“logical_false” and “logical_not”.
</li><li> “parentheses” controls unnecessary parentheses like those
surrounding the expression of an assignment, an “if” or a “case”
statement, or those that are not required by operators precedence
rules.
</li><li> “range” controls expressions of the form <code>T'First .. T'Last</code>
that should be <code>T'range</code> (or even simply <code>T</code>).
</li></ul>
<p>This rule can be given at most once for each subrule.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">search simplifiable_expressions (parentheses);
check simplifiable_expressions (range, logical);
</pre></div>
<a name="Fixes-6"></a>
<h4 class="subsection">5.52.3 Fixes</h4>
<p>The following subrules generate fixes:
</p><ul>
<li> “Conversions”: The unnecessary conversion (or qualification) is removed.
</li><li> “Parentheses”: The unnecessary parentheses are removed.
</li></ul>
<a name="Tips-32"></a>
<h4 class="subsection">5.52.4 Tips</h4>
<p>There are cases where parentheses may seem unnecessary, but are
(purposedly) not reported by this rule. Consider for example:
</p><div class="example">
<pre class="example"> X := A + (B + C);
</pre></div>
<p>Removing the parentheses would change the expression to mean:
</p><div class="example">
<pre class="example"> X := (A + B) + C;
</pre></div>
<p>If the <code>"+"</code> operator has be redefined and is no more
associative, this would actually change the meaning of the program. In
a less contrieved example, note that:
</p><div class="example">
<pre class="example"> X mod (A*B)
</pre></div>
<p>is <i>not</i> the same as:
</p><div class="example">
<pre class="example"> X mod A * B
</pre></div>
<p>For these reasons, and to make the rule easier to understand for the
user, the rule does not report unnecessary parentheses between
operators of identical priority levels.
</p>
<p>Conversion of universal value is never necessary, however there are
cases where overloading resolution may require the conversion to be
replaced by a qualification, rather than being simply removed.
</p>
<hr>
<a name="Simplifiable_005fStatements"></a>
<div class="header">
<p>
Next: <a href="#Statements" accesskey="n" rel="next">Statements</a>, Previous: <a href="#Simplifiable_005fExpressions" accesskey="p" rel="prev">Simplifiable_Expressions</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Simplifiable_005fStatements-1"></a>
<h3 class="section">5.53 Simplifiable_Statements</h3>
<p>This rule controls statements that can be removed or simplified in
various ways without changing the meaning of the program.
</p>
<a name="Syntax-52"></a>
<h4 class="subsection">5.53.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> simplifiable_statements [(<subrule> {, <subrule>})];
<subrule> ::= block | dead | handler | if |
if_for_case | if_not | loop | loop_for_while |
nested_path | null
</pre></div>
<a name="Action-52"></a>
<h4 class="subsection">5.53.2 Action</h4>
<p>Without parameter, all kinds of simplifiable statements are
controlled; otherwise, the controlled statements depend on the
subrule:
</p><ul>
<li> <code>block</code> controls block statements that have no labels, no
declarations, and no exception handlers.
</li><li> <code>dead</code> controls dead code, i.e. statements that are statically
known to be never executed. This includes statements that follow a
<code><b>return</b></code>, <code><b>requeue</b></code>, or <code><b>goto</b></code> statement,
or an <code><b>exit</b></code> statement that is either unconditional or whose
condition is statically known to be true. It includes also
<code><b>while</b></code> statements and <code><b>if</b></code> statements (including
<code><b>elsif</b></code> paths) whose condition is statically false, branches
of <code><b>case</b></code> statements whose choices are all statically null
ranges, and <code><b>for</b></code> loops whose range is statically empty.
</li><li> <code>handler</code> controls “trivial” exception handlers, i.e. handlers
whose sequence of statements includes only a single <code><b>raise</b></code>
statement without an exception name. However, a handler is not
reported if there is also a non trivial handler for <code><b>others</b></code>.
These examples show the situation:
<div class="example">
<pre class="example"><b>exception</b>
<b>when</b> Constraint_Error => --Reported (no when others)
<b>raise</b>;
<b>end</b>;
<b>exception</b>
<b>when</b> Constraint_Error => --Reported (trivial when others)
<b>raise</b>;
<b>when</b> <b>others</b> => --Reported
<b>raise</b>;
<b>end</b>;
<b>exception</b>
<b>when</b> Constraint_Error => --Not reported (non trivial when others)
<b>raise</b>;
<b>when</b> <b>others</b> =>
Put_Line ("Error");
<b>end</b>;
</pre></div>
</li><li> <code>if</code> controls <code><b>if</b></code> statements with an <code><b>else</b></code>
path that contains only <code><b>null</b></code> statements (and can thus be
removed).
</li><li> <code>if_for_case</code> controls usage of <code><b>if</b></code> statements that
could be replaced by <code><b>case</b></code> statements. An <code><b>if</b></code>
statement is assumed to be replaceable if it has at least one
<code><b>elsif</b></code> and all conditions are comparisons (or membership
tests, possibly connected by logical operators) of the same discrete
variable with static values. Typically, this subrule will spot
constructs like:
<div class="example">
<pre class="example"> <b>if</b> X = 1 <b>then</b>
...
<b>elsif</b> X = 2 or X = 3 or X = 4 <b>then</b>
...
<b>elsif</b> X >= 5 and X <= 10 <b>then</b>
...
<b>elsif</b> X in 11 .. 20 <b>then</b>
...
<b>else</b>
...
<b>end</b> <b>if</b>;
</pre></div>
</li><li> <code>if_not</code> controls <code><b>if</b></code> statements with an
<code><b>else</b></code> path and no <code><b>elsif</b></code> path, and where the
condition is given in negative form (i.e. it is a <code><b>not</b></code>, or a
<code>"/="</code> comparison). Such statements could be made positive (and
thus less error-prone) by interverting the <code><b>if</b></code> and
<code><b>else</b></code> paths.
</li><li> <code>loop</code> controls <code>while</code> loop statements where the condition
is statically known to be <code>True</code>, and can thus be changed to simple loops.
</li><li> <code>loop_for_while</code> controls simple loop statements whose first
statement is an <code><b>exit</b></code> (for the same loop), and which can
therefore be turned into a <code>while</code> loop.
</li><li> <code>nested_path</code> controls paths from <code><b>if</b></code> statements that
can be moved outside. This happens if the <code><b>if</b></code> has only
<code><b>then</b></code> and <code><b>else</b></code> paths, and either of them ends
with a “breaking” statement (<code><b>raise</b></code>, <code><b>return</b></code>,
<code><b>exit</b></code> or <code><b>goto</b></code>); in this case, the other path
needs not be nested inside the <code><b>if</b></code> statement. However, if
both paths end with the <i>same</i> “breaking” statement, no error is
reported. In short, the rule signals the following examples:
<div class="example">
<pre class="example"><b>if</b> Cond <b>then</b>
<b>return</b>;
<b>else</b>
I := 1;
<b>end</b> <b>if</b>;
<b>if</b> Cond <b>then</b>
I := 1;
<b>else</b>
<b>return</b>;
<b>end</b> <b>if</b>;
</pre></div>
<p>because they can be changed to:
</p><div class="example">
<pre class="example"><b>if</b> Cond <b>then</b>
<b>return</b>;
<b>end</b> <b>if</b>;
I := 1;
<b>if</b> <b>not</b> Cond <b>then</b>
<b>return</b>;
<b>end</b> <b>if</b>;
I := 1;
</pre></div>
<p>The rule will not signal the following example, where both paths end
with the same “breaking” statement (<code><b>return</b></code>), because it
would break the symetry of the statement:
</p><div class="example">
<pre class="example"><b>if</b> Cond <b>then</b>
<b>return</b> 1;
<b>else</b>
<b>return</b> 2;
<b>end</b> <b>if</b>;
</pre></div>
</li><li> <code>null</code> controls <code><b>null</b></code> statements that serve no purpose
and can be removed. Note that if a <code><b>null</b></code> statement carries
a label, it is not considered simplifiable.
</li></ul>
<p>This rule can be given at most once for each subrule.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check simplifiable_statements (block, null);
search simplifiable_statements (if);
</pre></div>
<a name="Fixes-7"></a>
<h4 class="subsection">5.53.3 Fixes</h4>
<p>The following subrules generate fixes:
</p><ul>
<li> “Block”: The unnecessary enclosing block structure is removed.
</li><li> “Dead”: The dead code is removed.
</li><li> “If”: The empty “else” part is removed.
</li><li> “Handler”: The useless handler is removed.
</li><li> “Loop”: the “ <code><b>while</b></code> <cond> <code><b>loop</b></code>” is changed to a
plain <code><b>loop</b></code>
</li><li> “Null”: The useless <code><b>null</b></code> statement is removed.
</li></ul>
<a name="Tips-33"></a>
<h4 class="subsection">5.53.4 Tips</h4>
<p>The “dead” subrule does not signal a <code><b>when</b> <b>others</b></code> branch
of a <code><b>case</b></code> statement
that covers no value at all; this can be checked with:
</p><div class="example">
<pre class="example">check case_statement (others_span, min 1);
</pre></div>
<p><code><b>loop</b></code> may seem a strange thing to check, since no Ada
programmer is supposed to write this. However, experience shows that
it is a good indicator of code written by people who did not get
proper Ada training. Such code is certainly worth a peer review...
</p>
<hr>
<a name="Statements"></a>
<div class="header">
<p>
Next: <a href="#Style" accesskey="n" rel="next">Style</a>, Previous: <a href="#Simplifiable_005fStatements" accesskey="p" rel="prev">Simplifiable_Statements</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Statements-1"></a>
<h3 class="section">5.54 Statements</h3>
<p>This rule controls usage of certain Ada statements.
</p>
<a name="Syntax-53"></a>
<h4 class="subsection">5.54.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> statements (<subrule> {, <subrule>};
<subrule> ::=
any_statement | abort |
accept | accept_return |
assignment | asynchronous_select |
block | case |
case_others | case_others_null |
code | conditional_entry_call |
declare_block | delay |
delay_until | dispatching_call |
dynamic_procedure_call | effective_declare_block |
entry_call | entry_return |
exception_others | exception_others_null |
exit | exit_expanded_name |
exit_for_loop | exit_outer_loop |
exit_plain_loop | exit_while_loop |
exited_extended_return | extended_return |
for_in_loop | for_iterator_loop |
for_of_loop | function_return |
goto | if |
if_elsif | inherited_procedure_call |
labelled | loop_return |
multiple_exits | named_exit |
no_else | null |
procedure_call | procedure_return |
raise | raise_locally_handled |
raise_nonpublic | raise_standard |
redispatching_call | reraise |
requeue | selective_accept |
simple_block | simple_loop |
terminate | timed_entry_call |
unconditional_exit | unnamed_block |
unnamed_exit | unnamed_loop_exited |
unnamed_for_loop | unnamed_multiple_loop |
unnamed_simple_block | unnamed_simple_loop |
unnamed_while_loop | untyped_for |
untyped_for_in | untyped_for_of |
while_loop
</pre></div>
<a name="Action-53"></a>
<h4 class="subsection">5.54.2 Action</h4>
<p>Subrules that are Ada keywords control the corresponding Ada
statements. The meaning of other subrules is as follows:
</p><ul>
<li> <code>any_statement</code> controls all statements. This is of course not
intended to forbid all statements in a program (!), but
<em>counting</em> all statements can be quite useful.
</li><li> <code>accept_return</code> controls return statements that return from an
<code><b>accept</b></code> statement, <code>entry_return</code> controls return
statements that return from a (protected) entry body, and
<code>procedure_return</code> controls return statements that return from a
procedure. <code>loop_return</code> controls return statements (including
extended return statements) that appear inside a <code><b>loop</b></code>
statement.
</li><li> <code>assignment</code> controls all assignment statements.
</li><li> <code>asynchronous_select</code> controls the <code><b>select</b></code>
... <code><b>then abort</b></code> statement. <code>conditional_entry_call</code>
controls the <code><b>select</b></code> ... <code><b>else</b></code>
statement. <code>timed_entry_call</code> controls the <code><b>select</b></code>
... <code><b>or delay</b></code> statement. <code>selective_accept</code> controls
the regular <code><b>select</b></code> statement.
</li><li> <code>block</code> controls all block statements, while <code>unnamed_block</code>
controls blocks without a name, <code>declare_block</code> controls blocks
with an explicit <code><b>declare</b></code> (even if the declarative part is
empty), and <code>effective_declare_block</code> controls blocks with a
declarative part that includes anything else than <code><b>use</b></code>
clauses and pragmas. <code>simple_block</code> controls block statements
that have no declarative part (or an empty declarative part) and no
exception handlers, and <code>unnamed_simple_block</code> does the same,
but only for blocks without a name.
</li><li> <code>case</code> controls all <code>case</code> statements.
</li><li> <code>case_others</code> controls any <code><b>when others</b></code> path in a
<code><b>case</b></code> statement, while <code>case_others_null</code> controls only
<code><b>when others</b></code> paths in a <code><b>case</b></code> statement that
contain only <code><b>null</b></code> statements.
</li><li> <code>code</code> controls code statements.
</li><li> <code>delay</code> controls only relative <code><b>delay</b></code> statements, while
<code>delay_until</code> controls absolute <code><b>delay until</b></code>
statements.
</li><li> <code>entry_call</code> controls all entry call statements, including those
that are part of a conditional or timed entry call statement.
</li><li> <code>exit</code> controls all exit statements, while <code>exit_for_loop</code>,
<code>exit_while_loop</code>, and <code>exit_plain_loop</code> control
<code><b>exit</b></code> statements that terminate <code><b>for</b></code> loops,
<code><b>while</b></code> loops, and plain (neither <code><b>for</b></code> nor
<code><b>while</b></code>) loops, respectively. <code>unconditional_exit</code>
controls <code><b>exit</b></code> statements without a <code><b>when</b></code>
condition. <code>multiple_exits</code> controls loop that have more than
one <code><b>exit</b></code> statement. <code>unnamed_loop_exited</code> controls
exit statements that terminate an unnamed loop. <code>exit_outer_loop</code>
controls <code><b>exit</b></code> statements that exit from an outer loop
(i.e. not the innermost one). <code>exit_expanded_name</code> controls named
<code><b>exit</b></code> statements where the name is given as an expanded
name.
</li><li> <code>exception_others</code> controls any <code><b>when others</b></code> exception
handler, while <code>exception_others_null</code> controls only
<code><b>when others</b></code> exception handlers that contain only
<code><b>null</b></code> statements.
</li><li> <code>extended_return</code> controls extended return statements (i.e. the
Ada 2005 construct “<code><b>return</b> V : T <b>do</b> ... <b>end</b>
<b>return</b></code>”). <code>exited_extended_return</code> controls extended
return statements that can be left without actually returning due to
an <b>exit</b> or <b>goto</b> statement within their sequence of
statements.
</li><li> <code>for_loop</code> controls all <code><b>for</b></code> loops, while
<code>for_in_loop</code> controls only the traditional form of
<code><b>for</b></code> loop (<code><b>for</b> I <b>in</b> <i>range</i> <b>loop</b></code>),
<code>for_iterator_loop</code> controls the iterator form (<code><b>for</b> I
<b>in</b> <i>Iterator</i> <b>loop</b></code>), and <code>for_of_loop</code> controls the
components form (<code><b>for</b> V <b>of</b> ... <b>loop</b></code>) (the three
latter forms are not available with the old gnat version of
AdaControl).
</li><li> <code>function_return</code> controls return statements (including extended
return statements) from functions. Obviously, return statements cannot
be forbidden in functions; this keyword controls that there is only
one return statement in the body of functions, and at most one return
statement in each exception handler of the exception part of
functions.
</li><li> <code>if</code> controls all <code><b>if</b></code> statements.
</li><li> <code>if_elsif</code> controls <code><b>if</b></code> statements that have at least
one <code><b>elsif</b></code>.
</li><li> <code>labelled</code> controls statements with a label (true statement
labels, not block and loop names).
</li><li> <code>named_exit</code> controls <code><b>exit</b></code> statements with a loop
name.
</li><li> <code>no_else</code> controls <code><b>if</b></code> statements that have no <code><b>else</b></code>
path.
</li><li> <code>null</code> controls all <code><b>null</b></code> statements.
</li><li> <code>procedure_call</code> controls all calls to
procedures. <code>dispatching_call</code> does the same, but only for
dispatching calls, while <code>redispatching_call</code> does the same, but
only for dispatching calls that are (directly or indirectly) inside a
primitive operation of a tagged type. <code>dynamic_procedure_call</code>
does the same, but only for calls through pointers.
<code>inherited_procedure_call</code> controls calls to procedures that have
been inherited by a derived type and not redefined.
</li><li> <code>raise</code> controls all <code><b>raise</b></code> statements.
</li><li> <code>reraise</code> controls <code><b>raise</b></code> statements in exception
handlers that reraise the same exception, and calls to the
<code>Ada.Exceptions.Reraise_Occurrence</code> procedure.
</li><li> <code>raise_standard</code> controls <code><b>raise</b></code> statements that raise
one of the predefined exceptions (those declared in package
<code>Standard</code>). <code>raise_nonpublic</code> controls statements that
raise exceptions that are neither predefined nor defined in the
visible part of a package. <code>raise_foreign</code> controls statements
that raise exceptions that are neither predefined nor declared in the
same program unit (or an ancestor of the unit) as the statement that
raises the exception. <code>raise_locally_handled</code> controls
statements that raise an exception which is handled by a handler in
the same subprogram body as the statement.
<p>Note that for these subrules, the exception can be raised either by a
<code><b>raise</b></code> statement, or by a call to
<code>Ada.Exceptions.Raise_Exception</code> where the raised exception is
statically determinable.
</p></li><li> <code>simple_loop</code> controls simple loops, i.e. those that are neither
<code><b>while</b></code> nor <code><b>for</b></code> loops.
</li><li> <code>unnamed_exit</code> controls <code><b>exit</b></code> statements without a
loop name that exits from a named loop.
</li><li> <code>unnamed_for_loop</code>, <code>unnamed_simple_loop</code>, and
<code>unnamed_while_loop</code> control loops of the given kind that are not
named.
</li><li> <code>unnamed_multiple_loop</code> controls nested loops that are not named
(i.e. under this rule, only loops that contain no inner loop, and are
not nested in another loop, are allowed not to be named). The kind of
loop (plain, <code><b>for</b></code>, <code><b>while</b></code>) is not considered.
</li><li> <code>untyped_for_in</code> controls regular <code><b>for</b> .. <b>in</b></code> loops
that use a range without an explicitely named type (i.e. <code><b>for</b>
I <b>in</b> 1..10 <b>loop</b></code>). Using a <code>'Range</code> attribute is
OK. <code>untyped_for_of</code> controls <code><b>for</b> .. <b>of</b></code> loops that
have no subtype indication. <code>untyped_for</code> controls both. Note
that generalized iterators are <i>not</i> controlled, since the syntax
does not allow the specification of an explicit subtype for them.
</li><li> <code>while_loop</code> controls all <code><b>while</b></code> loops.
</li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">search statements (delay);
check statements (goto, abort);
check statements (case_others_null, exception_others_null);
</pre></div>
<a name="Variable-6"></a>
<h4 class="subsection">5.54.3 Variable</h4>
<p>The rule provides a variable that allows to specify the amount of information
displayed with the “procedure_call” and “entry_call” subrules.
</p>
<table>
<tr><td width="12%"><b>Variable</b></td><td width="18%"><b>Values</b></td><td width="10%"><b>Default</b></td><td width="60%"><b>Effect</b></td></tr>
<tr><td width="12%">Called_Info</td><td width="18%">none<br>compact<br>detailed<br>root_detailed</td><td width="10%">none</td><td width="60%"><dl compact="compact">
<dt>“none”</dt>
<dd><p>No extra information.
</p></dd>
<dt>“compact”</dt>
<dd><p>display the name of the called procedure or entry.
</p></dd>
<dt>“detailed”</dt>
<dd><p>display the name of the called procedure or entry with overloading
information.
</p></dd>
<dt>“root_detailed”</dt>
<dd><p>display the name of the root called procedure or entry (i.e. the
original procedure if the called procedure is a renaming) with overloading
information.
</p></dd>
</dl></td></tr>
</table>
<a name="Tips-34"></a>
<h4 class="subsection">5.54.4 Tips</h4>
<p>It may seem strange to control things like <code><b>if</b></code> or
<code><b>case</b></code> statements, since no coding standard would prohibit
their use. However, this may be useful, especially with “count”, for
statistical purposes, like measuring the ratio of <code><b>if</b></code> to
<code><b>case</b></code> statements.
</p>
<p>The plain “raise” subrule controls the <code><b>raise</b></code> statement, and
only this one. If you want to check all places where exceptions can be
raised, use also the “entities” rule like this:
</p><div class="example">
<pre class="example">"all raise": check statements (raise),
check entities (Ada.Exceptions.Raise_Exception,
Ada.Exceptions.Reraise_Occurrence);
</pre></div>
<p>Other subrules of the “raise” family are more about which kind of
exception is being raised, and therefore control also exceptions
raised by calling the procedures from <code>Ada.Exceptions</code>.
</p>
<p>“inherited_procedure_call” controls only <i>procedure</i> calls. For
function calls, see rule <a href="#Expressions">Expressions</a>.
</p>
<hr>
<a name="Style"></a>
<div class="header">
<p>
Next: <a href="#Terminating_005fTasks" accesskey="n" rel="next">Terminating_Tasks</a>, Previous: <a href="#Statements" accesskey="p" rel="prev">Statements</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Style-1"></a>
<h3 class="section">5.55 Style</h3>
<p>This rules controls usage of various “general” Ada coding style.
</p>
<a name="Syntax-54"></a>
<h4 class="subsection">5.55.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> style;
<control_kind> style (casing_aspect, <casing_kw> {,<casing_kw>});
<control_kind> style (casing_attribute, <casing_kw> {,<casing_kw>});
<control_kind> style (casing_exponent, <casing_kw> {,<casing_kw>});
<control_kind> style (casing_identifier, <casing_kw> {,<casing_kw>});
<control_kind> style (casing_keyword, <casing_kw> {,<casing_kw>});
<control_kind> style (casing_number, <casing_kw> {,<casing_kw>});
<control_kind> style (casing_pragma, <casing_kw> {,<casing_kw>});
<control_kind> style (compound_statement);
<control_kind> style (default_in);
<control_kind> style (exposed_literal, <type_kw>, {, <value_place>});
<control_kind> style (formal_parameter_order {, <mode list>});
<control_kind> style (multiple_elements {,<element_kw>});
<control_kind> style (negative_condition);
<control_kind> style (no_closing_name [, <max_lines>]);
<control_kind> style (numeric_literal, [not] <base> [, <block_size>]);
<control_kind> style (parameter_order {, <mode list>});
<control_kind> style (renamed_entity);
<casing_kw> ::= uppercase | lowercase | titlecase | original
<element_kw> ::= [flexible] clause | pragma |declaration | statement |
handler | begin | end | then | when |
else | is | loop | do | keywords
<mode_list> ::= <mode> {| <mode>}
<mode> ::= in | defaulted_in | access | in_out | out |
type | procedure | function | package
<type_kw> ::= integer | real | character | string
<value_place> ::= <value> | <place>
<value> ::= [max] <integer number> | <real number> | "<pattern>"
<place> ::= declaration | statement |
aggr_index | attr_index | constant | exponent |
index | number | pragma | repr_clause |
var_init | type
</pre></div>
<a name="Action-54"></a>
<h4 class="subsection">5.55.2 Action</h4>
<p>The first parameter specifies which style aspect is to be checked:
</p>
<ul>
<li> “casing_aspect”, “casing_attribute”, “casing_keyword”,
“casing_identifier”, and “casing_pragma” control that aspect names
(respectively attributes, keywords, identifiers, or pragmas) use the
appropriate casing. “original” (which is allowed only for
identifiers) means that identifiers must use the same casing as in
their declaration.
<p>“casing_exponent” controls the case of the ’E’ in a numeric literal
using exponent notation, and “casing_number” controls the case of
extended digits used in based numbers when the base is above 10 (only
“Lowercase” and “Uppercase” allowed for these).
</p>
<p>If more than one <casing_kw> is given, it means that any of them is
allowed.
</p></li><li> “compound_statement” controls that compound statements span at least
a minimum number of lines: 3 for <code><b>if</b></code> statements,
<code><b>loop</b></code> statements, block statements, and <code><b>accept</b></code>
statements with a body; 4 for <code><b>case</b></code> statements, selective
<code><b>accept</b></code> statements, and timed entry call statements; and 5
for conditional entry call statements and asynchronous select
statements.
</li><li> “default_in” controls subprograms, entries and generics declarations
that omit an explicit <code>in</code> mode for a parameter. Access
parameters are not reported, since an an explicit <code>in</code> is not
allowed in that case.
</li><li> “exposed_literal” controls the usage of literals (aka “magic
values”), that appear outside of allowed places. The second parameter
tells to which kind of literals the rule applies. The (optional)
indicated values that follow are allowed at any place; for integers, a
single value can be preceded by “max”, to indicate that all literals
whose (absolute) value is less or equal are allowed; for strings, the
values are regular expressions. See <a href="#Syntax-of-regular-expressions">Syntax of regular expressions</a>. Commonly allowed values are 0 and 1 for integer
literals, 1.0 and 0.0 for real literals and "^$" (the empty string)
for string literals. At most 20 values of each kind may be
specified.
<p>In addition, one or several <place> keyword can be used to specify
constructs where any literal is allowed: “declaration” stands for
any declaration, “statement” for any statement, “aggr_index” for
index values in a (named) array aggregate, “attr_index” for the
index expression of attributes like <code>'First</code> or <code>'Length</code>,
“constant” for constant declarations, “exponent” for the right
parameter of an exponentiation (i.e. <code>"**"</code>) function call,
“index” for array indexing, “number” for named number
declarations, “pragma” for pragma arguments, “repr_clause” for
representation clauses, “type” for type (and subtype) declarations,
and “var_init” for the initialization expression of variable
declarations. If no <place> is given, it is taken as <code>number,
constant</code>, i.e. any literal is allowed in named numbers and constant
declarations.
</p></li><li> “multiple_elements” controls clauses, pragmas, declarations,
statements, and handlers that do not start on a line of their own
(i.e. when there are more than one of these on the same
line). Similarly, <code><b>begin</b></code>, <code><b>end</b></code>, <code><b>then</b></code>
and <code><b>when</b></code> are required to be on a line of their own,
together with the possible keyword or identifier attached to them and
the semi-colon. In addition, the <code><b>is</b></code>, <code><b>loop</b></code> or
<code><b>do</b></code> that terminates the first part of some declarations or
statements is required to be on the same line as the begining of the
element, or on a line of its own.
<p>Extra parameters specify which kind of element to check; if not
specified, all kind of elements are controlled. “keywords” is a
shorthand for specifying all keywords. If “flexible” is specified in
front of “clause” (not allowed otherwise), it allows a
<code><b>use</b></code> clause to be on the same line as a <code><b>with</b></code>
clause, provided all packages named in the <code><b>use</b></code> clause are
also named in the preceding <code><b>with</b></code> clause.
</p></li><li> “negative_condition” controls “if” statements with an “else”
part and no “elsif”, where the condition starts with a
<code><b>not</b></code>, and should therefore preferably be expressed
positively.
</li><li> “no_closing_name” controls declarations, like package or subprograms,
that allow (but do not require) repeating the name at the end of the
declaration, and where the closing name is omitted (which is
considered bad style in general). However, it can be acceptable to
allow the omission of closing names for very short constructs;
therefore this rule has an optional parameter specifying the maximum
number of lines of a construct for which omitting the closing name is
allowed. This rule can be given only once for each of check, search
and count. This way, it is possible to have a length considered a
warning (search), and one considered an error (check). Of course, this
makes sense only if the length for search is less than the one for
check. If no length is specified, all occurrences of missing closing
names are signaled.
</li><li> “numeric_literal” controls the presentation of numeric literals, depending
on the base (wich, as required by Ada rules, must be in the range
2..16). If “not <base>” is specified as the second parameter, the
given base may not be used for based literals. Otherwise, there must
be a third (integer) parameter to specify the size of blocks of digits
for that base, i.e. there must be an underscore character to separate
digits every <block_size> position. Typically, <block_size> is 3 for
base 10, 4 for base 2, etc.
</li><li> “parameter_order” and “formal_parameter_order” control the order
of the declarations of parameters or generic formal parameters,
respectively. Each parameter of the rule consists in one or several of
the “mode” keywords, and describes, in order, which kind of
parameter is allowed. All modes not specified explicitely are allowed
after the ones that are specified. See examples below.
<p>If no parameter is given, the order for regular parameters is “in”
or “access” first, then “in_out”, then “out”, then
“defaulted_in”. The order for formal_parameters is “type” first,
then “in” “defaulted_in” and “access”, then “in_out”, then
“procedure” and “function”, then “package”.
</p></li><li> “renamed_entity” controls occurrences of identifiers within the scope
of a renaming declaration for them; i.e. it enforces that when an entity
has been renamed, the original name should not be used anymore.
</li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">search style (no_closing_name);
search style (no_closing_name, 5);
check style (casing_identifier, original);
check style (default_in);
check style (numeric_literal, 10, 3);
check style (exposed_literal, integer, 0, 1);
check style (exposed_literal, real, 0.0, 1.0);
-- in parameters (with or without default) and access
-- parameters must be first, then in out parameters, then
-- out parameters. In parameters are allowed last if they
-- have defaults.
check style (parameter_order,
in | defaulted_in | access,
in_out,
out
defaulted_in);
-- For generics, formal objects must come first, then formal
-- types, then formal subprograms, then formal package:
check style (formal_parameter_order,
in | in_out,
type,
procedure | function,
package);
</pre></div>
<p>Without parameter, the rule will control all style aspects with
parameter values that correspond to the most commonly used cases,
i.e. it is equivalent to the following:
</p><div class="example">
<pre class="example">style (no_closing_name);
style (casing_aspect, titlecase);
style (casing_attribute, titlecase);
style (casing_exponent, uppercase);
style (casing_identifier, original);
style (casing_keyword, lowercase);
style (casing_number, uppercase);
style (casing_pragma, titlecase);
style (default_in);
style (negative_condition)
style (multiple_elements)
style (literal, 10, 3);
style (exposed_literal, integer, 0, 1)
style (exposed_literal, real, 0.0, 1.0);
</pre></div>
<a name="Fixes-8"></a>
<h4 class="subsection">5.55.3 Fixes</h4>
<p>The following subrules generate fixes:
</p><ul>
<li> “Casing_Aspect”: The casing of the aspect name is adjusted.
</li><li> “Casing_Attribute”: The casing of the attribute is adjusted.
</li><li> ”Casing_Exponent”: The casing of the exponent is adjusted.
</li><li> “Casing_Identifier”: The casing of the identifier is adjusted.
</li><li> “Casing_Keyword”: The casing of the keyword is adjusted.
</li><li> “Casing_Number”: The casing of letters in the based number is adjusted.
</li><li> “Casing_Pragma”: The casing of the pragma name is adjusted.
</li><li> “Default_In”: The missing “<code><b>in</b></code>” is added.
</li><li> “Multiple_Elements”: Line breaks are inserted before the second
element on the same line.
</li><li> “No_Closing_Name”: The name of the construct is added after “<code><b>end</b></code>”.
</li><li> “Renamed_Entity”: The original name is replaced by the renaming name.
</li></ul>
<a name="Tips-35"></a>
<h4 class="subsection">5.55.4 Tips</h4>
<p>For the “Casing_Identifier” subrule, if the value is “original”,
subprogram and parameter names from the body are checked against those
from the specification (if any). This is what the user would expect,
although strictly speaking it is not a usage of the name.
</p>
<p>Note that operators always follow the casing rule for keywords, even
for calls that use the infix notation (i.e. in <code>"and"(A, B)</code>).
</p>
<p>Having more than one allowed casing is useful if for example you want
to require Titlecase, but accept that the original casing be used
(maybe because your editor or pretty-printer forces it).
</p>
<p>For the “Exposed_Literal” subrule, negative values can be specified as
being allowed; negative numbers are handled as if they were
literals. This is what the casual user would expect, but to the
language lawyer, “-1” is not a negative literal, it is a unary minus
operator applied to the positive value “1”.
</p>
<p>“compound_statement” was a simplistic way of finding badly laid-out
statements, at a time when “multiple_elements” did not control the
end or intermediate parts of declarations and statements. It is of
little use now that “multiple_elements” has been enhanced.
</p>
<a name="Limitations-17"></a>
<h4 class="subsection">5.55.5 Limitations</h4>
<p>If a predefined operator or an attribute is renamed, the
“renamed_entity” subrule cannot check that the original entity is not
used in the scope of the renaming. Such cases are
detected by the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Terminating_005fTasks"></a>
<div class="header">
<p>
Next: <a href="#Type_005fInitial_005fValues" accesskey="n" rel="next">Type_Initial_Values</a>, Previous: <a href="#Style" accesskey="p" rel="prev">Style</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Terminating_005fTasks-1"></a>
<h3 class="section">5.56 Terminating_Tasks</h3>
<p>This rule controls tasks that can terminate.
</p>
<a name="Syntax-55"></a>
<h4 class="subsection">5.56.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> terminating_tasks
</pre></div>
<a name="Action-55"></a>
<h4 class="subsection">5.56.2 Action</h4>
<p>A task is considered a terminating task if its last statement is not
an unconditional loop, or this if this loop is exited. It is also
considered terminating if it contains a selective accept with a
<code><b>terminate</b></code> alternative.
</p>
<p>Since this rule has no parameters, it can be given only once.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check terminating_tasks;
</pre></div>
<a name="Tips-36"></a>
<h4 class="subsection">5.56.3 Tips</h4>
<p>There is still one case where a task terminates, which is not reported
by this rule: when a task is aborted. This is intended, since there
are cases (like mode changes) where a logically non-terminating task
is aborted.
</p>
<p>If aborts are also to be reported, use the rule “statements
(abort)”. See <a href="#Statements">Statements</a>.
</p>
<hr>
<a name="Type_005fInitial_005fValues"></a>
<div class="header">
<p>
Next: <a href="#Type_005fUsage" accesskey="n" rel="next">Type_Usage</a>, Previous: <a href="#Terminating_005fTasks" accesskey="p" rel="prev">Terminating_Tasks</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Type_005fInitial_005fValues-1"></a>
<h3 class="section">5.57 Type_Initial_Values</h3>
<p>This rule controls that a special constant is declared together with
each type, for example to serve as a default initial value.
</p>
<a name="Syntax-56"></a>
<h4 class="subsection">5.57.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> type_initial_values [("<pattern>")];
</pre></div>
<a name="Action-56"></a>
<h4 class="subsection">5.57.2 Action</h4>
<p>This rule controls types that do not feature an initialization
constant declared in the same declarative part as the type. If no
<pattern> is given, any constant is considered an initialization
constant for its type; otherwise, only constants whose name matches
the given pattern are considered initialization constants.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check type_initial_values ("^C_Init_");
</pre></div>
<p>The above example will ensure that every declared type features a
constant of the type whose name starts with “C_Init_”.
</p>
<hr>
<a name="Type_005fUsage"></a>
<div class="header">
<p>
Next: <a href="#Uncheckable" accesskey="n" rel="next">Uncheckable</a>, Previous: <a href="#Type_005fInitial_005fValues" accesskey="p" rel="prev">Type_Initial_Values</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Type_005fUsage-1"></a>
<h3 class="section">5.58 Type_Usage</h3>
<p>This rule controls usage of indicated types, either individually
or by category.
</p>
<a name="Syntax-57"></a>
<h4 class="subsection">5.58.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> type_usage (<attribute>, <category> {, <aspect>}]);
<control_kind> type_usage (index, <entity>|<category> {, <aspect>}]);
<category> ::= () | access | array | delta | digits |
mod | protected | range | record | tagged | task
<aspect> ::= [not] representation | pack | size | component_size
</pre></div>
<a name="Action-57"></a>
<h4 class="subsection">5.58.2 Action</h4>
<p>If the first parameter is an attribute (a name starting with a simple
quote), the rule controls all occurrences of the attribute where the
prefix designates a type belonging to the <category> given as second
parameter.
</p>
<p>If the first parameter is “index”, the rule controls all array types
that have an index of the type given by <entity>, or belonging to the
<category> given as second parameter. As usual, the whole syntax for
entities is allowed for <entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</p>
<p>For both subrules, if one or several <aspect> are given, only types
featuring (or not featuring if “not” is given) the provided aspects
are controlled.
</p>
<p>The meaning of <category> is:
</p><ul>
<li> “()”: The type is an enumerated type.
</li><li> “access”: The type is an access type.
</li><li> “array”: The type is an array type.
</li><li> “delta”: The type is a fixed point type (it is not currently
possible to distinguish ordinary fixed point types from decimal fixed
point types).
</li><li> “digits”: The type is a floating point type.
</li><li> “mod”: The type is a modular type.
</li><li> “protected”: The type is a protected type.
</li><li> “range”: The type is a signed integer type.
</li><li> “record”: The type is an (untagged) record type.
</li><li> “tagged”: The type is a tagged type (including type
extensions).
</li><li> “task”: The type is a task type.
</li></ul>
<p>The meaning of <aspect> is:
</p><ul>
<li> “representation”: the type has an enumeration representation clause
or a record representation clause.
</li><li> “pack”: the type is the target of a pack <code><b>pragma</b></code>.
</li><li> “size” and “component_size”: the type has the corresponding
attribute specified.
</li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">-- Don't use 'Pos attribute on enumerated types with a representation
check type_usage ('Pos, (), representation);
-- Don't use modular type for array indexes
check type_usage (index, mod);
</pre></div>
<a name="Tips-37"></a>
<h4 class="subsection">5.58.3 Tips</h4>
<p>The subrule “index” controls the use of a type as an index at any
position and irrespectively of the number of indices of the array. To
control a precise pattern of types used as indices, use the rule
“array_declarations”. See <a href="#Array_005fDeclarations">Array_Declarations</a>.
</p>
<p>The subrule that uses attribute names does not allow an <entity>. To
control occurrences of an attribute on a precise type, use the rule
“entities”. See <a href="#Entities">Entities</a>.
</p>
<hr>
<a name="Uncheckable"></a>
<div class="header">
<p>
Next: <a href="#Unit_005fPattern" accesskey="n" rel="next">Unit_Pattern</a>, Previous: <a href="#Type_005fUsage" accesskey="p" rel="prev">Type_Usage</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Uncheckable-1"></a>
<h3 class="section">5.59 Uncheckable</h3>
<p>This rules controls cases where it is not possible to guarantee the
accuracy of checks performed by AdaControl, and where manual
inspection may be required.
</p>
<a name="Syntax-58"></a>
<h4 class="subsection">5.59.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> uncheckable [(<subrule> [,<subrule>])];
<subrule> ::= false_positive | false_negative | missing_unit
</pre></div>
<a name="Action-58"></a>
<h4 class="subsection">5.59.2 Action</h4>
<p>If the keyword “missing_unit” is given, this rule controls missing
units, i.e. units given on the command line that are not found (and
therefore not controlled) will result in an usual error message.
</p>
<p>Otherwise, this rule controls constructs that are not static
and prevent other rules from being fully reliable. This rule is
special, since it really affects the way other rules behave when they
encounter a statically uncheckable construct. Therefore, if a label is
given, the message will include the label as usual, with an indication
of the rule that triggered the message; if no label is given, the
message will include the name of the rule that detected the
uncheckable construct, not “uncheckable” itself.
</p>
<p>If the keyword “false_negative” is given, the rule will control
constructs that could result in false negatives, i.e. possible
violations that would go undected, while if the keyword
“false_positive” is given, it will control constructs that could
result in false positives, i.e. error messages when the rule is not
really violated. If no keyword is given, both occurrences are
controlled.
</p>
<p>As far as statistics are concerned (see <a href="#Control-kinds-and-report-messages">Control kinds and report messages</a>), “uncheckable” messages from rules are counted under the
corresponding rule’s statistics (like other messages), but there will
be also a count of all “uncheckable” messages under the rule
“UNCHECKABLE”, and also subtotals corresponding to the number of
“uncheckables” for each rule.
</p>
<p>This rule can be given only once for each of value of the parameters.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check uncheckable (false_negative);
search uncheckable (false_positive);
check uncheckable (missing_unit);
</pre></div>
<a name="Tips-38"></a>
<h4 class="subsection">5.59.3 Tips</h4>
<p>This rule is especially important when AdaControl is used in safety
critical software, since it will detect constructs that could escape
verification. Such constructs should be either disallowed, or require
manual inspection. On the other hand, in casual software, it may lead
to many messages, since for example dispatching calls are uncheckable
with many rules.
</p>
<a name="Limitation-14"></a>
<h4 class="subsection">5.59.4 Limitation</h4>
<p>With “missing_unit”, the message does not include a reference to a
source location, since there is no place in the source which can be
considered as the origin of the error. If you run AdaControl from
GPS, there will always be a separate category (“Uncheckable”) in the
locations window, under which the message will appear, with a file
name of “none”. Don’t try to click on the error message, since GPS
will find no file named “none”!
</p>
<hr>
<a name="Unit_005fPattern"></a>
<div class="header">
<p>
Next: <a href="#Units" accesskey="n" rel="next">Units</a>, Previous: <a href="#Uncheckable" accesskey="p" rel="prev">Uncheckable</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Unit_005fPattern-1"></a>
<h3 class="section">5.60 Unit_Pattern</h3>
<p>This rule controls various usage patterns of program units and
elements declared in them.
</p>
<a name="Syntax-59"></a>
<h4 class="subsection">5.60.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> unit_pattern (Single_Tagged_Type);
<control_kind> unit_pattern (Tagged_Type_Hierarchy);
<control_kind> unit_pattern (Context_Clauses_Order {, <clause_list>});
<control_kind> unit_pattern (Declarations_Order, <target>,
{, <decl_list>});
<clause_list> ::= <clause> {| <clause>}
<clause> ::= with | use | use_type | use_all_type | pragma
<target> ::= package_public | package_private | package_body |
subprogram
<decl_list> ::= <declaration> {| <declaration>}
<declaration> ::= use | use_type |
use_all_type | number |
constant | variable |
private_type | full_type |
subtype | subprogram_spec |
package_spec | generic_subprogram_spec |
generic_package_spec | task_spec |
protected_spec | subprogram_body |
package_body | generic_subprogram_body |
generic_package_body | task_body |
protected_body | object_renaming |
subprogram_renaming | package_renaming |
exception_renaming | subprogram_instantiation |
package_instantiation | exception |
others
</pre></div>
<a name="Action-59"></a>
<h4 class="subsection">5.60.2 Action</h4>
<p>The checked pattern depends on the given subrule:
</p><ul>
<li> “single_tagged_type” controls that at most one tagged type is
declared in any package.
</li><li> “tagged_type_hierarchy” controls that tagged types follow packages
hierarchy, i.e. that the parent of a type extension (derivation of a tagged
type) is declared in the parent unit of the one that declared the
derivation.
</li><li> “context_clauses_order” controls the order of context clauses (and
pragmas) given on top of the unit. Each parameter of the rule consists
in one or several of the <clause> keywords, and describes, in order,
which kind of clause is allowed. Note that “use_type” covers only
the regular <code><b>use type</b></code> clause, specify also “use_all_type”
to include the Ada 2012 <code><b>use all type</b></code> clause as well. Note
that all <clause>s not specified explicitely have no place, and thus
are not allowed at all.
</li><li> “declarations_order” controls the order of declarations (and use clauses)
given in various parts, depending on the second parameter:
<ul>
<li> “package_public” controls elements in the visible part of a package specification;
</li><li> “package_private” controls elements in the private part of a package
specification;
</li><li> “package_body” controls elements in the body of a package;
</li><li> “subprogram” controls elements in the body of subprograms
(procedures and functions) and entries.
</li></ul>
<p>Each parameter of the rule consists in one or several of the
<declaration> keywords, and describes, in order, which kind of
declaration is allowed. Note that all <declaration>s not specified
explicitely have no place, and thus are not allowed at all, unless
“others” is given as the last parameter, in which case it covers all
elements not part of any of the preceding parameters. See example
below.
</p></li></ul>
<p>Ex:
</p><div class="example">
<pre class="example">check unit_pattern (single_tagged_type);
check unit_pattern (tagged_type_hierarchy);
-- All with clauses must come first, then use and use type clauses
-- (freely mixed), then pragmas
check unit_pattern (context_clauses_order,
with,
use | use_type | use_all_type,
pragma);
-- In the public part of a package, declare constants and named numbers
-- first,then private types, then any of regular types, constants, and
-- variables, then subprograms specifications (including generics and
-- instantiations), then anything else:
check unit_pattern (declarations_order, package_public,
number | constant,
private_type,
full_type | constant | variable,
subprogram_spec | generic_subprogram_spec | subprogram_instantiation,
others);
</pre></div>
<a name="Tips-39"></a>
<h4 class="subsection">5.60.3 Tips</h4>
<p>For “context_clauses_order” and “declarations_order”, elements
given as part of the same parameter (i.e. with a vertical bar between
them) can be freely mixed, then followed by any of the elements of the
next parameter, etc. An element may appear several times in different
parameters. If the last parameter is “others”, any element not
mentionned at all is allowed after the ones for which you specify an
order; this way, it is possible to specify an order for just some
elements, and then don’t care for the rest.
</p>
<p>Expression functions and null procedures are classified as
“subprogram_spec” unless they are the completion of an explicit
specification, in which case they are classified as
“subprogram_body”.
</p>
<p>If you don’t want a declaration to appear at all, you can also use the
rule “declarations”. See <a href="#Declarations">Declarations</a>.
</p>
<hr>
<a name="Units"></a>
<div class="header">
<p>
Next: <a href="#Unnecessary_005fUse_005fClause" accesskey="n" rel="next">Unnecessary_Use_Clause</a>, Previous: <a href="#Unit_005fPattern" accesskey="p" rel="prev">Unit_Pattern</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Units-1"></a>
<h3 class="section">5.61 Units</h3>
<p>This rule controls that all necessary units, and only those, are
processed by AdaControl.
</p>
<a name="Syntax-60"></a>
<h4 class="subsection">5.61.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> units [(<subrule> [,<subrule>])];
<subrule> ::= unreferenced | unchecked
</pre></div>
<a name="Action-60"></a>
<h4 class="subsection">5.61.2 Action</h4>
<p>If the keyword <code>unreferenced</code> is given, the rule controls
compilation units that are part of the set of analyzed units, but
withed by no other unit. If the keyword <code>unchecked</code> is given, the
rule controls compilation units that are withed by other unit(s), but
not part of the set of controlled units (except standard units).
</p>
<p>This rule can only be given once for each of the subrules.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check units (unchecked);
search units (unreferenced);
</pre></div>
<a name="Tip-5"></a>
<h4 class="subsection">5.61.3 Tip</h4>
<p>The main program will appear as unreferenced, since it is normally part of
the controlled units, and not withed by any other unit. As usual, the corresponding
message can be disabled by putting the comment:
</p><div class="example">
<pre class="example">--## rule line off units
</pre></div>
<p>on the main program.
</p>
<hr>
<a name="Unnecessary_005fUse_005fClause"></a>
<div class="header">
<p>
Next: <a href="#Unsafe_005fElaboration" accesskey="n" rel="next">Unsafe_Elaboration</a>, Previous: <a href="#Units" accesskey="p" rel="prev">Units</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Unnecessary_005fUse_005fClause-1"></a>
<h3 class="section">5.62 Unnecessary_Use_Clause</h3>
<p>This rule controls <code><b>use</b></code> clauses that do not serve any
purpose.
</p>
<a name="Syntax-61"></a>
<h4 class="subsection">5.62.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> unnecessary_use_clause [(<subrule> {,<subrule>})];
<subrule> ::= unused | qualified | operator | nested | movable
</pre></div>
<a name="Action-61"></a>
<h4 class="subsection">5.62.2 Action</h4>
<p>The rule controls <code><b>use</b></code> clauses that can safely be removed,
moved, or changed to a <code><b>use type</b></code> clause. This happens in the
following cases:
</p><ul>
<li> “unused”: a <code><b>use</b></code> clause is given, but no element from the
corresponding package is mentionned in its scope. The message starts
with “unused:”.
<p>In this case, the <code><b>use</b></code> clause can safely be removed.
</p></li><li> “qualified”: a <code><b>use</b></code> clause is given, but all elements from the
corresponding package are refered to using a qualified name
(i.e. prefixed by the name of the package). The message starts with
“all uses qualified:”.
<p>In this case, the <code><b>use</b></code> clause can safely be removed, but you
may want to keep it for documentation purposes, since the package is
actually used within this scope.
</p></li><li> “operator”: a <code><b>use</b></code> clause is given, but the only elements
that do not use a qualified name are operators. The message starts
with “only used for operators:”.
<p>In this case, and except for some pathological cases (definition of
operators that are not primitive operations of the corresponding
type), the <code><b>use</b></code> clause can be replaced by one or several
<code><b>use type</b></code> clause(s).
</p></li><li> “nested”: a <code><b>use</b></code> clause is given within the scope of an
enclosing <code><b>use</b></code> clause for the same package, or in a child
unit for some ancestor. The message tells the location of the other
<code><b>use</b></code> clause or the ancestor.
<p>If you also have a message that the outer <code><b>use</b></code> clause is
unnecessary, this means that all references to the package appear
inside the inner <code><b>use</b></code> clauses, and that the outer one can be
removed. If not, you can either remove the inner <code><b>use</b></code>
clauses, or remove the outer one and add more local <code><b>use</b></code>
clauses where necessary.
</p></li><li> “movable”: a <code><b>use</b></code> clause is given in a package
specification, but all uses are from the corresponding body. The
message starts with “use clause can be moved to body:”.
<p>In this case, the <code><b>use</b></code> clause can safely be moved to the
body, unless it appears in a library package, and there are
unqualified references to its elements from child units.
</p></li></ul>
<p>If no parameter is given, all cases are controlled, otherwise only
cases corresponding to the specified keyword(s) are controlled. This
rule can be given only once for each value of the parameters.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">remove: search unnecessary_use_clause (unused);
use_type: check unnecessary_use_clause (operator);
</pre></div>
<a name="Tip-6"></a>
<h4 class="subsection">5.62.3 Tip</h4>
<p>This rule checks only usage of <code><b>use</b></code> clauses. The rule
“reduceable_scope” can be used to check that <code><b>use</b></code> clauses
do not span unnecessarily to wide a scope. See <a href="#Reduceable_005fScope">Reduceable_Scope</a>.
</p>
<a name="Limitations-18"></a>
<h4 class="subsection">5.62.4 Limitations</h4>
<p>There are some rare cases where the rule may signal that a
<code><b>use</b></code> clause is not necessary, where it actually is. There is
no risk associated to this since if you remove the <code><b>use</b></code>
clause, the program will not compile.
</p>
<p>The first one comes from a limitation of the ASIS standard: if the
<i>only</i> use of the <code><b>use</b></code> clause is for making the “root”
definition of a dispatching call visible.
</p>
<p>The second one comes from a limitation in ASIS-for-Gnat. This happens
when the <i>only</i> use of the <code><b>use</b></code> clause is for making an
implicitely declared operation (an operation which is declared by the
compiler as part of a type derivation) visible, and when:
</p><ul>
<li> the operation is the target of a renaming declaration;
</li><li> or the operation is passed as an actual to a generic instantiation;
</li><li> or all operands of the operation are universal (i.e. untyped).
</li></ul>
<p>Since these problems come from intrinsic limitations of ASIS, there is
nothing we can do about it. When this happens, you can disable the
unnecessary_use_clause rule using the line (or block) disabling
feature. See <a href="#Disabling-controls">Disabling controls</a>. Note that for the third alternative
of the second case, you can also qualify one of the parameters, so it
is not universal any more.
</p>
<hr>
<a name="Unsafe_005fElaboration"></a>
<div class="header">
<p>
Next: <a href="#Unsafe_005fPaired_005fCalls" accesskey="n" rel="next">Unsafe_Paired_Calls</a>, Previous: <a href="#Unnecessary_005fUse_005fClause" accesskey="p" rel="prev">Unnecessary_Use_Clause</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Unsafe_005fElaboration-1"></a>
<h3 class="section">5.63 Unsafe_Elaboration</h3>
<p>This rule controls (generic) packages that may be subject to
elaboration order dependencies.
</p>
<a name="Syntax-62"></a>
<h4 class="subsection">5.63.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> unsafe_elaboration;
</pre></div>
<a name="Action-62"></a>
<h4 class="subsection">5.63.2 Action</h4>
<p>The rule controls library packages (or generic packages) whose
elaboration calls or instantiates elements from other units (except
language defined units) that are not subject to a <code><b>pragma</b></code>
<code>Elaborate</code> or <code>Elaborate_All</code>. The elaboration of such
packages may depend on elaboration order.
</p>
<p>Since this rule has no parameters, it can be given only once.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check unsafe_elaboration;
</pre></div>
<a name="Tips-40"></a>
<h4 class="subsection">5.63.3 Tips</h4>
<p>If the package contains tasks, they are considered as being part of
the elaboration code of the package, since tasks could be started by
the elaboration of the package. This is somehow pessimistic in the
unlikely case where a package would contain a local task type (whose
specification is not part of the package specification) and no task
object of that type is declared. Anyway, this could create only false
positives, therefore there is no risk associated to it.
</p>
<hr>
<a name="Unsafe_005fPaired_005fCalls"></a>
<div class="header">
<p>
Next: <a href="#Unsafe_005fUnchecked_005fConversion" accesskey="n" rel="next">Unsafe_Unchecked_Conversion</a>, Previous: <a href="#Unsafe_005fElaboration" accesskey="p" rel="prev">Unsafe_Elaboration</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Unsafe_005fPaired_005fCalls-1"></a>
<h3 class="section">5.64 Unsafe_Paired_Calls</h3>
<p>This rule controls usage of calls to operations that are normally
paired (like P/V operations) and do not follow a "safe" coding
pattern.
</p>
<a name="Syntax-63"></a>
<h4 class="subsection">5.64.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> unsafe_paired_calls
(<opening procedure>, <closing procedure> [, <lock type>]);
<opening procedure> ::= <entity>
<closing procedure> ::= <entity>
<lock type> ::= <entity>
</pre></div>
<a name="Action-63"></a>
<h4 class="subsection">5.64.2 Action</h4>
<p>The following explanations are given in terms of
“locks” since this is the primary use of this rule, however the rule
can be used for any calls that need to be properly paired.
</p>
<p>The rule can deal with three different kinds of locks:
</p><ul>
<li> <i>abstract state machines</i>: There is no “lock” object, locking is
done directly inside the procedures. The <lock type> parameter of the
rule must not be provided in that case.
</li><li> <i>object abstract data types</i>: The procedure operates on an object
(generally of a private type) representing the “lock” object, passed
as an “in out” parameter. The third parameter must be the
corresponding type, and the rule will control that all matching pairs of
calls refer statically to the same variable.
</li><li> <i>reference abstract data types</i>: The procedure operates on a
reference that designates the “lock” object, passed as an
“in”parameter. The third parameter must be the corresponding type,
which must be discrete or access, and the rule will control that all
matching pairs of calls refer statically to the same value (for
discrete types) or to the same constant (for access types).
</li></ul>
<p>As usual, the whole syntax for entities is allowed for
<entity>. See <a href="#Specifying-an-Ada-entity-name">Specifying an Ada entity name</a>.
</p>
<p>An <i>opening block</i> is either a call to the first procedure given to
the rule, or an if statement whose condition is a simple reference to
a boolean constant (that needs not be static) and whose if path or
else path is itself an opening block, possibly followed by <b>exit</b>,
<b>return</b>, and <b>null</b> statements (and no others).
</p>
<p>Similarly, a <i>closing block</i> is either a call to the second
procedure given to the rule, or an if statement whose condition is a
simple reference to a boolean constant (that needs not be static) and
whose if path or else path is itself a closing block, possibly
followed by <b>exit</b>, <b>return</b>, and <b>null</b> statements (and no
others).
</p>
<p>An opening and a closing block match if:
</p><ul>
<li> corresponding calls to the
procedures of a pair use the appropriate value for the “lock”
parameter (if any), as explained above
</li><li> if statements have their conditions refer to the
same constant, and their if and else paths contain matching blocks.
</li></ul>
<p>The "safe" coding pattern is defined as follows:
</p><ul>
<li> An opening block is the first statement of a
handled sequence of statements;
</li><li> A closing block is the last statement of the same handled sequence of
statements, except for possible <b>exit</b>, <b>return</b>, and <b>null</b>
statements following it.
</li><li> The opening and closing blocks match.
</li><li> There is no other call to either operation in the statements of the
handled sequence of statements, except in nested blocks or accept
statements; calls in such inner statements shall not reference the
same values or variables as outer ones.
</li><li> There is an exception handler for "others" in the
handled sequence of statements.
</li><li> Every exception handler of the handled sequence of statements includes
a single closing block matching the opening block at the top of the
sequence of statements.
</li></ul>
<p>Typically, the “safe” pattern corresponds to the following structures:
</p><div class="example">
<pre class="example">-- Abstract state machine
<b>begin</b>
P;
-- Do something
V;
<b>exception</b>
<b>when</b> <b>others</b> =>
V;
-- handle exception
<b>end</b>;
-- Object abstract data type
<b>declare</b>
My_Lock : Lock_Type;
<b>begin</b>
P (My_Lock);
-- Do something
V (My_Lock);
<b>exception</b>
<b>when</b> <b>others</b> =>
V (My_Lock);
-- handle exception
<b>end</b>;
-- Reference abstract data type
<b>declare</b>
Lock_Ptr : <b>constant</b> Lock_Access := Get_Lock;
<b>begin</b>
P (Lock_Ptr);
-- Do something
V (Lock_Ptr);
<b>exception</b>
<b>when</b> <b>others</b> =>
V (Lock_Ptr);
-- handle exception
<b>end</b>;
-- Conditional blocks
<b>declare</b>
Lockable : <b>constant</b> Boolean := ...;
Lock1 : <b>constant</b> Boolean := ...;
<b>begin</b>
<b>if</b> Lockable <b>then</b>
<b>if</b> Lock1 <b>then</b>
Lock (V1);
<b>else</b>
Lock (V2);
<b>end</b> <b>if</b>;
<b>end</b> <b>if</b>;
-- Do something
<b>if</b> Lockable <b>then</b>
<b>if</b> Lock1 <b>then</b>
Unlock (V1);
<b>return</b>;
<b>else</b>
Unlock (V2);
<b>exit</b>;
<b>end</b> <b>if</b>;
<b>end</b> <b>if</b>;
<b>end</b>;
</pre></div>
<p>Ex:
</p><div class="example">
<pre class="example">check unsafe_paired_calls (Sema.P, Sema.V, Sema.Lock_Access);
</pre></div>
<a name="Variable-7"></a>
<h4 class="subsection">5.64.3 Variable</h4>
<p>The rule provides a variable that allows to control whether opening
and closing blocks can contain <b>if</b> statements, or just calls to the
procedures.
</p>
<table>
<tr><td width="25%"><b>Variable</b></td><td width="10%"><b>Values</b></td><td width="10%"><b>Default</b></td><td width="55%"><b>Effect</b></td></tr>
<tr><td width="25%">Conditionals_Allowed</td><td width="10%">off<br>on</td><td width="10%">on</td><td width="55%"><dl compact="compact">
<dt>off</dt>
<dd><p>only direct calls to the indicated procedures are allowed as opening
and closing blocks
</p></dd>
<dt>on</dt>
<dd><p>calls can be nested in if statements as described above.
</p></dd>
</dl></td></tr>
</table>
<a name="Tips-41"></a>
<h4 class="subsection">5.64.4 Tips</h4>
<p>If the <Lock type> parameter is provided, both procedures must have a
single parameter of the given type, it must not correspond to an
“out” parameter, and if it corresponds to an “in” parameter, the
type must be discrete or access.
</p>
<p>This rule can be specified several times, and it is possible to have
the same procedure belonging to several rules. For example, if you
have a <code>Mask_Interrupt</code> procedure that should be matched by
either <code>Unmask_Interrupt</code> or <code>General_Reset</code> (all declared
in package <code>IT_Driver</code>), you can specify:
</p><div class="example">
<pre class="example">check unsafe_paired_calls (IT_Driver.Mask_Interrupt,
IT_Driver.Unmask_Interrupt);
check unsafe_paired_calls (IT_Driver.Mask_Interrupt,
IT_Driver.General_Reset);
</pre></div>
<p>Normally, the legality of a rule is checked when the command file is
parsed, and execution does not start if there is any error. However,
the legality of the provided type can be checked only during the
analysis. If the type is incorrect for some reason, a proper error
message is issued and execution stops immediately.
</p>
<a name="Limitation-15"></a>
<h4 class="subsection">5.64.5 Limitation</h4>
<p>Due to a weakness of the ASIS standard, dispatching calls are not
considered. Especially, this means that the <Lock type> cannot be
class-wide. Such calls are detected by the rule “uncheckable”.
See <a href="#Uncheckable">Uncheckable</a>.
</p>
<p>Due to a size limitation of internal data structures, this rule can be
specified at most 32 times.
</p>
<hr>
<a name="Unsafe_005fUnchecked_005fConversion"></a>
<div class="header">
<p>
Next: <a href="#Usage" accesskey="n" rel="next">Usage</a>, Previous: <a href="#Unsafe_005fPaired_005fCalls" accesskey="p" rel="prev">Unsafe_Paired_Calls</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Unsafe_005fUnchecked_005fConversion-1"></a>
<h3 class="section">5.65 Unsafe_Unchecked_Conversion</h3>
<p>This rule controls unchecked conversions between types which are not
statically known to have identical sizes.
</p><a name="Syntax-64"></a>
<h4 class="subsection">5.65.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> unsafe_unchecked_conversion
</pre></div>
<a name="Action-64"></a>
<h4 class="subsection">5.65.2 Action</h4>
<p>This rule controls instances of <code>Unchecked_Conversion</code> between
types where the following conditions are not met:
</p><ul>
<li> A size clause has been specified for both types
</li><li> Both sizes are equal
</li></ul>
<p>Moreover, a special message is given if any of the types is a class-wide
type (certainly a very questionable construct!).
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check unsafe_unchecked_conversion
</pre></div>
<a name="Limitation-16"></a>
<h4 class="subsection">5.65.3 Limitation</h4>
<p>There are cases where a size clause is given for a type, but
AdaControl is unable to evaluate it. This happens especially if the
size clause refers to a size attribute of a predefined type, like:
</p><div class="example">
<pre class="example"><b>for</b> T'Size <b>use</b> Integer'size;
</pre></div>
<p>This can lead to false positives (i.e. detection of instantiations of
<code>Unchecked_Conversion</code> that are actually OK). Such cases are
detected by the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Usage"></a>
<div class="header">
<p>
Next: <a href="#Use_005fClauses" accesskey="n" rel="next">Use_Clauses</a>, Previous: <a href="#Unsafe_005fUnchecked_005fConversion" accesskey="p" rel="prev">Unsafe_Unchecked_Conversion</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Usage-1"></a>
<h3 class="section">5.66 Usage</h3>
<p>This rule controls how certain entitities (variables, constants,
types, procedures, functions, exceptions, tasks, protected objects,
and generics) are used.
</p><a name="Syntax-65"></a>
<h4 class="subsection">5.66.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> usage
(variable|object {,[not] <location> | read | written | initialized});
<control_kind> usage
(constant {,[not] <location> | read});
<control_kind> usage
(type {,[not] <location> | used});
<control_kind> usage
(procedure {,[not] <location> | called | accessed});
<control_kind> usage
(function {,[not] <location> | called | accessed});
<control_kind> usage
(exception {,[not] <location> | raised | handled});
<control_kind> usage
(task {,[not] <location> | called | aborted});
<control_kind> usage
(protected {,[not] <location> | called});
<control_kind> usage
(generic {,[not] <location> | instantiated});
<control_kind> usage
(all {,[not] <location>});
<location> ::= from_visible | from_private | from_spec
</pre></div>
<a name="Action-65"></a>
<h4 class="subsection">5.66.2 Action</h4>
<p>The first parameter defines the class of entities to be controlled.
“object” stands for both “constant” and “variable”, “type”
stands for both types and subtypes, and “all” stands for all
classes.
</p>
<p>If only one parameter is given, usage of all entities belonging to the
indicated class are reported . Otherwise, other parameter(s) are
keyword that restrict the kind of usage being controlled.
</p>
<p>“[not] from_visible”, “[not] from_private”, and “[not]
from_spec” restrict entities being checked to those that appear (or
not) in (generic) package specifications, in the visible part, in the
private part, or in any part, respectively. “accessed” (available
for subprograms only) restricts entities being checked to those that
appear as the prefix of a <code>'Access</code> or <code>'Address</code>
attribute. Other keywords carry their obvious meaning, and are allowed
only where appropriate. The rule will output the information only for
objects that match all the conditions given. A combination of
parameters can be given only once for each of “check”, “search”,
and “count”.
</p>
<p>The report includes the kind of unit that declares the entity (normal
unit, instantiation, or generic unit), the part where it is declared
(visible or private) if it is declared in a (generic) package, and
whether the entity is known to be initialized, read, written, raised,
handled, called, or aborted, depending on the entity’s class. Some
combinations give an extra useful message (for example, a variable
which is initialized and read but not written will produce a “could
be declared constant” message).
</p>
<p>Variables of an access type and variables of an array type whose
components are of an access type (or arrays of an access type, etc.)
are always considered initialized, since they are initialized to
<code>null</code> by the compiler.
</p>
<p>Variables that cannot be assigned to (i.e. variables of an array type
with some null dimension, or variables of a discrete type whose range
includes no values) are specially recognized as “pseudo-constants”:
there is no message that they are not written to (since it is not
possible), but there is an indication that they are pseudo-constants.
</p>
<p>The subrules “procedure” and “function” check only regular
subprograms, not protected ones. On the other hand, the subrule
“protected” controls all calls to any protected subprogram or entry.
</p>
<p>Exceptions raised by calling <code>Raise_Exception</code> and tasks aborted by
calling <code>Abort_Task</code> are properly recognized as exceptions being
raised and tasks being aborted, respectively.
</p>
<p>In the case of entities declared in generic packages, the rule will
report on usage of the entities for each instantiation, as well as on
global usage for the generic itself. Usage for an instantiation will
include usage in the generic itself (i.e. if the generic writes to a
variable, the variable will be marked as “written” for each
instantiation). Usage for the generic itself is the union of all
usages in all instantiations (i.e., if a variable from any
instantiation is written to, the variable from the generic will be
marked as written). Therefore, if the rule reports that a variable in
a generic package can be declared constant, it means that no instance
of this variable from any instantiation is being written to. But bear
in mind that this can be trusted only if all units from the program
are analyzed. See <a href="#limitation">limitation</a>.
</p>
<p>Note that usage of entities whose declaration is not processed (like,
typically, elements declared in standard packages like
<code>Ada.Text_IO</code>), is not reported. For the same reason, it is not
possible to control usage of predefined operators (since they have no
declaration).
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- No variable in package spec; check usage otherwise
Package_Variable: check usage (variable, from_spec);
Constantable : search usage (variable, not from_spec, read,
initialized, not written);
Uninitialized : check usage (variable, not from_spec, read,
not initialized, not written);
Removable : search usage (object, not from_spec, not read);
-- Check exceptions that are never raised
-- generics that are never instantiated
-- and protected objects that are never called
check usage (exception, not raised);
check usage (generic, not instantiated);
check usage (protected, not called);
-- Find how many tasks are declared, and report those
-- that may be aborted
count usage (task);
check usage (task, aborted);
</pre></div>
<a name="Tips-42"></a>
<h4 class="subsection">5.66.3 Tips</h4>
<p>Constants that are never used, exceptions that are never raised or
handled, tasks that are never called, etc. are suspicious. Moreover,
some useful compiler warnings (like those about variables that should
be declared constants) are not output for variables declared in
library packages, and even in some other contexts (at least with
GNAT). This rule can check these kind of things, project wide.
</p>
<p>Some of these checks make sense only for entities declared in package
specifications; for example, variables are often discouraged in
package specifications, or need at least some extra control. That’s
why it can be useful to restrict some checks to package specifications.
</p>
<p>Note that an unspecified parameter in a rule stands for two rules
(positive and negative form of the missing parameter). I.e.:
</p><div class="example">
<pre class="example">search usage (variable, from_spec, read, written);
</pre></div>
<p>is the same as:
</p><div class="example">
<pre class="example">search usage (variable, from_spec, read, written, initialized);
search usage (variable, from_spec, read, written, not initialized);
</pre></div>
<p>Therefore, the following example will complain on the second line that
the rule has already been given for this combination of parameters:
</p><div class="example">
<pre class="example">search usage (variable, from_spec, read, written);
search usage (variable, from_spec, read, written, not initialized);
</pre></div>
<p>Note that the notion of constants for this rule includes named numbers.
</p>
<a name="limitation"></a><a name="Limitations-19"></a>
<h4 class="subsection">5.66.4 Limitations</h4>
<p>The report of this rule is output at the end of the run, and is
meaningful only for the units that have been processed; i.e., if it
reports “variable not read”, it should be understood as “not read
by the units given”. In order to have meaningful results, it is
therefore advisable to use this rule on the complete closure of the
program.
</p>
<p>An exception can be raised by passing its <code>'Identity</code> to a
procedure that will in turn call <code>Raise_Exception</code> (and similarly
for <code>Abort_Task</code>). These cases are not statically determinable,
and therefore not recognized by AdaControl. However, these cases can
be identified by searching the use of the <code>'Identity</code> attribute
with the following rule:
</p><div class="example">
<pre class="example">check entity (all 'Identity);
</pre></div>
<p>If an object is the prefix of a <code>'Access</code>,
<code>'Unchecked_Access</code>, or <code>'Address</code> attribute, it can be used
through the access (or address) value in ways that are not statically
analyzable. The same happens if objects are targets of dynamic
renamings. Such cases are detected by the rule
“uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<p>Due to a weakness of the ASIS standard, it is not possible to know the
mode (<b>in</b>, <b>out</b>) of variables used as parameters of dispatching
calls. Such variables are considered to be read and written at the
point of the call, therefore possibly creating false positives (which
is safer than false negatives). Use of such constructs is detected by
the rule “uncheckable”. See <a href="#Uncheckable">Uncheckable</a>.
</p>
<hr>
<a name="Use_005fClauses"></a>
<div class="header">
<p>
Next: <a href="#With_005fClauses" accesskey="n" rel="next">With_Clauses</a>, Previous: <a href="#Usage" accesskey="p" rel="prev">Usage</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="Use_005fClauses-1"></a>
<h3 class="section">5.67 Use_Clauses</h3>
<p>This rule controls usage of <code><b>use</b></code> clauses.
</p>
<a name="Syntax-66"></a>
<h4 class="subsection">5.67.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> use_clauses
[([<subrule>,] <package name> {, <package name>})];
<subrule> ::= package | local | global | type | type_local | type_global
</pre></div>
<a name="Action-66"></a>
<h4 class="subsection">5.67.2 Action</h4>
<p>The rule controls every <code><b>use</b></code> or <code><b>use type</b></code> clause,
<i>except</i> those that name one of the mentioned packages/types. It is
therefore possible to allow <code><b>use</b></code> or <code><b>use type</b></code>
clauses just for certain packages/types.
</p>
<p>If the keyword “package” is given (or no keyword at all), all
package <code><b>use</b></code> clauses are controlled. If the keyword
“global” is given, only <code><b>use</b></code> clauses that appear in
context clauses (i.e. together with the <code><b>with</b></code> clauses) are
controlled; if the keyword “local” is given, only <code><b>use</b></code>
clauses that appear as declarations are controlled.
</p>
<p>If the keyword “type” is given, all <code><b>use type</b></code> clauses are
controlled. If the keyword “type_global” is given, only <code><b>use
type</b></code> clauses that appear in context clauses (i.e. together with the
<code><b>with</b></code> clauses) are controlled; if the keyword “type_local”
is given, only <code><b>use type</b></code> clauses that appear as declarations
are controlled.
</p>
<p>This rule can be given at most once for each of check, search and
count. This way, it is possible to have a level considered a warning
(search), and one considered an error (check).
</p>
<p>Ex:
</p><div class="example">
<pre class="example">-- Global use clauses are disallowed, local ones only for IO:
check use_clauses (global);
check use_clauses (local, Ada.Text_IO, Ada.Wide_Text_IO);
-- No use type in context clauses, count types that are "use type"'d
check use_clauses (type_global);
count use_clauses (type);
</pre></div>
<hr>
<a name="With_005fClauses"></a>
<div class="header">
<p>
Previous: <a href="#Use_005fClauses" accesskey="p" rel="prev">Use_Clauses</a>, Up: <a href="#Rules-reference" accesskey="u" rel="up">Rules reference</a> </p>
</div>
<a name="With_005fClauses-1"></a>
<h3 class="section">5.68 With_Clauses</h3>
<p>This rule controls <code><b>with</b></code> clauses that should be removed or
moved to a better place.
</p>
<a name="Syntax-67"></a>
<h4 class="subsection">5.68.1 Syntax</h4>
<div class="example">
<pre class="example"><control_kind> with_clauses [(<subrule> [, <subrule>])];
<subrule> ::= multiple_names | reduceable | inherited
</pre></div>
<a name="Action-67"></a>
<h4 class="subsection">5.68.2 Action</h4>
<p>The parameters are subrule keywords that determine which kind of
control is performed:
</p><ul>
<li> <code>multiple_names</code> controls any <code><b>with</b></code> clause that
mentions more than one unit name.
</li><li> <code>reduceable</code> reports:
<ul>
<li> Redundant <code><b>with</b></code> clauses, i.e. clauses given more than once
for the same unit. This includes the case where the same
<code><b>with</b></code> clause is given in a specification and the
corresponding body, and the case of renamings of a same unit
(i.e. <code>Text_IO</code> and <code>Ada.Text_IO</code>). Note that giving a
<code><b>with</b></code> clause in a unit, and repeating it in a child unit (or
subunit) is <i>not</i> considered redundant. This also includes the case
of a <code><b>with</b></code> clause for an ancestor of the current unit.
</li><li> Unused <code><b>with</b></code> clauses, i.e. when nothing from the withed unit
is referenced in the corresponding unit. The rule signals when a withed
unit is not used in a unit, but used in one or more of its subunits. If
an unused <code><b>with</b></code> clause is given on a package specification, the
message reminds that it migh be useful for child units.
</li><li> Moveable <code><b>with</b></code> clauses, i.e. when the withed unit is not
used in the specification, but only in the body, and should be moved
to the body, or when the withed unit is only used in the private part,
and could be replaced by a <code><b>private</b></code> <code><b>with</b></code>.
</li></ul>
</li><li> <code>inherited</code> controls child units and subunits that reference a
unit which is not directly withed, i.e. when withed only from a parent
(or enclosing) unit. Although Ada rules imply that a <code><b>with</b></code>
clause carries on to child units and subunits, it can be considered
better practice to ensure that every compilation unit withes directly
the units it needs.
</li></ul>
<p>Each of the subrules can be given at most once. If no keyword is
given, all subrules are activated.
</p>
<p>Ex:
</p><div class="example">
<pre class="example">check with_clauses (multiple_names, reduceable);
search with_clauses (inherited);
</pre></div>
<a name="Variables"></a>
<h4 class="subsection">5.68.3 Variables</h4>
<table>
<tr><td width="25%"><b>Variable</b></td><td width="10%"><b>Values</b></td><td width="10%"><b>Default</b></td><td width="55%"><b>Effect</b></td></tr>
<tr><td width="25%">Check_Private_With</td><td width="10%">off<br>on</td><td width="10%">on</td><td width="55%"><dl compact="compact">
<dt>on</dt>
<dd><p>issues a message when a <code><b>with</b></code> can be
replaced with a <code><b>private</b></code> <code><b>with</b></code>.
</p></dd>
<dt>off</dt>
<dd><p>do not issue a message when a <code><b>with</b></code> can be replaced with a
<code><b>private</b></code> <code><b>with</b></code> (useful in Ada 95 mode).
</p></dd>
</dl></td></tr>
<tr><td width="25%">Ignore_Use_Clause</td><td width="10%">off/on</td><td width="10%">on</td><td width="55%"><dl compact="compact">
<dt>on</dt>
<dd><p>package names appearing in use clauses are not considered as a usage
of the package.
</p></dd>
<dt>off</dt>
<dd><p>names appearing in use clauses are treated like any other identifier
(see tip below).
</p></dd>
</dl></td></tr>
</table>
<a name="Tips-43"></a>
<h4 class="subsection">5.68.4 Tips</h4>
<p>A <code><b>with</b></code> clause can safely be removed if it is unused, and no
child unit (or subunit) reports that the unit is inherited.
</p>
<p>Normally, use of a package name in a <code><b>use</b></code> clause is <i>not</i>
considered a usage of the package; clearly, the <code><b>with</b></code> clause
can (and should) be removed (or moved) if the only use of the package
is in <code><b>use</b></code> clauses (removing or moving the <code><b>use</b></code>
clauses by the same token). However, some programming rules may require
placing <code><b>use</b></code> clauses in certain places, forcing the corresponding
<code><b>with</b></code> clause. Set the variable <code>Ignore_Use_Clause</code> to
<code>off</code> to make sure that a <code><b>use</b></code> clause does mark the
<code><b>with</b></code> clause as necessary.
</p>
<hr>
<a name="Examples-of-using-AdaControl-for-common-programming-rules"></a>
<div class="header">
<p>
Next: <a href="#Specifying-an-Ada-entity-name" accesskey="n" rel="next">Specifying an Ada entity name</a>, Previous: <a href="#Rules-reference" accesskey="p" rel="prev">Rules reference</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> </p>
</div>
<a name="Examples-of-using-AdaControl-for-common-programming-rules-1"></a>
<h2 class="chapter">6 Examples of using AdaControl for common programming rules</h2>
<p>In most projects, there are <i>programming rules</i> that define the way
a program should be written. AdaControl performs controls, i.e. it
finds occurrences of certain kinds of constructs. In this chapter, we
give examples of commonly found programming rules, and how the
corresponding controls can be written.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Migrating-from-Gnatcheck" accesskey="1">Migrating from Gnatcheck</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#command-files-provided-with-AdaControl" accesskey="2">command files provided with AdaControl</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Automatically-checkable-rules" accesskey="3">Automatically checkable rules</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Rules-that-need-manual-inspection" accesskey="4">Rules that need manual inspection</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Migrating-from-Gnatcheck"></a>
<div class="header">
<p>
Next: <a href="#command-files-provided-with-AdaControl" accesskey="n" rel="next">command files provided with AdaControl</a>, Previous: <a href="#Examples-of-using-AdaControl-for-common-programming-rules" accesskey="p" rel="prev">Examples of using AdaControl for common programming rules</a>, Up: <a href="#Examples-of-using-AdaControl-for-common-programming-rules" accesskey="u" rel="up">Examples of using AdaControl for common programming rules</a> </p>
</div>
<a name="Migrating-from-Gnatcheck-1"></a>
<h3 class="section">6.1 Migrating from Gnatcheck</h3>
<p>The file <code>gnatcheck.aru</code> in directory <code>rules</code> gives the
AdaControl equivalents of rules checked by Gnatcheck. This version of
AdaControl covers most of Gnatcheck rules. For rules where Gnatcheck
requires a parameter, the AdaControl rule is given for the default
value, or with an example value. Small differences in semantics are
indicated by a comment that starts with "Difference:".
</p>
<p>This file is not intended to be used directly, but as an example on
how to convert Gnatcheck rules into AdaControl rules. Note that in
many cases, AdaControl is much more general than Gnatcheck. The file
follows as strictly as possible the rules as defined by Gnatcheck, but
if you are migrating from Gnatcheck to AdaControl, you may want to use
the more powerful forms provided by AdaControl.
</p>
<hr>
<a name="command-files-provided-with-AdaControl"></a>
<div class="header">
<p>
Next: <a href="#Automatically-checkable-rules" accesskey="n" rel="next">Automatically checkable rules</a>, Previous: <a href="#Migrating-from-Gnatcheck" accesskey="p" rel="prev">Migrating from Gnatcheck</a>, Up: <a href="#Examples-of-using-AdaControl-for-common-programming-rules" accesskey="u" rel="up">Examples of using AdaControl for common programming rules</a> </p>
</div>
<a name="Command-files-provided-with-AdaControl"></a>
<h3 class="section">6.2 Command files provided with AdaControl</h3>
<p>The <code>rules</code> directory provides also rules files that can be
sourced to enforce some commonly encountered general rules.
</p>
<br>
<p><b>Identifiers from Standard shall not be redefined</b>
</p>
<p>Use file <code>no_standard_entity.aru</code>.
</p>
<br>
<p><b>Identifiers from System shall not be redefined</b>
</p>
<p>Use file <code>no_system_entity.aru</code>.
</p>
<br>
<p><b>Predefined IO packages shall not be used</b>
</p>
<p>Use file <code>no_io.aru</code>.
</p>
<br>
<p><b>Standard package XXX shall not be used</b>
</p>
<p>File <code>no_standard_unit.aru</code> controls usage of <i>all</i> standard
packages. Comment out those that you do want to allow.
</p>
<br>
<p><b>Obsolescent features shall not be used</b>
</p>
<p>Use file <code>no_obsolescent_features.aru</code>. Not all obsolescent features are
controlled, but most of them (those that are most worth checking) are.
</p>
<br>
<p><b>Gnat specific attributes shall not be used</b>
</p>
<p>Use file <code>no_gnat_attribute.aru</code>
</p>
<br>
<p><b>Features from annex X shall not be used</b>
</p>
<p>Use file <code>no_annex_X.aru</code>.
</p>
<br>
<p><b>The Ravenscar profile shall be enforced</b>
</p>
<p>Use file <code>ravenscar.aru</code>.
</p>
<p>Note that not all of the restrictions of the Ravenscar profile are
currently controlled, but many are, and we expect later releases of
AdaControl to increase the number of controlled features. In some
cases (like “Detect_Blocking”), AdaControl does a better job than
the profile, since it can detect statically situations that the
profile only requires to be detected at run-time. The command file is
also slightly more restrictive than the profile; for example, the
restriction “no_task_allocation” only disallows task allocators,
while this command file controls the declaration of access types on tasks.
</p>
<br>
<p><b>NASA coding guidelines shall be enforced</b>
</p>
<p>Use file <code>nasa.aru</code>. This file is an example of how to convert
guidelines (available from
<a href="http://fsw.gsfc.nasa.gov/gds/code_standards_ada.pdf">http://fsw.gsfc.nasa.gov/gds/code_standards_ada.pdf</a>) into an
AdaControl command file.
</p>
<br>
<p><b>Ada 83 unit names shall not be used (i.e. use <code>Ada.Text_IO</code>, not <code>Text_IO</code>)</b>
</p>
<p>Use file <code>no_83_unit_name.aru</code>.
</p>
<br>
<p><b>New reserved words of Ada 2005/2012 shall not be used</b>
</p>
<p>Use file <code>reserved_2005.aru</code>. (the file name mentions only 2005,
but it checks also for 2012 - after all, there is only one extra
reserved word).
</p>
<br>
<p><b>Measurements for the SQALE method</b>
</p>
<p>AdaControl can provide measurements required by the SQALE quality
measurement method. The corresponding file is <code>SQALE.aru</code>.
</p>
<p>For information about the SQALE method, please refer to J-P Rosen’s paper at
<a href="http://www.adalog.fr/publicat/sqale.pdf">http://www.adalog.fr/publicat/sqale.pdf</a>
</p>
<hr>
<a name="Automatically-checkable-rules"></a>
<div class="header">
<p>
Next: <a href="#Rules-that-need-manual-inspection" accesskey="n" rel="next">Rules that need manual inspection</a>, Previous: <a href="#command-files-provided-with-AdaControl" accesskey="p" rel="prev">command files provided with AdaControl</a>, Up: <a href="#Examples-of-using-AdaControl-for-common-programming-rules" accesskey="u" rel="up">Examples of using AdaControl for common programming rules</a> </p>
</div>
<a name="Automatically-checkable-rules-1"></a>
<h3 class="section">6.3 Automatically checkable rules</h3>
<p>Below are examples of rules that can be directly checked by AdaControl.
</p>
<br>
<p><b>Goto statement shall not be used</b>
</p><div class="example">
<pre class="example">check statements (goto);
</pre></div>
<br>
<p><b>Functions shall not have <code><b>out</b></code> or <code><b>in out</b></code> parameters (Ada 2012)</b>
</p><div class="example">
<pre class="example">check parameter_declarations (out_parameters, max 0, function);
check parameter_declarations (in_out_parameters, max 0, function);
</pre></div>
<br>
<p><b>Short circuit forms should be preferred over corresponding logical operators</b>
</p><div class="example">
<pre class="example">Use_Short_Circuit: search expressions (and, or);
</pre></div>
<br>
<p><b>Aggregates should be used for full assignments to structured variables, unless it is a record with a single component</b>
</p><div class="example">
<pre class="example">check multiple_assignments (groupable, given 2, ratio 100);
</pre></div>
<br>
<p><b>All loops that contain exit statements must be named, and the name must be given in the exit statement</b>
</p><div class="example">
<pre class="example">check statements (unnamed_loop_exited);
check statements (unnamed_exit);
</pre></div>
<br>
<p><b>All type names must start with “T_”</b>
</p><div class="example">
<pre class="example">check naming_convention (type, "^T_");
</pre></div>
<br>
<p><b>All program units must repeat their name after the “end”</b>
</p><div class="example">
<pre class="example">check style (no_closing_name);
</pre></div>
<br>
<p><b>Pragma Suppress is not allowed</b>
</p><div class="example">
<pre class="example">check pragmas (suppress);
</pre></div>
<br>
<p><b>Ada tasking must not be used</b>
</p><div class="example">
<pre class="example">check declarations (task);
</pre></div>
<br>
<p><b>“=” and “/=” shall not be used between real types</b>
</p><div class="example">
<pre class="example">check expressions (real_equality);
</pre></div>
<br>
<p><b>All tasks must provide an exception handler that calls “Failure” in
the case of an unhandled exception</b>
</p><div class="example">
<pre class="example">check exception_propagation (task);
check silent_exceptions (failure);
</pre></div>
<br>
<p><b>Unchecked_Conversion shall not be used</b>
</p><div class="example">
<pre class="example">check entities (ada.unchecked_conversion);
</pre></div>
<br>
<p><b>No global variable shall be declared in the visible part of a package
specification</b>
</p><div class="example">
<pre class="example">check usage (variable, from_spec);
</pre></div>
<br>
<p><b>Predefined numeric types of the language shall not be used</b>
</p><div class="example">
<pre class="example">check entities (standard.Integer,
standard.short_integer,
standard.long_integer,
standard.Float,
standard.short_float,
standard.long_float);
</pre></div>
<br>
<p><b>Access to subprograms shall not be used</b>
</p><div class="example">
<pre class="example">check declarations (access_to_sp);
</pre></div>
<br>
<p><b>Abort statements shall not be used</b>
</p><div class="example">
<pre class="example">check statements (abort);
</pre></div>
<br>
<p><b>There shall be only one instantiation of
Ada.Numerics.Generic_Elementary_Functions for each floating point type</b>
</p><div class="example">
<pre class="example">-- Put a --##RULE LINE OFF GEF
-- for the one which is allowed
GEF: check Instantiations (Ada.Numerics.Generic_Elementary_Functions);
</pre></div>
<br>
<p><b>A local item shall not hide an outer one with the same name</b>
</p><div class="example">
<pre class="example">check Local_Hiding;
</pre></div>
<br>
<p><b>There shall be no IOs in exception handlers</b>
</p><div class="example">
<pre class="example">check entity_inside_exception (ada.Text_IO.put, ada.Text_IO.put_line,
ada.Text_IO.get, ada.Text_IO.get_line);
</pre></div>
<p>Note that this checks for all overloaded procedures, but only those
dealing with characters and strings (those defined directly within
Ada.Text_IO). If the names “get” and “put” are not used for
anything else than IOs, a more general form can be given as:
</p><div class="example">
<pre class="example">check entity_inside_exception (all get, all put,
all get_line, all put_line);
</pre></div>
<p>This will check that no entity with the corresponding names appear in
exception handlers.
</p>
<br>
<p><b>Exceptions shall not be used</b>
</p><div class="example">
<pre class="example">No_Exception: check declarations (exception, handlers);
No_Exception: check statements (raise);
No_Exception: check entities (Ada.Exceptions);
</pre></div>
<p>This will check that no exception is declared, no exception handler is
provided, and no exception is raised, not even through the services of
the package <code>Ada.Exceptions</code>.
</p>
<br>
<p><b>No procedure exported to C shall propagate exceptions</b>
</p><div class="example">
<pre class="example">check exception_propagation (interface, C);
</pre></div>
<br>
<p><b>There shall be no Unchecked_Conversion to or from Address</b>
</p><div class="example">
<pre class="example">check instantiations (ada.unchecked_conversion, system.address);
check instantiations (ada.unchecked_conversion, <>, system.address);
</pre></div>
<br>
<p><b>There shall be no use clause except for Text_IO</b>
</p><div class="example">
<pre class="example">check use_clauses(ada.text_IO);
</pre></div>
<br>
<p><b>Use explicit list of values in case statements rather than “when others”if the “when others” would cover less than 10 values</b>
</p><div class="example">
<pre class="example">check Case_Statement(min_others_span, 10);
</pre></div>
<br>
<p><b>If a block is more than 20 lines long, it must be named</b>
</p><div class="example">
<pre class="example">check Max_Size(unnamed_block, 20);
</pre></div>
<br>
<p><b>Exceptions shall not be handled except by main program</b>
</p><div class="example">
<pre class="example">check declaration (handlers)
</pre></div>
<p>This check will be disabled for the exception handler of the main program.
</p>
<br>
<p><b>Each unit has a header starting with a fixed format, and must contain at least 10 lines of comments</b>
</p><div class="example">
<pre class="example">check header_comments (model, "header.txt");
check header_comments (minimum, 10);
</pre></div>
<p>The file <code>header.txt</code> contains the required header (as regexps), like:
</p><div class="example">
<pre class="example">^--*{50}$
^-- This is a header$
</pre></div>
<hr>
<a name="Rules-that-need-manual-inspection"></a>
<div class="header">
<p>
Previous: <a href="#Automatically-checkable-rules" accesskey="p" rel="prev">Automatically checkable rules</a>, Up: <a href="#Examples-of-using-AdaControl-for-common-programming-rules" accesskey="u" rel="up">Examples of using AdaControl for common programming rules</a> </p>
</div>
<a name="Rules-that-need-manual-inspection-1"></a>
<h3 class="section">6.4 Rules that need manual inspection</h3>
<p>Below are examples of rules that require manual inspection, but where
AdaControl can be used to identify suspicious areas.
</p>
<br>
<p><b>All usages of the ’ADDRESS attribute shall be justified and documented</b>
</p><div class="example">
<pre class="example">search entities (all 'address);
</pre></div>
<br>
<p><b>Specifying an address for a variable shall be restricted to hardware interfacing</b>
</p><div class="example">
<pre class="example">search representation_clauses(address);
</pre></div>
<br>
<p><b>There shall be no memory leakage</b>
</p><div class="example">
<pre class="example">search Allocators;
</pre></div>
<p>This rule identifies all allocations, and thus can be used to check
that all allocated elements are properly deallocated.
</p>
<hr>
<a name="Specifying-an-Ada-entity-name"></a>
<div class="header">
<p>
Next: <a href="#Syntax-of-regular-expressions" accesskey="n" rel="next">Syntax of regular expressions</a>, Previous: <a href="#Examples-of-using-AdaControl-for-common-programming-rules" accesskey="p" rel="prev">Examples of using AdaControl for common programming rules</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> </p>
</div>
<a name="Specifying-an-Ada-entity-name-1"></a>
<h2 class="appendix">Appendix A Specifying an Ada entity name</h2>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#General-syntax" accesskey="1">General syntax</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Overloaded-names" accesskey="2">Overloaded names</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Enumeration-literals" accesskey="3">Enumeration literals</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Operators" accesskey="4">Operators</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Attributes" accesskey="5">Attributes</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Anonymous-constructs-and-extended-return-statements" accesskey="6">Anonymous constructs and extended return statements</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Record-and-protected-types-components" accesskey="7">Record and protected types components</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Formals-of-access-to-subprogram-types" accesskey="8">Formals of access to subprogram types</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Limitation" accesskey="9">Limitation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="General-syntax"></a>
<div class="header">
<p>
Next: <a href="#Overloaded-names" accesskey="n" rel="next">Overloaded names</a>, Previous: <a href="#Specifying-an-Ada-entity-name" accesskey="p" rel="prev">Specifying an Ada entity name</a>, Up: <a href="#Specifying-an-Ada-entity-name" accesskey="u" rel="up">Specifying an Ada entity name</a> </p>
</div>
<a name="General-syntax-1"></a>
<h3 class="section">A.1 General syntax</h3>
<p>Many rules can take Ada entities as parameters. Each time a rule uses
the category <entity>, it refers to an Ada entity that can be
specified with the following syntax:
</p><div class="example">
<pre class="example"><entity> ::= <full_name> | "all" <simple_name> | "all" <attribute>
</pre></div>
<p><code><full_name></code> is the full name of the Ada entity, using normal
Ada dot notation (with some extensions, see below). Full name means
that you give the full expanded name, starting from a compilation
unit. This name must be the actual full name, i.e. it must not include
any renaming (otherwise the name will not be recognized). For example,
the usual <code>Put_Line</code> must be given as
<code>Ada.Text_IO.Put_Line</code>, not as
<code>Text_IO.Put_Line</code>. Predefined elements (<code>Integer</code>,
<code>Constraint_Error</code>) must be given in the form
<code>Standard.Integer</code> or <code>Standard.Constraint_Error</code>, since
they are logically declared in the package <code>Standard</code>.
</p>
<p><code><simple_name></code> is a single identifier, possibly followed by
overloading information. No qualification is allowed.
</p>
<p><code><Attribute></code> is an attribute name, including the quote. No
overloading information is allowed.
</p>
<p><code><full_name></code> designates a single entity or several overloaded
entities declared in the same place (as identified by the prefix),
while <code>all <simple_name></code> designates all identifiers with the
given name in the program, irrespectively of where they
appear. <code>all <Attribute></code> designates all occurrences of the given
attribute, irrespectively of what the attribute applies to.
</p>
<p>A utility is provided with AdaControl to help you find the full name
of an entity. See <a href="#pfni">pfni</a>. If you are using GPS with AdaControl
plug-ins, it can be accessed directly from the contextual
menu. See <a href="#Contextual-menu">Contextual menu</a>.
</p>
<hr>
<a name="Overloaded-names"></a>
<div class="header">
<p>
Next: <a href="#Enumeration-literals" accesskey="n" rel="next">Enumeration literals</a>, Previous: <a href="#General-syntax" accesskey="p" rel="prev">General syntax</a>, Up: <a href="#Specifying-an-Ada-entity-name" accesskey="u" rel="up">Specifying an Ada entity name</a> </p>
</div>
<a name="Overloaded-names-1"></a>
<h3 class="section">A.2 Overloaded names</h3>
<p>In Ada, names can be overloaded. This means that you can have several
procedures <code>P</code> in package <code> Pack</code>, if they differ by the
types of the parameters. If you just give the name <code>Pack.P</code> as
the <entity>, the corresponding rule will be applied to all
elements named <code>P</code> from package <code>Pack</code>. If you want to
distinguish between overloaded names, you can specify a profile after
the element’s name. A profile has the syntax:
</p>
<div class="example">
<pre class="example">"{" [ ["access"] <type-name>
{ ";" ["access"] <type-name> } ]
["return" <type-name>] "}"
</pre></div>
<p>You must specify the <i>type</i> name, even if the <entity>
declaration uses a subtype of the type; this is because Ada uses types
for overloading resolution, not subtypes. Anonymous access parameters
are specified by putting <code>access</code> in front of the type name. An
overloaded name for a procedure without parameters uses just a pair of
empty brackets. If the subprogram is a function, you must provide the
<code>return <type-name></code> part for the return type of the
function. The types must also be given as a unique name,
i.e. including the full path: if the type is <code>T</code> declared in
package <code>Pack</code>, you must specify it as <code>Pack.T</code>. As a
convenience, the <code>Standard.</code> is optional for predefined types, so
you can write <code>Standard.Integer</code> as <code>Integer</code>. There is no
ambiguity, since a type is always declared within some construct. Note
that omitting <code>Standard</code> works only for <i>types</i> that are part
of the profile used to distinguish between overloaded Ada entities but
that the <i>Ada entity name</i> must always contain Standard if it is a
predefined element.
</p>
<p>Overloaded names can be also be used with the <code>all <simple_name></code>
form of the <entity>. In this case, the rule will be applied to
all names that are subprograms with the given identifier and matching
the given profile, irrespectively of where they appear.
</p>
<p>Note that if you use an overloaded name, all overloadable names that
are part of the <entity>, including those of the profile, must
use the overloaded syntax. For example, given the following program
</p><div class="example">
<pre class="example"><b>procedure</b> P <b>is</b>
<b>procedure</b> Q (I : Integer) <b>is</b>
...
<b>end</b> Q;
<b>procedure</b> Q (F : Float) <b>is</b>
...
<b>end</b> Q;
<b>begin</b>
...
<b>end</b> P;
</pre></div>
<p>If you want to distinguish between the two procedures <code>Q</code>, you
must specify them as <code>P{}.Q{Integer}</code> and
<code>P{}.Q{Float}</code> (note the <code>P{}</code> which specifies an
overloaded name for a procedure <code>P</code> without parameters).
</p>
<p>The names of entities which can not be overloaded (like package,
exception, …) must not be suffixed by braces
(e.g. <code>Ada.Text_IO.Put_Line{Standard.String}</code>).
</p>
<hr>
<a name="Enumeration-literals"></a>
<div class="header">
<p>
Next: <a href="#Operators" accesskey="n" rel="next">Operators</a>, Previous: <a href="#Overloaded-names" accesskey="p" rel="prev">Overloaded names</a>, Up: <a href="#Specifying-an-Ada-entity-name" accesskey="u" rel="up">Specifying an Ada entity name</a> </p>
</div>
<a name="Enumeration-literals-1"></a>
<h3 class="section">A.3 Enumeration literals</h3>
<p>Following normal Ada rules, an enumeration literal is considered a
parameterless function. If you want to distinguish between overloaded
enumeration literals, you can use overloaded names for them. For
example, given:
</p><div class="example">
<pre class="example"><b>package</b> Pack <b>is</b>
<b>type</b> T1 <b>is</b> (A, B);
<b>type</b> T2 <b>is</b> (B, C);
<b>end</b> Pack;
</pre></div>
<p>Ada entities names are:
</p><ul>
<li> <code>Pack.B{return Pack.T1}</code>
</li><li> <code>Pack.B{return Pack.T2}</code>
</li></ul>
<hr>
<a name="Operators"></a>
<div class="header">
<p>
Next: <a href="#Attributes" accesskey="n" rel="next">Attributes</a>, Previous: <a href="#Enumeration-literals" accesskey="p" rel="prev">Enumeration literals</a>, Up: <a href="#Specifying-an-Ada-entity-name" accesskey="u" rel="up">Specifying an Ada entity name</a> </p>
</div>
<a name="Operators-1"></a>
<h3 class="section">A.4 Operators</h3>
<p>AdaControl handles operators (i.e. functions like <code>"+"</code>)
correctly. Of course, you must specify such operations using normal
Ada syntax: if you define the integer type <code>T</code> in package
<code>Pack</code>, an overloaded name for the addition would be
<code>Pack."+"{Pack.T; Pack.T return Pack.T}</code>.
</p>
<hr>
<a name="Attributes"></a>
<div class="header">
<p>
Next: <a href="#Anonymous-constructs-and-extended-return-statements" accesskey="n" rel="next">Anonymous constructs and extended return statements</a>, Previous: <a href="#Operators" accesskey="p" rel="prev">Operators</a>, Up: <a href="#Specifying-an-Ada-entity-name" accesskey="u" rel="up">Specifying an Ada entity name</a> </p>
</div>
<a name="Attributes-1"></a>
<h3 class="section">A.5 Attributes</h3>
<p>It is also possible to designate attributes of entities, using the
normal notation (i.e. <code>Standard.Integer'First</code>). If the name of
an attribute which is a function appears in a name that uses the
overloaded syntax, it is not necessary (and actually not allowed) to
provide its profile, since there is no possible ambiguity in that
case. For example, given:
</p>
<div class="example">
<pre class="example"><b>procedure</b> P (I : Integer) <b>is</b>
<b>type</b> T <b>is</b> <b>range</b> 1 .. 10;
<b>begin</b>
...
<b>end</b> P;
</pre></div>
<p>You can designate the <code>'Image</code> attribute for type <code>T</code> as
<code>P{Standard.Integer}.T'Image</code> (the profile of the <code>'Image</code>
function is not given, as would be necessary for a normal function).
</p>
<p>To designate all occurrences of an attribute, use <code><b>all</b></code> in
front of the attribute. To designate only occurrences of an attribute
whose prefix is a (sub) type (but any type or subtype), give it as
<code>type'Attr</code> (i.e. the keyword “type” is put in front of the
quote).
</p>
<p><code><b>all</b></code> may be used in place of an attribute name to mean “any
attribute”. See examples below.
</p>
<div class="example">
<pre class="example">check entities (all 'Image); -- Find all occurrences of 'Image
check entities (all type'Length); -- Find all occurrences of 'Length
-- applied to a type
check entities (Standard.Integer'all); -- Find all attributes applied
-- to type Integer
Check entities (all type'all); -- Find all attributes applied
-- to a type
check entities (all 'all); -- Find all attributes
</pre></div>
<hr>
<a name="Anonymous-constructs-and-extended-return-statements"></a>
<div class="header">
<p>
Next: <a href="#Record-and-protected-types-components" accesskey="n" rel="next">Record and protected types components</a>, Previous: <a href="#Attributes" accesskey="p" rel="prev">Attributes</a>, Up: <a href="#Specifying-an-Ada-entity-name" accesskey="u" rel="up">Specifying an Ada entity name</a> </p>
</div>
<a name="Anonymous-constructs-and-extended-return-statements-1"></a>
<h3 class="section">A.6 Anonymous constructs and extended return statements</h3>
<p>There is a special case for elements that are defined (directly or
indirectly) within unnamed loops or block statements. Everything
happens as if the unnamed construct was named
<code>_anonymous_</code>. Therefore if you have the following program:
</p><div class="example">
<pre class="example"><b>procedure</b> P <b>is</b>
<b>begin</b>
<b>for</b> I <b>in</b> 1..10 <b>loop</b>
<b>declare</b>
J : Integer;
<b>begin</b>
...
<b>end</b>;
<b>end</b> <b>loop</b>;
<b>end</b> P;
</pre></div>
<p>You can refer to <code>I</code> as <code>P._anonymous_.I</code>, and to <code>J</code>
as <code>P._anonymous_._anonymous_.J</code>.
</p>
<p>Similarly, an extended return statement is considered “named” <code>return</code>.
Therefore if you have the following program:
</p><div class="example">
<pre class="example"><b>function</b> F <b>return</b> Integer <b>is</b>
I : Integer;
<b>begin</b>
<b>return</b> I : Integer <b>do</b>
...
<b>end</b> <b>return</b>;
<b>end</b> F;
</pre></div>
<p>You can refer to the <code>I</code> declared in <code>F</code> as <code>F.I</code>, and
to the return object <code>I</code> as <code>F.return.I</code>.
</p>
<hr>
<a name="Record-and-protected-types-components"></a>
<div class="header">
<p>
Next: <a href="#Formals-of-access-to-subprogram-types" accesskey="n" rel="next">Formals of access to subprogram types</a>, Previous: <a href="#Anonymous-constructs-and-extended-return-statements" accesskey="p" rel="prev">Anonymous constructs and extended return statements</a>, Up: <a href="#Specifying-an-Ada-entity-name" accesskey="u" rel="up">Specifying an Ada entity name</a> </p>
</div>
<a name="Record-and-protected-types-components-1"></a>
<h3 class="section">A.7 Record and protected types components</h3>
<p>You can designate the name of a record or protected type component (a
“field” name), but to identify it uniquely, you must precede its name
by the name of the type. This is a small extension to Ada syntax, but
it is the simplest and most natural way to deal with this case. For
example, given:
</p><div class="example">
<pre class="example"><b>procedure</b> P <b>is</b>
<b>type</b> T <b>is</b>
<b>record</b>
Name : Integer;
<b>end</b> <b>record</b>;
...
</pre></div>
<p>The Ada entity name is <code>P.T.Name</code>.
</p>
<hr>
<a name="Formals-of-access-to-subprogram-types"></a>
<div class="header">
<p>
Next: <a href="#Limitation" accesskey="n" rel="next">Limitation</a>, Previous: <a href="#Record-and-protected-types-components" accesskey="p" rel="prev">Record and protected types components</a>, Up: <a href="#Specifying-an-Ada-entity-name" accesskey="u" rel="up">Specifying an Ada entity name</a> </p>
</div>
<a name="Formals-of-access-to-subprogram-types-1"></a>
<h3 class="section">A.8 Formals of access to subprogram types</h3>
<p>Similarly, you can designate the formal of an access to subprogram
type by prefixing it by the access type. For example, given:
</p><div class="example">
<pre class="example"><b>procedure</b> P <b>is</b>
<b>type</b> T <b>is</b> <b>access</b> <b>procedure</b> (X : Integer);
...
</pre></div>
<p>The Ada entity name of the formal is <code>P.T.X</code>.
</p>
<hr>
<a name="Limitation"></a>
<div class="header">
<p>
Previous: <a href="#Formals-of-access-to-subprogram-types" accesskey="p" rel="prev">Formals of access to subprogram types</a>, Up: <a href="#Specifying-an-Ada-entity-name" accesskey="u" rel="up">Specifying an Ada entity name</a> </p>
</div>
<a name="Limitation-17"></a>
<h3 class="section">A.9 Limitation</h3>
<p>Due to a limitation of ASIS for GNAT, it is not possible to specify
a profile with predefined operators; predefined operators without
a profile work normally.
</p><div class="example">
<pre class="example">-- This will not recognize "<" on Standard.Integer:
check entities (Standard."<"{Standard.Integer,
Standard.Integer
return Standard.Boolean});
-- This will correctly recognize all predefined "<":
check entities (Standard."<");
</pre></div>
<hr>
<a name="Syntax-of-regular-expressions"></a>
<div class="header">
<p>
Next: <a href="#Non-upward_002dcompatible-changes" accesskey="n" rel="next">Non upward-compatible changes</a>, Previous: <a href="#Specifying-an-Ada-entity-name" accesskey="p" rel="prev">Specifying an Ada entity name</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> </p>
</div>
<a name="Syntax-of-regular-expressions-1"></a>
<h2 class="appendix">Appendix B Syntax of regular expressions</h2>
<p>The following syntax gives the complete definition of regular
expressions, as used by several rules. It is taken from the
specification of the package <code>gnat.regpat</code>, where additional
information is available.
</p>
<div class="example">
<pre class="example">regexp ::= expr
::= ^ expr -- anchor at the beginning of string
::= expr $ -- anchor at the end of string
expr ::= term
::= term | term -- alternation (term or term ...)
term ::= item
::= item item ... -- concatenation (item then item)
item ::= elmt -- match elmt
::= elmt * -- zero or more elmt's
::= elmt + -- one or more elmt's
::= elmt ? -- matches elmt or nothing
::= elmt *? -- zero or more times, minimum number
::= elmt +? -- one or more times, minimum number
::= elmt ?? -- zero or one time, minimum number
::= elmt { num } -- matches elmt exactly num times
::= elmt { num , } -- matches elmt at least num times
::= elmt { num , num2 } -- matches between num and num2 times
::= elmt { num }? -- matches elmt exactly num times
::= elmt { num , }? -- matches elmt at least num times
non-greedy version
::= elmt { num , num2 }? -- matches between num and num2 times
non-greedy version
elmt ::= nchr -- matches given character
::= [range range ...] -- matches any character listed
::= [^ range range ...] -- matches any character not listed
::= . -- matches any single character
-- except newlines
::= ( expr ) -- parens used for grouping
::= \ num -- reference to num-th parenthesis
range ::= char - char -- matches chars in given range
::= nchr
::= [: posix :] -- any character in the POSIX range
::= [:^ posix :] -- not in the POSIX range
posix ::= alnum -- alphanumeric characters
::= alpha -- alphabetic characters
::= ascii -- ascii characters (0 .. 127)
::= cntrl -- control chars (0..31, 127..159)
::= digit -- digits ('0' .. '9')
::= graph -- graphic chars (32..126, 160..255)
::= lower -- lower case characters
::= print -- printable characters (32..127)
::= punct -- printable, except alphanumeric
::= space -- space characters
::= upper -- upper case characters
::= word -- alphanumeric characters
::= xdigit -- hexadecimal chars (0..9, a..f)
char ::= any character, including special characters
ASCII.NUL is not supported.
nchr ::= any character except \()[].*+?^ or \char to match char
\n means a newline (ASCII.LF)
\t means a tab (ASCII.HT)
\r means a return (ASCII.CR)
\b matches the empty string at the beginning or end of a
word. A word is defined as a set of alphanumerical
characters (see \w below).
\B matches the empty string only when *not* at the
beginning or end of a word.
\d matches any digit character ([0-9])
\D matches any non digit character ([^0-9])
\s matches any white space character. This is equivalent
to [ \t\n\r\f\v] (tab, form-feed, vertical-tab,...
\S matches any non-white space character.
\w matches any alphanumeric character or underscore.
This include accented letters, as defined in the
package Ada.Characters.Handling.
\W matches any non-alphanumeric character.
\A match the empty string only at the beginning of the
string, whatever flags are used for Compile (the
behavior of ^ can change, see Regexp_Flags below).
\G match the empty string only at the end of the
string, whatever flags are used for Compile (the
behavior of $ can change, see Regexp_Flags below).
... ::= is used to indication repetition (one or more terms)
</pre></div>
<p>Embedded newlines are not matched by the ^ operator. It is possible
to retrieve the substring matched a parenthesis expression. Although
the depth of parenthesis is not limited in the regexp, only the first
9 substrings can be retrieved.
</p>
<p>The operators ’*’, ’+’, ’?’ and ’{}’ always match the longest possible
substring. They all have a non-greedy version (with an extra ? after
the operator), which matches the shortest possible substring.
</p>
<p>For instance:
</p><div class="example">
<pre class="example"> regexp="<.*>" string="<h1>title</h1>" matches="<h1>title</h1>"
regexp="<.*?>" string="<h1>title</h1>" matches="<h1>"
</pre></div>
<p>’{’ and ’}’ are only considered as special characters if they appear
in a substring that looks exactly like ’{n}’, ’{n,m}’ or ’{n,}’, where
n and m are digits. No space is allowed. In other contexts, the curly
braces will simply be treated as normal characters.
</p>
<p>Note that if you compiled AdaControl with the
<code>String_Matching_Portable</code> package, only basic wildcards are
available, i.e. only “*” and “?” are supported, where “*”
matches any string of character and “?” matches a single character.
</p>
<hr>
<a name="Non-upward_002dcompatible-changes"></a>
<div class="header">
<p>
Previous: <a href="#Syntax-of-regular-expressions" accesskey="p" rel="prev">Syntax of regular expressions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> </p>
</div>
<a name="Non-upward_002dcompatible-changes-1"></a>
<h2 class="appendix">Appendix C Non upward-compatible changes</h2>
<p>This chapter is intended to users of a previous version of AdaControl,
who want to migrate command files to the latest version. Although we
understand the burden of non upward-compatible changes, we consider
that making AdaControl more powerful and easier to use is sometimes
more important than strict compatibility. Moreover, in most cases the
changes are very straightforward and can be done easily by hand, or
with scripts if many files are involved.
</p>
<a name="Migrating-from-1_002e17r3"></a>
<h3 class="section">C.1 Migrating from 1.17r3</h3>
<a name="Statements-2"></a>
<h4 class="subsection">C.1.1 Statements</h4>
<p>The subrules <code>dispatching_call</code> and <code>redispatching_call</code> do
not control <i>function</i> calls anymore, since these are controlled (more
appropriately) by subrules of the <code>expressions</code> rule. In short, change:
</p><div class="example">
<pre class="example">check statements (dispatching_call, redispatching_call);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check statements (dispatching_call, redispatching_call);
check expressions (dispatching_function_call,
redispatching_function_call);
</pre></div>
<p>The subrule <code>raise_nonpublic</code> does not control any more the
raising of exceptions declared in visible parts of packages other than
the one that contains the <code><b>raise</b></code> statement; these are now
controlled by the subrule <code>raise_foreign</code>. It also now accepts
(i.e. does not control) exceptions declared in the visible part of an
ancestor of the package that contains <code><b>raise</b></code> statement.
</p>
<a name="Use-of-command-line-options-_002dr-and-_002ds"></a>
<h4 class="subsection">C.1.2 Use of command line options -r and -s</h4>
<p>Previous versions mentionned in the command line syntax that “-r”
and “-s” could be used together, but the effect of this combination
was not documented. It has now a documented (and slightly different,
but more useful) effect. See <a href="#Input-units">Input units</a> and <a href="#Generating-a-units-list">Generating a units list</a>.
</p>
<a name="Migrating-from-1_002e16r11"></a>
<h3 class="section">C.2 Migrating from 1.16r11</h3>
<a name="Declarations_002c-Entities_002c-Instantiations"></a>
<h4 class="subsection">C.2.1 Declarations, Entities, Instantiations</h4>
<p>These rules use the concept of “location” to restrict the places
where some constructs are controlled. It is now possible to specify
“not” in front of a location keyword. As a consequence, the
keyword “nested” has been removed, as it was the same thing
as “not library”. In short, change:
</p><div class="example">
<pre class="example">check declarations (nested procedure);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check declarations (not library procedure);
</pre></div>
<a name="Migrating-from-1_002e15r5"></a>
<h3 class="section">C.3 Migrating from 1.15r5</h3>
<a name="Array_005fDeclarations-2"></a>
<h4 class="subsection">C.3.1 Array_Declarations</h4>
<p>The extension of aspects to more rules required a slight change in the
syntax of the “component” subrule: the keywords “packed”,
“sized”, and “component_sized” have been changed to “pack”,
“size”, and “component_size”, respectively.
</p>
<a name="Multiple_005fAssignments"></a>
<h4 class="subsection">C.3.2 Multiple_Assignments</h4>
<p>Due to new functionalities, and expecting more in the future, the rule
has been renamed to “Assignments”.
</p>
<a name="No_005fOperator_005fUsage-2"></a>
<h4 class="subsection">C.3.3 No_Operator_Usage</h4>
<p>The syntax has been changed, due to the introduction of
“indexing”. Moreover, the rule was not consistent, in that the
result of “none” was affected by the presence or absence of
“logical” (without “logical”, “none” included all types, while
with it, it counted only those not counted with “logical”). If you
want that exact same behaviour (which might not be desirable),
change:
</p><div class="example">
<pre class="example">-- (1)
check no_operator_usage (none);
-- (2)
check no_operator_usage (logical);
-- (3)
check no_operator_usage (none, logical)
-- or no parameters
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">-- (1)
check no_operator_usage(ignore indexing, ignore logical);
-- or no parameters
-- (2)
check no_operator_usage (logical);
-- (3)
check no_operator_usage (not logical),
check no_operator_usage (logical);
</pre></div>
<a name="Object_005fDeclarations-2"></a>
<h4 class="subsection">C.3.4 Object_Declarations</h4>
<p>Due to the necessity of avoiding a syntactic ambiguity in the new
subrule “type”, the keyword “all” is no more allowed in the syntax
for the subrule “min_integer_span” (specifying neither “variable”
or “constant” still means the subrule applies to both, as
before). Change:
</p><div class="example">
<pre class="example">count object_declarations (min_integer_span, all 8);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">count object_declarations (min_integer_span, 8);
</pre></div>
<a name="Statements-3"></a>
<h4 class="subsection">C.3.5 Statements</h4>
<p>The subrule “exit” was documented as controlling all exit
statements, but it did not report exits from <code><b>for</b></code> and
<code><b>while</b></code> loops if “exit_for_loop” (respectively
“exit_while_loop”) was also specified. It now behaves as documented,
i.e. it controls all <code><b>exit</b></code> statements.
</p>
<p>Note that if you want separate messages for each kind of loop, the new
rule “exit_plain_loop” controls exit from plain loops.
</p>
<a name="Style-2"></a>
<h4 class="subsection">C.3.6 Style</h4>
<p>The subrule “positional_association” is now a rule of its own,
“positional_associations”. The order of parameters is different, due
to various subrules of the new rule. Typically, change:
</p><div class="example">
<pre class="example">check style (parameter_association, call, 1);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check parameter_associations (all, 1, call);
</pre></div>
<p>Note that the new rule distinguishes between regular array aggregates
and aggregates used for enumeration representation clauses.
</p>
<p>Modes of the subrules “parameter_order” and
“formal_parameter_order” are now separated by “|”. With the
previous syntax, forgetting a comma was changing the meaning of the
rule without introducing a syntax error. Typically, change:
</p><div class="example">
<pre class="example">check style (parameter_order, in defaulted_in, out in_out);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check style (parameter_order, in | defaulted_in, out | in_out);
</pre></div>
<a name="Migrating-from-1_002e14r9"></a>
<h3 class="section">C.4 Migrating from 1.14r9</h3>
<a name="Local_005fHiding-2"></a>
<h4 class="subsection">C.4.1 Local_Hiding</h4>
<p>Due to the introduction of extra parameters for allowed patterns, it
is no more possible to specify the rule several times in the same
command. Change:
</p><div class="example">
<pre class="example">check local_hiding (strict, overloading);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check local_hiding (strict);
check local_hiding (overloading);
</pre></div>
<p>The special subrule “overloading_short” has been replaced by a rule
variable to choose the report format. Change:
</p><div class="example">
<pre class="example">check local_hiding (overloading_short);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">set local_hiding.overloading_report compact;
check local_hiding (overloading);
</pre></div>
<a name="Max_005fNesting-2"></a>
<h4 class="subsection">C.4.2 Max_Nesting</h4>
<p>The value given is now the <i>nesting</i> level (consistent with the rule name),
no more the maximum <i>depth</i>. This is more natural (Max_Nesting(1) means
that the construct can be nested once), but it is one less than in previous
versions. For example, change:
</p><div class="example">
<pre class="example">check Max_Nesting (5);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check Max_Nesting (4);
</pre></div>
<a name="Parameter_005fDeclarations-2"></a>
<h4 class="subsection">C.4.3 Parameter_Declarations</h4>
<p>The subrules have been generalized, using the same syntax for bounds
as other rules. Change:
</p><div class="example">
<pre class="example">check parameter_declarations (min_parameters, 1);
check parameter_declarations (max_parameters, 5);
check parameter_declarations (max_defaulted_parameters, 3);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check parameter_declarations (all_parameters, min 1, max 5);
check parameter_declarations (defaulted_parameters, max 3);
</pre></div>
<a name="Migrating-from-1_002e11r4"></a>
<h3 class="section">C.5 Migrating from 1.11r4</h3>
<a name="Expressions-2"></a>
<h4 class="subsection">C.5.1 Expressions</h4>
<p>The subrule <code>Real_Equality</code> does not control user-defined
equality operators any more. This is intended to be more of an
improvement than an incompatibily.
</p>
<a name="Special_005fComments"></a>
<h4 class="subsection">C.5.2 Special_Comments</h4>
<p>Since the number of subrules is growing, and do not only address ‘special”
comments, this rule has been renamed to “comments”.
</p>
<a name="Migrating-from-1_002e10r10"></a>
<h3 class="section">C.6 Migrating from 1.10r10</h3>
<a name="GPS-integration"></a>
<h4 class="subsection">C.6.1 GPS integration</h4>
<p>Due to a bug/feature of the GPS interface, if a units file was
specified, it did not reappear later in the corresponding box of the
Switch/AdaControl dialog. This has been fixed, but you must reenter
the units file name in the dialog.
</p>
<a name="Representation_005fClauses-2"></a>
<h4 class="subsection">C.6.2 Representation_Clauses</h4>
<p>The introduction of categories made some subrules syntactically
ambiguous or redundant. In consequence, the subrules
“derived_record”, “extension_record”, and “tagged_record” have
been removed, and the subrules “record”, “incomplete_record”, and
“non_contiguous_record” have been renamed as “layout”,
“incomplete_layout”, and “non_contiguous_layout” respectively. Change:
</p><div class="example">
<pre class="example">check representation_clause (derived_record);
check representation_clause (extension_record);
check representation_clause (tagged_record);
check representation_clause (record);
check representation_clause (incomplete_record);
check representation_clause (non_contiguous_record);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check representation_clause (new layout);
check representation_clause (extension layout);
check representation_clause (tagged layout);
check representation_clause (layout);
check representation_clause (incomplete_layout);
check representation_clause (non_contiguous_layout);
</pre></div>
<a name="Migrating-from-1_002e9r4"></a>
<h3 class="section">C.7 Migrating from 1.9r4</h3>
<a name="Array_005fDeclarations-3"></a>
<h4 class="subsection">C.7.1 Array_Declarations</h4>
<p>The subrule “Max_Length” has been changed to “Length”, with the possibility to specify both min and max
values. Change:
</p><div class="example">
<pre class="example">check array_declarations (max_length, 100);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check array_declarations (length, max 100);
</pre></div>
<a name="Declarations-2"></a>
<h4 class="subsection">C.7.2 Declarations</h4>
<p>The subrule names “initialized_record_field”,
“uninitialized_record_field”, “initialized_protected_field”, and
“uninitialized_protected_field” have been changed to
“initialized_record_component”, “uninitialized_record_component”,
“initialized_protected_component”, and
“uninitialized_protected_component”, respectively, to be more
consistent with official Ada terminology. Change:
</p><div class="example">
<pre class="example">check declarations (initialized_record_field,
uninitialized_record_field,
initialized_protected_field,
uninitialized_protected_field);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check declarations (initialized_record_component,
uninitialized_record_component,
initialized_protected_component,
uninitialized_protected_component);
</pre></div>
<p>The subrule “aliased” has been split into “aliased_constant” and
“aliased_variable”. The old rule controlled both at the same time,
but did not control aliased components (there are now other subrules
to that effect). Change:
</p><div class="example">
<pre class="example">check declarations (aliased);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check declarations (aliased_constant, aliased_variable);
</pre></div>
<a name="Default_005fParameter-2"></a>
<h4 class="subsection">C.7.3 Default_Parameter</h4>
<p>The <place> is no more allowed to be “all”, because it was ambiguous
with the “all <name>” syntax of <entity>. If you used “all”,
duplicate the control with “calls” and “instantiations”. Change:
</p><div class="example">
<pre class="example">My_label : check default_parameter (all, ...);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">My_label : check default_parameter (calls, ...),
check default_parameter (instantiations, ...);
</pre></div>
<a name="Improper_005fInitialization-2"></a>
<h4 class="subsection">C.7.4 Improper_Initialization</h4>
<p>By default, variables declared directly within (generic) package
specifications and bodies are no more checked. To get the previous
behaviour, add the “package” modifier. Change:
</p><div class="example">
<pre class="example">check improper_initialization (variable);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check improper_initialization (package variable);
</pre></div>
<a name="Migrating-from-1_002e8r8"></a>
<h3 class="section">C.8 Migrating from 1.8r8</h3>
<a name="CSV_0028X_0029-format"></a>
<h4 class="subsection">C.8.1 CSV(X) format</h4>
<p>If the output format is CSV or CSVX, the file name, line number and
column number are generated as three different spreadsheet columns,
instead of forming a single message. This makes it easier to use a
spreadsheet program for per-file statistics.
</p>
<a name="Default_005fParameter-3"></a>
<h4 class="subsection">C.8.2 Default_Parameter</h4>
<p>Due to the introduction of the “positional” keyword, “not used” is
now spelled “not_used”. Change:
</p><div class="example">
<pre class="example">check default_parameter (proc, param, not used);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check default_parameter (proc, param, not_used);
</pre></div>
<a name="Other_005fDependencies"></a>
<h4 class="subsection">C.8.3 Other_Dependencies</h4>
<p>This rule has been changed into a subrule of the (new) rule
“Dependencies”. Change:
</p><div class="example">
<pre class="example">check Other_Dependencies (pack1, pack2);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check Dependencies (others, pack1, pack2);
</pre></div>
<a name="Special_005fComments-1"></a>
<h4 class="subsection">C.8.4 Special_Comments</h4>
<p>Due to the introduction of another subrule, add “pattern” as the first parameter
to the rule. Change:
</p><div class="example">
<pre class="example">check Special_Comments ("TBSL");
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check Special_Comments (pattern, "TBSL");
</pre></div>
<a name="Statements-4"></a>
<h4 class="subsection">C.8.5 Statements</h4>
<p>The “raise” subrule now reports all occurrences of the <code><b>raise</b></code>
statement, even if another control is applicable to the same statement.
</p>
<p>The “reraise” subrule now reports calls to
<code>Ada.Exceptions.Reraise_Occurrence</code>.
</p>
<p>The “raise_standard” subrule now reports exceptions raised by calls to
<code>Ada.Exceptions.Raise_Exception</code>.
</p>
<a name="Migrating-from-1_002e7r9"></a>
<h3 class="section">C.9 Migrating from 1.7r9</h3>
<a name="Case_005fStatement-2"></a>
<h4 class="subsection">C.9.1 Case_Statement</h4>
<p>This rule now allows the specification of both min and max values for
each subrule. Subrule names have been changed accordingly. Change:
</p><div class="example">
<pre class="example">check Case_Statement (max_range_span, 5);
check Case_Statement (max_values, 10);
check Case_Statement (min_others_span, 4);
check Case_Statement (min_paths, 6);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check Case_Statement (range_span, max 5);
check Case_Statement (values, max 10);
check Case_Statement (others_span, min 4);
check Case_Statement (paths, min 6);
</pre></div>
<a name="Max_005fParameters"></a>
<h4 class="subsection">C.9.2 Max_Parameters</h4>
<p>This rule has been changed into a subrule of the (new) rule
“Parameter_Declarations”. Change:
</p><div class="example">
<pre class="example">check Max_Parameters (10);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check Parameter_Declarations (Max_Parameters, 10);
</pre></div>
<a name="Migrating-from-1_002e6r8"></a>
<h3 class="section">C.10 Migrating from 1.6r8</h3>
<a name="g_t_0060_0060message_0027_0027-command"></a>
<h4 class="subsection">C.10.1 “message” command</h4>
<p>The message is now syntactically a string, and must always be enclosed
in double quotes (quotes were optional in previous versions).
</p>
<a name="g_t_0060_0060source_0027_0027-command"></a>
<h4 class="subsection">C.10.2 “source” command</h4>
<p>If a “source” command is given in a command file, and the sourced file
is given with a relative path, it is interpreted relatively to the
sourcing file (it was interpreted relatively to the current directory
previously). This should make “chained” sourcing easier, since the
interpretation does not depend on where the sourcing file is being
called from.
</p>
<a name="Control_005fCharacters"></a>
<h4 class="subsection">C.10.3 Control_Characters</h4>
<p>This rule is now called “Characters” and can process other kinds of
characters in addition to control characters. Control characters
correspond to the “control” parameter of the rule. Change:
</p><div class="example">
<pre class="example">check control_characters;
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check characters (control);
</pre></div>
<a name="If_005fFor_005fCase"></a>
<h4 class="subsection">C.10.4 If_For_Case</h4>
<p>This rule has been changed into a subrule of the (new) rule
“simplifiable_statements”. Change:
</p><div class="example">
<pre class="example">check if_for_case;
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check simplifiable_statements (if_for_case);
</pre></div>
<a name="Instantiations-2"></a>
<h4 class="subsection">C.10.5 Instantiations</h4>
<p>The rule does not print the number of instantiations any more, since the same
effect can be achieved with the “count” control kind.
</p>
<a name="Local_005fInstantiation"></a>
<h4 class="subsection">C.10.6 Local_Instantiation</h4>
<p>This rule has been removed, since its effect can now be achieved with other rules:
the rule “declarations” to check for local instantiations of any generic, and the rule
“instantiations” to check for local instantiations of specified generics.
Change:
</p><div class="example">
<pre class="example">R1: check Local_Instantiation;
R2: search Local_Instantiation (Ada.Unchecked_Conversion);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">R1: check declarations (local instantiation);
R2: search Instantiations (local Ada.Unchecked_Conversion);
</pre></div>
<a name="Naming_005fConvention-2"></a>
<h4 class="subsection">C.10.7 Naming_Convention</h4>
<p>Quotes are no more optional around patterns.
</p>
<p>The <location> modifier is now before the <filter_kind> (it was before the
pattern previously). This may require splitting the rule in two in some cases.
For example, change:
</p><div class="example">
<pre class="example">check naming_convention (object, local "^L_", global "^G_");
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check naming_convention (local object, "^L_");
check naming_convention (global object, "^G_");
</pre></div>
<a name="No_005fSafe_005fInitialization"></a>
<h4 class="subsection">C.10.8 No_Safe_Initialization</h4>
<p>The name of this rule has been changed to “improper_initialization”,
since it now controls other cases of improper initialization.
</p>
<a name="Special_005fComments-2"></a>
<h4 class="subsection">C.10.9 Special_Comments</h4>
<p>Quotes are no more optional around patterns.
</p>
<a name="Statements-5"></a>
<h4 class="subsection">C.10.10 Statements</h4>
<p>Two subrules of this rule have migrated to the new rule
“simplifiable_statements” (with slightly different names). Change:
</p><div class="example">
<pre class="example">check statements (unnecessary_null);
check statements (while_true);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check simplifiable_statements (null);
check simplifiable_statements (loop);
</pre></div>
<a name="Migrating-from-1_002e5r24"></a>
<h3 class="section">C.11 Migrating from 1.5r24</h3>
<a name="Declarations-3"></a>
<h4 class="subsection">C.11.1 Declarations</h4>
<p>The subrule “Formal_In_Out” has been renamed as
“In_Out_Generic_Parameter”, for consistency with the new
“In_Out_Parameter” subrule.
</p>
<p>The subrules “renames” and “not_operator_renames” have been renamed
to “renaming” and “not_operator_renaming”.
</p>
<p>As a consequence of being able to specify the location of any
construct, the subrules “nested_function_instantiation”,
“nested_generic_function”, “nested_generic_package”,
“nested_generic_procedure”, “nested_package”,
“nested_package_instantiation”, and
“nested_procedure_instantiation” have been removed and replaced with
the corresponding general construct (without “nested_”). You can
have the same effect by specifying the “nested” modifier in front of
them. I.e., change:
</p><div class="example">
<pre class="example">check declarations (nested_generic_function);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check declarations (nested generic_function);
</pre></div>
<a name="Naming_005fConvention-3"></a>
<h4 class="subsection">C.11.2 Naming_Convention</h4>
<p>The <location> keyword is placed before the <Filter_Kind> keyword instead of
before the <Pattern>, which looks more natural. The “Any” keyword has been removed,
since omitting the <location> keyword has the same effect. Change:
</p><div class="example">
<pre class="example">check naming_convention (variable, global "^G_");
check naming_convention (package, any "^Pack_");
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check naming_convention (global variable, "^G_");
check naming_convention (package, "^Pack_");
</pre></div>
<a name="Non_005fStatic_005fConstraint"></a>
<h4 class="subsection">C.11.3 Non_Static_Constraint</h4>
<p>This rule is now called Non_Static, since it is no more restricted to
constraints. The parameters “index” and “discriminant” have been
changed to “index_constraint” and “discriminant_constraint”,
respectively. Change:
</p><div class="example">
<pre class="example">check non_static_constraint (index, discriminant);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check non_static (index_constraint, discriminant_constraint);
</pre></div>
<a name="Positional_005fParameters"></a>
<h4 class="subsection">C.11.4 Positional_Parameters</h4>
<p>This rule has been renamed to <code>Insufficient_Parameters</code>, since it does no more
handle the “maximum” subrule. Controlling positional parameters according to their number
is now done by the rule <code>style (positional_association)</code>. Change:
</p><div class="example">
<pre class="example">check positional_parameters (maximum, 3);
check positional_parameters (insufficient, 2, Boolean);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check style (positional_association, call, 3);
check insufficient_parameters (2, Boolean);
</pre></div>
<a name="Real_005fOperator"></a>
<h4 class="subsection">C.11.5 Real_Operator</h4>
<p>This rule is no more a rule of its own, it is a subrule of the (new)
rule Expressions, whose name is Real_Equality. Change:
</p><div class="example">
<pre class="example">check Real_Operators;
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check expressions (Real_Equality);
</pre></div>
<a name="Style-3"></a>
<h4 class="subsection">C.11.6 Style</h4>
<p>The name of the subrule “casing” has been changed to
“casing_identifier” since the casing of attributes and pragmas can
now also be checked. The casing style is no more optional.
</p>
<p>The name of the subrule “literal” has been changed to
“numeric_literal” (since characters and strings are also literals,
but are not handled by this subrule).
</p>
<p>The subrule “exposed_literal” now requires an extra parameter to
tell whether it applies to integer literals, real literals, character
literals or string literals. Allowed values are provided after this
parameter, and must of course be of the appropriate type. In short, if
you had:
</p><div class="example">
<pre class="example">check style (exposed_literal, 0, 1, 0.0, 1.0);
</pre></div>
<p>you must change it to:
</p><div class="example">
<pre class="example">check style (exposed_literal, integer, 0, 1)
check style (exposed_literal, real, 0.0, 1.0);
</pre></div>
<p>The “aggregate” parameter of the subrule “positional_association”
has been split into “array_aggregate” and “record_aggregate”. For example,
change:
</p><div class="example">
<pre class="example">check style (positional_association, aggregate);
</pre></div>
<p>into:
</p><div class="example">
<pre class="example">check style (positional_association, record_aggregate, array_aggregate);
</pre></div>
<a name="Migrating-from-1_002e4r20"></a>
<h3 class="section">C.12 Migrating from 1.4r20</h3>
<a name="GPS-integration-1"></a>
<h4 class="subsection">C.12.1 GPS integration</h4>
<p>The XML file used to describe AdaControl features to GPS used to be
called <code>adactl.xml</code>. It is now called <code>zadactl.xml</code>, since
GPS processes its initialization files in alphabetical order. This
avoids shuffling the menus when AdaControl support is activated.
</p>
<p>Make sure to remove the old <code>adactl.xml</code> file from the GPS
plug-ins directory before installing the new version.
</p>
<a name="Declarations-4"></a>
<h4 class="subsection">C.12.2 Declarations</h4>
<p>The parameters “access” and “access_subprogram” have been changed
to “access_type” and “access_subprogram_type”, for consistency
with the new parameters.
</p>
<a name="Header_005fComments-2"></a>
<h4 class="subsection">C.12.3 Header_Comments</h4>
<p>A keyword has been added to specify the required number of comment lines.
Change:
</p><div class="example">
<pre class="example">check Header_Comments (10);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check Header_Comments (minimum, 10);
</pre></div>
<a name="No_005fClosing_005fName"></a>
<h4 class="subsection">C.12.4 No_Closing_Name</h4>
<p>This rule is now part of the “style” rule. Change:
</p><div class="example">
<pre class="example">check|search|count No_Closing_Name;
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check|search|count Style (No_Closing_Name);
</pre></div>
<a name="Specification_005fObjects"></a>
<h4 class="subsection">C.12.5 Specification_Objects</h4>
<p>This rule is now part of the “usage” rule. Change:
</p><div class="example">
<pre class="example">check|search|count Specification_Objects (<parameters>);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check|search|count Usage (Object, From_Spec, <parameters>);
</pre></div>
<a name="Statement"></a>
<h4 class="subsection">C.12.6 Statement</h4>
<p>Name changed from “statement” to “statements” (added an ’s’), to
be consistent with other rules.
</p>
<a name="When_005fOthers_005fNull"></a>
<h4 class="subsection">C.12.7 When_Others_Null</h4>
<p>This rule is now part of the “statements” rule. Change:
</p><div class="example">
<pre class="example">check|search|count When_Others_Null (case);
check|search|count When_Others_Null (exception);
</pre></div>
<p>to:
</p><div class="example">
<pre class="example">check|search|count Statements (case_others_null);
check|search|count Statements (exception_others_null);
</pre></div>
<hr>
</body>
</html>
|