2
0
Эх сурвалжийг харах

* make result of not(constant) (with constant type <= sinttype)
equal to sinttype (Delphi-compatible, fixes #10966)
* changed not(cardinal_constant) into sinttype on 64 bit
platforms for consistency with other similar rules (and with
the above change)

git-svn-id: trunk@10455 -

Jonas Maebe 17 жил өмнө
parent
commit
931aef4daa

+ 1 - 0
.gitattributes

@@ -8010,6 +8010,7 @@ tests/webtbs/tw1092.pp svneol=native#text/plain
 tests/webtbs/tw10920.pp svneol=native#text/plain
 tests/webtbs/tw10920.pp svneol=native#text/plain
 tests/webtbs/tw10931.pp svneol=native#text/plain
 tests/webtbs/tw10931.pp svneol=native#text/plain
 tests/webtbs/tw1096.pp svneol=native#text/plain
 tests/webtbs/tw1096.pp svneol=native#text/plain
+tests/webtbs/tw10966.pp svneol=native#text/plain
 tests/webtbs/tw1097.pp svneol=native#text/plain
 tests/webtbs/tw1097.pp svneol=native#text/plain
 tests/webtbs/tw1103.pp svneol=native#text/plain
 tests/webtbs/tw1103.pp svneol=native#text/plain
 tests/webtbs/tw1104.pp svneol=native#text/plain
 tests/webtbs/tw1104.pp svneol=native#text/plain

+ 10 - 2
compiler/nmat.pas

@@ -800,12 +800,20 @@ implementation
                u16bit,
                u16bit,
                s16bit,
                s16bit,
                s32bit,
                s32bit,
+{$ifdef cpu64bitaddr}
+               u32bit,
+{$endif cpu64bitaddr}
                s64bit:
                s64bit:
                  begin
                  begin
-                   v:=int64(not int64(v)); { maybe qword is required }
-                   int_to_type(v,def);
+                   v:=int64(not int64(v));
+                   if (torddef(left.resultdef).ordtype<>s64bit) then
+                     def:=sinttype
+                   else
+                     def:=s64inttype;
                  end;
                  end;
+{$ifndef cpu64bitaddr}
                u32bit,
                u32bit,
+{$endif not cpu64bitaddr}
                u64bit :
                u64bit :
                  begin
                  begin
                    { Delphi-compatible: not dword = dword (not word = longint) }
                    { Delphi-compatible: not dword = dword (not word = longint) }

+ 25 - 0
tests/webtbs/tw10966.pp

@@ -0,0 +1,25 @@
+{$r+}
+
+const
+  ctnsNeedJITParsing  = 1 shl 1;
+type
+  TCodeTreeNodeSubDesc = word;    
+var
+  SubDesc: TCodeTreeNodeSubDesc;
+  l: longint;
+//  c: cardinal;
+begin
+  SubDesc := 1;
+// fails
+//  SubDesc := not 2;
+  l := not(2);
+// fails
+//  c := not(2);
+  l := not ctnsNeedJITParsing;
+// fails
+//  c := not ctnsNeedJITParsing;
+  SubDesc := SubDesc and (not 2);
+  SubDesc := SubDesc and (not (1 shl 1));
+  SubDesc := SubDesc and (not ctnsNeedJITParsing);
+end.
+