File: hardbool.adb

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (46 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download
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
-- { dg-do compile }
-- { dg-options "-O -gnatVT -fdump-tree-optimized" }

--  Check that we perform the expected validity checks for
--  hardbool-annotated types, even when checking of tests is disabled.

package body Hardbool is
   function T return Boolean is (Boolean (X) and then Boolean (Y));

   procedure P1 is
   begin
      X := HBool1 (not Y);
   end P1;

   procedure P2 is
   begin
      X := HBool1 (if Y then HBool2'(False) else HBool2'(True));
   end P2;

   procedure P3 is
   begin
      X := (if Y then HBool1'(False) else HBool1'(True));
   end P3;

   procedure Q1 is
   begin
      Y := HBool2 (not X);
   end Q1;

   procedure Q2 is
   begin
      Y := HBool2 (if X then HBool1'(False) else HBool1'(True));
   end Q2;

   procedure Q3 is
   begin
      Y := (if X then HBool2'(False) else HBool2'(True));
   end Q3;

end Hardbool;

-- One for each type's _rep_to_pos function.
-- { dg-final { scan-tree-dump-times "gnat_rcheck_CE_Invalid_Data ..hardbool.ads" 2 "optimized" } }

-- One check for each variable used in T, one use in each P* and in each Q*.
-- { dg-final { scan-tree-dump-times "gnat_rcheck_CE_Invalid_Data ..hardbool.adb" 8 "optimized" } }