فهرست منبع

* handle result type of unsigned ordinal operations in ISO/Extpas mode similiar to TP, solves
#37875

florian 3 سال پیش
والد
کامیت
f21f7f0f50
2فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 1 0
      compiler/nadd.pas
  2. 10 0
      tests/webtbs/tw37875.pp

+ 1 - 0
compiler/nadd.pas

@@ -2516,6 +2516,7 @@ implementation
                    the result also unsigned. This is compatible with Delphi (PFV) }
                  if is_signed(ld) or
                     is_signed(rd) or
+                    (([m_iso,m_extpas]*current_settings.modeswitches)<>[]) or
 {$if defined(cpu16bitalu)}
                     (m_tp7 in current_settings.modeswitches) or
 {$endif}

+ 10 - 0
tests/webtbs/tw37875.pp

@@ -0,0 +1,10 @@
+{$MODE ISO}
+{$Q+}
+program nabs(input, output);
+  type halfword = 0..65535;
+  var a, b: halfword;
+begin
+  a := 4095;
+  b := 4096;
+  if abs(int(a+b-8192)) < 4096 then halt(0) else halt(1);
+end.