-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointers2.adb
65 lines (48 loc) · 1.11 KB
/
pointers2.adb
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
package Pointers2 with
SPARK_Mode
is
type Int_Ptr is access Integer;
procedure Bad_Swap (X, Y : in out Int_Ptr);
procedure Swap (X, Y : in out Int_Ptr);
X, Y : Int_Ptr;
procedure Bad_Swap_Global with
Global => (In_Out => (X, Y));
procedure Swap_Global with
Global => (In_Out => (X, Y));
procedure Bad_Borrow (X, Y : in out Int_Ptr);
procedure Bad_Move (X, Y : in out Int_Ptr);
end Pointers2;
package body Pointers2 with
SPARK_Mode
is
procedure Bad_Swap (X, Y : in out Int_Ptr) is
begin
X := Y;
end Bad_Swap;
procedure Swap (X, Y : in out Int_Ptr) is
Tmp : Int_Ptr := X;
begin
X := Y;
Y := Tmp;
end Swap;
procedure Bad_Swap_Global is
begin
X := Y;
end Bad_Swap_Global;
procedure Swap_Global is
Tmp : Int_Ptr := X;
begin
X := Y;
Y := Tmp;
end Swap_Global;
procedure Bad_Borrow (X, Y : in out Int_Ptr) is
begin
X := Y;
Swap (X, Y);
end Bad_Borrow;
procedure Bad_Move (X, Y : in out Int_Ptr) is
begin
X := Y;
X := Y;
end Bad_Move;
end Pointers2;