Quellcode durchsuchen

Merged revisions 1107-1108 via svnmerge from
/trunk

git-svn-id: branches/fixes_2_0@1136 -

peter vor 20 Jahren
Ursprung
Commit
860472f073
4 geänderte Dateien mit 60 neuen und 12 gelöschten Zeilen
  1. 2 0
      .gitattributes
  2. 16 12
      compiler/nadd.pas
  3. 12 0
      tests/tbs/tb0494.pp
  4. 30 0
      tests/tbs/tb0495.pp

+ 2 - 0
.gitattributes

@@ -4781,6 +4781,8 @@ tests/tbs/tb0490.pp svneol=native#text/plain
 tests/tbs/tb0491.pp svneol=native#text/plain
 tests/tbs/tb0492.pp svneol=native#text/plain
 tests/tbs/tb0493.pp svneol=native#text/plain
+tests/tbs/tb0494.pp -text
+tests/tbs/tb0495.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain

+ 16 - 12
compiler/nadd.pas

@@ -1072,20 +1072,24 @@ implementation
                 inserttypeconv(right,left.resulttype);
              end;
           end
-
-         { compare pchar to char arrays by addresses like BP/Delphi }
-         else if ((is_pchar(ld) or (lt=niln)) and is_chararray(rd)) or
-                 ((is_pchar(rd) or (rt=niln)) and is_chararray(ld)) then
-           begin
-             if is_chararray(rd) then
-              inserttypeconv(right,charpointertype)
-             else
-              inserttypeconv(left,charpointertype);
-           end
-
          { pointer comparision and subtraction }
-         else if (rd.deftype=pointerdef) and (ld.deftype=pointerdef) then
+         else if ((rd.deftype=pointerdef) and (ld.deftype=pointerdef)) or
+                 { compare pchar to char arrays by addresses like BP/Delphi }
+                 ((is_pchar(ld) or (lt=niln)) and is_chararray(rd)) or
+                 ((is_pchar(rd) or (rt=niln)) and is_chararray(ld)) then
           begin
+            { convert char array to pointer }
+            if is_chararray(rd) then
+              begin
+                inserttypeconv(right,charpointertype);
+                rd:=right.resulttype.def;
+              end
+            else if is_chararray(ld) then
+              begin
+                inserttypeconv(left,charpointertype);
+                ld:=left.resulttype.def;
+              end;
+
             case nodetype of
                equaln,unequaln :
                  begin

+ 12 - 0
tests/tbs/tb0494.pp

@@ -0,0 +1,12 @@
+{ the test checks only if the syntax is possible }
+var
+  ca : array[0..1000] of char;
+  p1 : pchar;
+
+begin
+  p1:=nil;
+  if (ca-p1)=0 then
+    halt(1); 
+  p1:=ca;
+end.
+   

+ 30 - 0
tests/tbs/tb0495.pp

@@ -0,0 +1,30 @@
+{ %cpu=i386 }
+{$asmmode intel}
+var
+  Digits : array[0..63] of byte;
+type
+  PBcd = ^TBcd;
+  TBcd  = packed record
+    Precision: Byte;                        { 1..64 }
+    SignSpecialPlaces: Byte;                { Sign:1, Special:1, Places:6 }
+    Fraction: packed array [0..31] of Byte; { BCD Nibbles, 00..99 per Byte, high Nibble 1st }
+  end;
+
+var
+  c : currency;
+  bcd : TBcd;
+
+begin
+  c:=1;
+  asm
+    lea esi,c
+    fild [esi].currency
+
+    lea esi,bcd
+    mov [esi].TBcd.SignSpecialPlaces,dl
+
+    mov eax,3
+    mov digits.byte[eax],0
+    mov digits.word[eax],0
+  end
+end.