toperator6.pp 711 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. {$mode objfpc}
  2. {$R+}
  3. type Tconstexprint=record
  4. overflow:boolean;
  5. case signed:boolean of
  6. false:
  7. (uvalue:qword);
  8. true:
  9. (svalue:int64);
  10. end;
  11. operator := (const u:qword):Tconstexprint;
  12. begin
  13. if (u<>high(int64)+100) then
  14. halt(1);
  15. result.overflow:=false;
  16. result.signed:=false;
  17. result.uvalue:=u;
  18. end;
  19. operator := (const s:int64):Tconstexprint;
  20. begin
  21. if (s<>-128) then
  22. halt(2);
  23. result.overflow:=false;
  24. result.signed:=true;
  25. result.svalue:=s;
  26. end;
  27. var
  28. value : tconstexprint;
  29. begin
  30. // Here it should choose the int64 code instead of qword
  31. value:=-128;
  32. // Here it should choose the qword
  33. value:=high(int64)+100;
  34. end.