Browse Source

* properly simplify not(<const. cbool>), resolves #25255

git-svn-id: trunk@26803 -
florian 11 years ago
parent
commit
6e1bf4d040
3 changed files with 17 additions and 4 deletions
  1. 1 0
      .gitattributes
  2. 6 4
      compiler/nmat.pas
  3. 10 0
      tests/webtbs/tw25255.pp

+ 1 - 0
.gitattributes

@@ -13802,6 +13802,7 @@ tests/webtbs/tw25170.pp svneol=native#text/plain
 tests/webtbs/tw25198.pp svneol=native#text/plain
 tests/webtbs/tw25198.pp svneol=native#text/plain
 tests/webtbs/tw25210.pp svneol=native#text/pascal
 tests/webtbs/tw25210.pp svneol=native#text/pascal
 tests/webtbs/tw2525.pp svneol=native#text/plain
 tests/webtbs/tw2525.pp svneol=native#text/plain
+tests/webtbs/tw25255.pp svneol=native#text/pascal
 tests/webtbs/tw25269.pp svneol=native#text/pascal
 tests/webtbs/tw25269.pp svneol=native#text/pascal
 tests/webtbs/tw25289.pp svneol=native#text/plain
 tests/webtbs/tw25289.pp svneol=native#text/plain
 tests/webtbs/tw25296.pp svneol=native#text/plain
 tests/webtbs/tw25296.pp svneol=native#text/plain

+ 6 - 4
compiler/nmat.pas

@@ -1074,15 +1074,17 @@ implementation
                pasbool8,
                pasbool8,
                pasbool16,
                pasbool16,
                pasbool32,
                pasbool32,
-               pasbool64,
+               pasbool64:
+                 v:=byte(not(boolean(int64(v))));
                bool8bit,
                bool8bit,
                bool16bit,
                bool16bit,
                bool32bit,
                bool32bit,
                bool64bit:
                bool64bit:
                  begin
                  begin
-                   v:=byte(not(boolean(int64(v))));
-                   if is_cbool(left.resultdef) then
-                     v:=-v;
+                   if v=0 then
+                     v:=-1
+                   else
+                     v:=0;
                  end;
                  end;
                uchar,
                uchar,
                uwidechar,
                uwidechar,

+ 10 - 0
tests/webtbs/tw25255.pp

@@ -0,0 +1,10 @@
+begin
+  if not(qwordbool($8000000000000000)) then
+    halt(1);
+  if not(longbool($80000000)) then
+    halt(1);
+  if not(wordbool($8000)) then
+    halt(1);
+  writeln('ok');
+end.
+