Kaynağa Gözat

Merge branch source:main into main

Curtis Hamilton 3 gün önce
ebeveyn
işleme
9ee6322e68
2 değiştirilmiş dosya ile 5 ekleme ve 1 silme
  1. 4 0
      compiler/nadd.pas
  2. 1 1
      compiler/nmat.pas

+ 4 - 0
compiler/nadd.pas

@@ -1018,6 +1018,10 @@ const
                   result := ctypeconvnode.create_internal(cunaryminusnode.create(right.getcopy),right.resultdef);
                   result := ctypeconvnode.create_internal(cunaryminusnode.create(right.getcopy),right.resultdef);
               end
               end
 
 
+            { change "nil - val" to "-val" }
+            else if (left.nodetype=niln) and is_pointer(right.resultdef) then
+              result := ctypeconvnode.create_internal(cunaryminusnode.create(ctypeconvnode.create_internal(right.getcopy,resultdef)),resultdef)
+
             { convert n - n mod const into n div const*const }
             { convert n - n mod const into n div const*const }
             else if (right.nodetype=modn) and is_constintnode(tmoddivnode(right).right) and
             else if (right.nodetype=modn) and is_constintnode(tmoddivnode(right).right) and
               (left.isequal(tmoddivnode(right).left)) and not(might_have_sideeffects(left)) { and
               (left.isequal(tmoddivnode(right).left)) and not(might_have_sideeffects(left)) { and

+ 1 - 1
compiler/nmat.pas

@@ -1013,7 +1013,7 @@ implementation
 
 
     constructor tunaryminusnode.create(expr : tnode);
     constructor tunaryminusnode.create(expr : tnode);
       begin
       begin
-         inherited create(unaryminusn,expr);
+        inherited create(unaryminusn,expr);
       end;
       end;