File tree 7 files changed +56
-12
lines changed
testsuite/gnat2goto/tests/package_use_type_N_Use_Type_Clause
7 files changed +56
-12
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ package body Count_Types is
2
+ -- ----------------------------------------------------------
3
+ function "=" (X : Counter; Y: Integer) return Boolean is
4
+ begin
5
+ if X.Value = Y then
6
+ return True;
7
+ else
8
+ return False;
9
+ end if ;
10
+ end "=" ;
11
+ -- ----------------------------------------------------------
12
+ function Double (X : in out Counter) return Counter is
13
+ begin
14
+ X.Value := X.Value + X.Value;
15
+ -- return X.Value + X.Value;
16
+ return X;
17
+ end Double ;
18
+ -- ----------------------------------------------------------
19
+ end Count_Types ;
Original file line number Diff line number Diff line change
1
+ package Count_Types is
2
+ type Count is new Integer;
3
+ -- ----------------------------------------------------------
4
+ type Counter is
5
+ record
6
+ Value : Integer := 1 ;
7
+ end record ;
8
+
9
+ function "=" (X : Counter; Y : Integer) return Boolean;
10
+
11
+ function Double (X : in out Counter) return Counter;
12
+ -- ----------------------------------------------------------
13
+ end Count_Types ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ **** WARNING: no body for function count_types__double
2
+ [1] file use_type_clause.adb line 16 assertion: SUCCESS
3
+ VERIFICATION SUCCESSFUL
Original file line number Diff line number Diff line change
1
+ -- 'use type' clause makes visible only the operators associated with a type
2
+ -- (NB but not the type itself, this must still be fully qualified
3
+ with Count_Types ; use type Count_Types.Count;
4
+
5
+ -- 'use all type' clause makes visible both the operators and primitive
6
+ -- operations associated with a type (NB but not the type itself, this must
7
+ -- still be fully qualified)
8
+ with Count_Types ; use all type Count_Types.Counter;
9
+
10
+ procedure Use_Type_Clause is
11
+ A : Count_Types.Count := 1 ;
12
+
13
+ B : Count_Types.Counter;
14
+ C : Count_Types.Counter;
15
+ begin
16
+ pragma Assert (A=1 );
17
+
18
+ C := Double(B); -- Double is accessible due to 'use all type' clause
19
+ -- next statement would fail as packages do not support function calls atm
20
+ -- pragma Assert (C=2);
21
+ end Use_Type_Clause ;
You can’t perform that action at this time.
0 commit comments