aboutsummaryrefslogtreecommitdiff
path: root/testsuite/runnable/record_layout.elna
blob: 180d7bc6f4b40945d32ee862a7833df08863a5c5 (plain)
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
47
48
49
50
51
52
53
54
55
type
  IntChar = record
    x: Int;
    y: Char
  end
  CharInt = record
    c: Char;
    i: Int
  end
  Base = record
    x: Int
  end
  Derived = record(Base)
    y: Char
  end
  ArrayRecord = record
    a: [3]Int;
    c: Char
  end

proc f()
var
  int_size: const Word := #size(Int)

  int_char_size: const Word := #size(IntChar)
  int_char_y_offset: const Word := #offset(IntChar, y)
  char_int_size: const Word := #size(CharInt)
  char_int_c_offset: const Word := #offset(CharInt, c)
  char_int_i_offset: const Word := #offset(CharInt, i)
  derived_size: const Word := #size(Derived)
  derived_x_offset: const Word := #offset(Derived, x)
  derived_y_offset: const Word := #offset(Derived, y)
  array_record_size: const Word := #size(ArrayRecord)
  array_record_a_offset: const Word := #offset(ArrayRecord, a)
  array_record_c_offset: const Word := #offset(ArrayRecord, c)
begin
  assert(int_char_y_offset = int_size);
  assert(int_char_size = 2u * int_size);

  assert(char_int_c_offset = 0u);
  assert(char_int_i_offset = int_size);
  assert(char_int_size = 2u * int_size);

  assert(derived_x_offset = 0u);
  assert(derived_y_offset = int_size);
  assert(derived_size = 2u * int_size);

  assert(array_record_size = 4u * int_size);
  assert(array_record_a_offset = 0u);
  assert(array_record_c_offset = 3u * int_size)
return

begin
  f()
end.