Forráskód Böngészése

* transform -x-1 into not(x), resolves #40313

florian 1 éve
szülő
commit
59c77a48b5
2 módosított fájl, 16 hozzáadás és 0 törlés
  1. 7 0
      compiler/nadd.pas
  2. 9 0
      tests/tbs/tb0711.pp

+ 7 - 0
compiler/nadd.pas

@@ -932,6 +932,13 @@ implementation
                 left:=nil;
                 tmoddivnode(right).right:=nil;
                 exit;
+              end
+
+            { transform -x-1 into not(x) }
+            else if is_signed(ld) and is_constintnode(right) and (tordconstnode(right).value=1) and (left.nodetype=unaryminusn) then
+              begin
+                result:=cnotnode.create(tunaryminusnode(left).left.getcopy);
+                exit;
               end;
           end;
 

+ 9 - 0
tests/tbs/tb0711.pp

@@ -0,0 +1,9 @@
+var
+  l : longint;
+
+begin
+  l:=1234;
+
+  if -l-1<>-1235 then
+    halt(1);
+end.