Skip to content

Commit 1a0e45d

Browse files
committed
Merge branch 'topic/416' into 'master'
KP-19501: add similar tests using Ada95 pragmas instead of Ada2012 aspects Closes #416 See merge request eng/libadalang/langkit-query-language!408
2 parents 47197ef + 97cd883 commit 1a0e45d

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
-- Same tests as for main.adb but using pragmas instead of
2+
-- Static/Dynamic_Predicate aspects.
3+
procedure Main95 is
4+
function Id (I : Integer) return Integer is (I);
5+
6+
type Arr is array (Integer range <>) of Integer;
7+
subtype Stat_Arr is Arr (1 .. 10);
8+
subtype Dyn_Arr is Arr (1 .. Id (10));
9+
type Multidim_Dyn_Arr is array (1 .. 10, 1 .. Id (10)) of Integer;
10+
11+
subtype Stat_Int is Integer range 1 .. 10;
12+
subtype Dyn_Int is Integer range Id (1) .. Id (10);
13+
14+
subtype Stat_Pred_Int is Integer;
15+
pragma Predicate (Entity => Stat_Pred_Int, Check => Stat_Pred_Int in 1 .. 10);
16+
subtype Dyn_Pred_Int is Integer;
17+
pragma Predicate (Entity => Dyn_Pred_Int, Check => Dyn_Pred_Int < Id(50));
18+
19+
S : String := "Hello";
20+
C_S : constant String := "world";
21+
22+
procedure Process_Int (I : Integer) is
23+
begin
24+
null;
25+
end Process_Int;
26+
27+
procedure Process_Stat_Int (I : Stat_Int) is
28+
begin
29+
null;
30+
end Process_Stat_Int;
31+
32+
procedure Process_Dyn_Int (I : Dyn_Int) is
33+
begin
34+
null;
35+
end Process_Dyn_Int;
36+
37+
procedure Process_Stat_Pred_Int (I : Stat_Pred_Int) is
38+
begin
39+
null;
40+
end Process_Stat_Pred_Int;
41+
42+
procedure Process_Dyn_Pred_Int (I : Dyn_Pred_Int) is
43+
begin
44+
null;
45+
end Process_Dyn_Pred_Int;
46+
47+
procedure Process_Multiple (I : Dyn_Pred_Int; J : Stat_Pred_Int) is
48+
begin
49+
null;
50+
end Process_Multiple;
51+
52+
Stat_Assign : Stat_Int;
53+
Dyn_Assign : Dyn_Int;
54+
55+
Stat_Index : Stat_Arr;
56+
Dyn_Index : Dyn_Arr;
57+
Mult_Index : Multidim_Dyn_Arr;
58+
59+
Qual_Expr_1 : Stat_Int := Stat_Int'(C_S'Length); -- NOFLAG
60+
Qual_Expr_2 : Dyn_Int := Dyn_Int'(S'Length); -- NOFLAG
61+
Qual_Expr_3 : Dyn_Int := Dyn_Int'(C_S'Length); -- FLAG
62+
Qual_Expr_4 : Dyn_Int := Dyn_Int'(C_S'Size); -- NOFLAG
63+
begin
64+
Process_Int (S'Length); -- NOFLAG
65+
Process_Int (C_S'Length); -- NOFLAG
66+
Process_Stat_Int (S'Length); -- NOFLAG
67+
Process_Stat_Int (C_S'Length); -- NOFLAG
68+
Process_Dyn_Int (S'Length); -- NOFLAG
69+
Process_Dyn_Int (C_S'Length); -- FLAG
70+
Process_Dyn_Int (C_S'Size); -- NOFLAG
71+
Process_Stat_Pred_Int (S'Length); -- NOFLAG
72+
Process_Stat_Pred_Int (C_S'Length); -- NOFLAG
73+
Process_Dyn_Pred_Int (S'Length); -- NOFLAG
74+
Process_Dyn_Pred_Int (C_S'Length); -- FLAG
75+
Process_Dyn_Pred_Int (C_S'Size); -- NOFLAG
76+
77+
Process_Multiple (S'Length, S'Size); -- NOFLAG
78+
Process_Multiple (C_S'Length, C_S'Size); -- FLAG
79+
80+
Stat_Assign := S'Length; -- NOFLAG
81+
Stat_Assign := C_S'Length; -- NOFLAG
82+
Dyn_Assign := S'Length; -- NOFLAG
83+
Dyn_Assign := C_S'Length; -- FLAG
84+
Dyn_Assign := C_S'Size; -- NOFLAG
85+
86+
Stat_Index (S'Length) := 10; -- NOFLAG
87+
Stat_Index (C_S'Length) := 10; -- NOFLAG
88+
Dyn_Index (S'Length) := 10; -- NOFLAG
89+
Dyn_Index (C_S'Length) := 10; -- FLAG
90+
Dyn_Index (C_S'Size) := 10; -- NOFLAG
91+
Dyn_Index (1) := 10; -- NOFLAG
92+
Mult_Index (1, S'Length) := 10; -- NOFLAG
93+
Mult_Index (1, C_S'Length) := 10; -- FLAG
94+
Mult_Index (1, C_S'Size) := 10; -- NOFLAG
95+
Mult_Index (C_S'Length, 1) := 10; -- FLAG
96+
Mult_Index (1, 1) := 10; -- NOFLAG
97+
end Main95;

testsuite/tests/checks/KP-19501/test.out

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,35 @@ main.adb:93:4: rule violation: possible occurrence of KP 19501
3030
93 | Mult_Index (C_S'Length, 1) := 10; -- FLAG
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
3232

33+
main95.adb:61:29: rule violation: possible occurrence of KP 19501
34+
61 | Qual_Expr_3 : Dyn_Int := Dyn_Int'(C_S'Length); -- FLAG
35+
| ^^^^^^^^^^^^^^^^^^^^
36+
37+
main95.adb:69:4: rule violation: possible occurrence of KP 19501
38+
69 | Process_Dyn_Int (C_S'Length); -- FLAG
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40+
41+
main95.adb:74:4: rule violation: possible occurrence of KP 19501
42+
74 | Process_Dyn_Pred_Int (C_S'Length); -- FLAG
43+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44+
45+
main95.adb:78:4: rule violation: possible occurrence of KP 19501
46+
78 | Process_Multiple (C_S'Length, C_S'Size); -- FLAG
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48+
49+
main95.adb:83:4: rule violation: possible occurrence of KP 19501
50+
83 | Dyn_Assign := C_S'Length; -- FLAG
51+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
52+
53+
main95.adb:89:4: rule violation: possible occurrence of KP 19501
54+
89 | Dyn_Index (C_S'Length) := 10; -- FLAG
55+
| ^^^^^^^^^^^^^^^^^^^^^^
56+
57+
main95.adb:93:4: rule violation: possible occurrence of KP 19501
58+
93 | Mult_Index (1, C_S'Length) := 10; -- FLAG
59+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
60+
61+
main95.adb:95:4: rule violation: possible occurrence of KP 19501
62+
95 | Mult_Index (C_S'Length, 1) := 10; -- FLAG
63+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
64+

0 commit comments

Comments
 (0)