Debian Codegraph @

gcc/testsuite/gm2/extensions/run/pass/packedrecord2.mod

raw
1 (* Copyright (C) 2015, 2016, 2017
2 Free Software Foundation, Inc. *)
3 (* This file is part of GNU Modula-2.
4
5 GNU Modula-2 is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3, or (at your option) any later
8 version.
9
10 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with gm2; see the file COPYING. If not, write to the Free Software
17 Foundation, 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA. *)
19
20 MODULE packedrecord2 ;
21
22 FROM libc IMPORT printf, exit ;
23 FROM SYSTEM IMPORT SIZE, BYTE ;
24
25
26 TYPE
27 Colour = (white, black) ;
28 HeapOpcode = (move, take, begin, end, add, del) ;
29 PieceNo = [0..15] ;
30
31 Instruction = RECORD
32 <* bytealignment(0) *>
33 o: [move..del] ; (* 3 bits *)
34 c: [white..black] ; (* 1 bit *)
35 n: PieceNo ; (* 4 bits *)
36 END ;
37
38 (*
39 assert -
40 *)
41
42 PROCEDURE assert (b: BOOLEAN) ;
43 BEGIN
44 IF NOT b
45 THEN
46 printf ("assert failed\n");
47 exit (1)
48 END
49 END assert ;
50
51
52 VAR
53 i: Instruction ;
54 BEGIN
55 printf ("size of 'i' is %d byte(s)\n", SIZE (i)) ;
56 assert (SIZE (i) = SIZE (BYTE))
57 END packedrecord2.