tprec8.pp 938 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. {$bitpacking on}
  2. type
  3. tenum = (ea,eb,ec,ed,ee,ef,eg,eh);
  4. tr = packed record
  5. a: 0..3; // 2 bits
  6. i: int64;
  7. c: boolean; // 1 bit
  8. d: 0..31; // 5 bits
  9. e: tenum; // 3 bits
  10. case byte of
  11. 0: (g: 0..7);
  12. 1: (h: 0..65536; k: boolean);
  13. 2: (j: boolean);
  14. end;
  15. procedure t(var r2: tr);
  16. var
  17. r: tr;
  18. begin
  19. r.a := 2;
  20. r.i := 1234567890123456789;
  21. r.c := true;
  22. r.d := 5;
  23. r.e := ed;
  24. r2 := r;
  25. end;
  26. var
  27. r: tr;
  28. b: byte;
  29. begin
  30. b := 0;
  31. t(r);
  32. if (r.a <> 2) or
  33. (r.i <> 1234567890123456789) or
  34. (not r.c) or
  35. (r.d <> 5) or
  36. (r.e <> ed) then
  37. halt(1);
  38. r.g := 5;
  39. if (r.g <> 5) then
  40. halt(1);
  41. r.h := 65535;
  42. if (r.h <> 65535) then
  43. halt(1);
  44. r.k := true;
  45. if not (r.k) then
  46. halt(1);
  47. r.j := false;
  48. if r.j then
  49. halt(1);
  50. if b <> 0 then
  51. halt(1);
  52. if sizeof(tr) <> 13 then
  53. halt(2);
  54. end.