Skip to content

Tests for 'use type' & 'use all type' clause #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package body Count_Types is

function Double (X : in out Counter) return Counter is
begin
return X*2;
end Double;

end Count_Types;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package Count_Types is

type Count is new Integer;

type Counter is new Integer;
function Double (X : in out Counter) return Counter;

end Count_Types;

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
VERIFICATION SUCCESSFUL
Error from cbmc use_type_clause:
**** WARNING: no body for function count_types__double

[1] file use_type_clause.adb line 21 assertion: SUCCESS
[2] file use_type_clause.adb line 24 assertion: FAILURE
VERIFICATION FAILED
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- NB our package implementation does not support function calls atm, so
-- although 'use type' can work fully if only built-in operators are used,
-- any use of functions or overloaded operators or new 'basic operations'
-- for a custom type will fail.
----------------------------------------------------------------------

-- 'use type' clause makes visible only the operators associated with a type
-- (NB but not the type itself, this must still be fully qualified
with Count_Types; use type Count_Types.Count;

-- 'use all type' clause makes visible both the operators and primitive
-- operations associated with a type (NB but not the type itself, this must
-- still be fully qualified)
with Count_Types; use all type Count_Types.Counter;

procedure Use_Type_Clause is
A : Count_Types.Count := 1;

B : Count_Types.Counter :=1;
begin
pragma Assert (A=1);

B := Double(B); -- Double is visible due to the 'use all type' clause
pragma Assert(B=2);
end Use_Type_Clause;