소스 검색

Merged revisions 10450,10455 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r10450 | jonas | 2008-03-06 21:29:27 +0100 (Thu, 06 Mar 2008) | 2 lines

* fixed constant evaluation of not(byte/word/long/quadbool) + test

........
r10455 | jonas | 2008-03-07 17:33:15 +0100 (Fri, 07 Mar 2008) | 6 lines

* 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: branches/fixes_2_2@10982 -

Jonas Maebe 17 년 전
부모
커밋
0b8e4777c9
4개의 변경된 파일50개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 0
      .gitattributes
  2. 18 4
      compiler/nmat.pas
  3. 6 1
      tests/test/cg/tnot.pp
  4. 25 0
      tests/webtbs/tw10966.pp

+ 1 - 0
.gitattributes

@@ -7980,6 +7980,7 @@ tests/webtbs/tw1092.pp svneol=native#text/plain
 tests/webtbs/tw10920.pp svneol=native#text/plain
 tests/webtbs/tw10927.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/tw10979.pp svneol=native#text/plain
 tests/webtbs/tw10998.pp svneol=native#text/plain

+ 18 - 4
compiler/nmat.pas

@@ -844,13 +844,27 @@ implementation
                s8bit,
                u16bit,
                s16bit,
-               u32bit,
                s32bit,
-               s64bit,
+{$ifdef cpu64bit}
+               u32bit,
+{$endif cpu64bit}
+               s64bit:
+                 begin
+                   v:=int64(not int64(v));
+                   if (torddef(left.resultdef).ordtype<>s64bit) then
+                     def:=sinttype
+                   else
+                     def:=s64inttype;
+                 end;
+{$ifndef cpu64bit}
+               u32bit,
+{$endif not cpu64bit}
                u64bit :
                  begin
-                   v:=int64(not int64(v)); { maybe qword is required }
-                   int_to_type(v,def);
+                   { Delphi-compatible: not dword = dword (not word = longint) }
+                   { Extension: not qword = qword                              }
+                   v:=qword(not qword(v));
+                   { will be truncated by the ordconstnode for u32bit }
                  end;
                else
                  CGMessage(type_e_mismatch);

+ 6 - 1
tests/test/cg/tnot.pp

@@ -57,7 +57,8 @@ begin
     writeln('Passed!');
 end;
 
-
+const
+  lb = longbool(false);
 
 var
  longres :  longint;
@@ -127,6 +128,10 @@ Begin
    Write('Value should be FALSE...');
    test(ord(byteboolres),0);
 
+  longboolres:=not(lb);
+  Write('Value should be 1...');
+  test(ord(longboolres),1);
+
   { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! }
   { CURRENT_NODE : LOC_JUMP }
   { ???????????????????????}

+ 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.
+