Skip to content

Commit 821350a

Browse files
authored
Merge pull request #160 from sonodtt/use_type_clause
Tests for 'use type' & 'use all type' clause
2 parents 22bbe07 + 634af76 commit 821350a

File tree

7 files changed

+48
-12
lines changed

7 files changed

+48
-12
lines changed

testsuite/gnat2goto/tests/package_use_type_N_Use_Type_Clause/Use_Type_Clause.adb

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package body Count_Types is
2+
3+
function Double (X : in out Counter) return Counter is
4+
begin
5+
return X*2;
6+
end Double;
7+
8+
end Count_Types;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package Count_Types is
2+
3+
type Count is new Integer;
4+
5+
type Counter is new Integer;
6+
function Double (X : in out Counter) return Counter;
7+
8+
end Count_Types;

testsuite/gnat2goto/tests/package_use_type_N_Use_Type_Clause/external_types.ads

-3
This file was deleted.

testsuite/gnat2goto/tests/package_use_type_N_Use_Type_Clause/test.opt

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
VERIFICATION SUCCESSFUL
2+
Error from cbmc use_type_clause:
3+
**** WARNING: no body for function count_types__double
4+
5+
[1] file use_type_clause.adb line 21 assertion: SUCCESS
6+
[2] file use_type_clause.adb line 24 assertion: FAILURE
7+
VERIFICATION FAILED
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- NB our package implementation does not support function calls atm, so
2+
-- although 'use type' can work fully if only built-in operators are used,
3+
-- any use of functions or overloaded operators or new 'basic operations'
4+
-- for a custom type will fail.
5+
----------------------------------------------------------------------
6+
7+
-- 'use type' clause makes visible only the operators associated with a type
8+
-- (NB but not the type itself, this must still be fully qualified
9+
with Count_Types; use type Count_Types.Count;
10+
11+
-- 'use all type' clause makes visible both the operators and primitive
12+
-- operations associated with a type (NB but not the type itself, this must
13+
-- still be fully qualified)
14+
with Count_Types; use all type Count_Types.Counter;
15+
16+
procedure Use_Type_Clause is
17+
A : Count_Types.Count := 1;
18+
19+
B : Count_Types.Counter :=1;
20+
begin
21+
pragma Assert (A=1);
22+
23+
B := Double(B); -- Double is visible due to the 'use all type' clause
24+
pragma Assert(B=2);
25+
end Use_Type_Clause;

0 commit comments

Comments
 (0)