Pārlūkot izejas kodu

Merged revisions 10536-10540,10547,10553,10555,10565,10570,10606,10612-10613,10617,10622-10624,10639-10641,10645-10646,10649,10658,10660-10662,10664-10667,10673-10675,10678-10680,10684-10687,10689,10695,10698-10701,10703,10709,10713-10716,10718-10719,10723,10735-10739,10749,10751,10755-10757,10759-10761,10769,10772-10778,10782-10785,10787-10790,10794-10795,10798,10830-10832,10837,10848,10858,10860,10862-10864,10875,10882,10891,10907,10909,10915-10916,10922-10923,10928,10930,10933,10935,10939-10940,10942,10948,10952-10956,10960,10964-10965,10972,10974-10975,10977,10980,10982-10983,10985,10993,11000,11032-11033,11042,11044,11046,11053,11060,11062,11064,11067,11075,11078,11080,11085,11089,11094,11096,11098,11103-11104,11106,11108-11109,11111,11114,11117,11122,11124,11126,11130-11131,11133,11136,11139-11141,11146-11147,11152-11154,11157,11159,11166-11167,11170,11173,11177-11178,11181-11182,11184-11185,11187-11189,11195-11196,11206-11209,11211 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r10536 | florian | 2008-03-23 11:18:33 +0100 (Sun, 23 Mar 2008) | 2 lines

+ check for location.loc<>expectloc in extdebug mode
* set expectloc properly for add nodes on arm
........
r10940 | florian | 2008-05-11 11:09:21 +0200 (Sun, 11 May 2008) | 3 lines

* range check error checking for floats refactored
* never throw range/overflow check errors for floats in delphi mode, resolves #7584
........
r11177 | florian | 2008-06-02 23:44:48 +0200 (Mon, 02 Jun 2008) | 2 lines

o patch by Olivier Coursiere:
+ add missing targets to ppudump
........
r11211 | florian | 2008-06-07 17:08:48 +0200 (Sat, 07 Jun 2008) | 1 line

* support of dq in Intel assembler on 64 bit CPUs, resolves #11425
........

git-svn-id: branches/fixes_2_2@12069 -

florian 17 gadi atpakaļ
vecāks
revīzija
0f69d4559d

+ 2 - 0
.gitattributes

@@ -7913,6 +7913,8 @@ tests/webtbs/tw0751.pp svneol=native#text/plain
 tests/webtbs/tw0753.pp svneol=native#text/plain
 tests/webtbs/tw0754.pp svneol=native#text/plain
 tests/webtbs/tw0755.pp svneol=native#text/plain
+tests/webtbs/tw07584.pp svneol=native#text/plain
+tests/webtbs/tw07584a.pp svneol=native#text/plain
 tests/webtbs/tw0760.pp svneol=native#text/plain
 tests/webtbs/tw0761.pp svneol=native#text/plain
 tests/webtbs/tw0769.pp svneol=native#text/plain

+ 13 - 8
compiler/arm/narmadd.pas

@@ -301,17 +301,22 @@ interface
 
 
     function tarmaddnode.pass_1 : tnode;
+      var
+        unsigned : boolean;
       begin
         result:=inherited pass_1;
 
-        { handling boolean expressions }
-        if not(assigned(result)) and
-           (
-             not(is_boolean(left.resultdef)) or
-             not(is_boolean(right.resultdef)) or
-             is_dynamic_array(left.resultdef)
-           ) then
-          expectloc:=LOC_FLAGS;
+        if not(assigned(result)) then
+          begin
+            unsigned:=not(is_signed(left.resultdef)) or
+              not(is_signed(right.resultdef));
+
+            if is_64bit(left.resultdef) and
+              ((nodetype in [equaln,unequaln]) or
+               (unsigned and (nodetype in [ltn,lten,gtn,gten]))
+              ) then
+              expectloc:=LOC_FLAGS;
+          end;
       end;
 
 

+ 9 - 0
compiler/globals.pas

@@ -359,6 +359,7 @@ interface
 {$ifdef ARM}
     function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
 {$endif ARM}
+    function floating_point_range_check_error : boolean;
 
 implementation
 
@@ -1096,6 +1097,14 @@ implementation
       end;
 {$endif ARM}
 
+
+    function floating_point_range_check_error : boolean;
+      begin
+        result:=((([cs_check_range,cs_check_overflow]*current_settings.localswitches)<>[]) and not
+                   (m_delphi in current_settings.modeswitches)
+                ); // or (cs_ieee_errors in current_settings.localswitches);
+      end;
+
 {****************************************************************************
                                     Init
 ****************************************************************************}

+ 1 - 2
compiler/nadd.pas

@@ -167,8 +167,7 @@ implementation
             ((rt = realconstn) and
              (trealconstnode(right).value_real = 0.0))) then
           begin
-            if (cs_check_range in current_settings.localswitches) or
-               (cs_check_overflow in current_settings.localswitches) then
+            if floating_point_range_check_error then
                begin
                  result:=crealconstnode.create(1,pbestrealtype^);
                  Message(parser_e_division_by_zero);

+ 4 - 8
compiler/ncgcon.pas

@@ -174,8 +174,7 @@ implementation
                       begin
                         current_asmdata.asmlists[al_typedconsts].concat(Tai_real_32bit.Create(ts32real(value_real)));
                         { range checking? }
-                        if ((cs_check_range in current_settings.localswitches) or
-                          (cs_check_overflow in current_settings.localswitches)) and
+                        if floating_point_range_check_error and
                           (tai_real_32bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
                           Message(parser_e_range_check_error);
                       end;
@@ -190,8 +189,7 @@ implementation
                           current_asmdata.asmlists[al_typedconsts].concat(Tai_real_64bit.Create(ts64real(value_real)));
 
                         { range checking? }
-                        if ((cs_check_range in current_settings.localswitches) or
-                          (cs_check_overflow in current_settings.localswitches)) and
+                        if floating_point_range_check_error and
                           (tai_real_64bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
                           Message(parser_e_range_check_error);
                      end;
@@ -201,8 +199,7 @@ implementation
                         current_asmdata.asmlists[al_typedconsts].concat(Tai_real_80bit.Create(value_real));
 
                         { range checking? }
-                        if ((cs_check_range in current_settings.localswitches) or
-                          (cs_check_overflow in current_settings.localswitches)) and
+                        if floating_point_range_check_error and
                           (tai_real_80bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
                           Message(parser_e_range_check_error);
                       end;
@@ -212,8 +209,7 @@ implementation
                         current_asmdata.asmlists[al_typedconsts].concat(Tai_real_128bit.Create(value_real));
 
                         { range checking? }
-                        if ((cs_check_range in current_settings.localswitches) or
-                          (cs_check_overflow in current_settings.localswitches)) and
+                        if floating_point_range_check_error and
                           (tai_real_128bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
                           Message(parser_e_range_check_error);
                       end;

+ 3 - 6
compiler/ninl.pas

@@ -1242,8 +1242,7 @@ implementation
       function handle_ln_const(r : bestreal) : tnode;
         begin
           if r<=0.0 then
-            if (cs_check_range in current_settings.localswitches) or
-               (cs_check_overflow in current_settings.localswitches) then
+            if floating_point_range_check_error then
                begin
                  result:=crealconstnode.create(0,pbestrealtype^);
                  CGMessage(type_e_wrong_math_argument)
@@ -1263,8 +1262,7 @@ implementation
       function handle_sqrt_const(r : bestreal) : tnode;
         begin
           if r<0.0 then
-            if (cs_check_range in current_settings.localswitches) or
-               (cs_check_overflow in current_settings.localswitches) then
+            if floating_point_range_check_error then
                begin
                  result:=crealconstnode.create(0,pbestrealtype^);
                  CGMessage(type_e_wrong_math_argument)
@@ -1535,8 +1533,7 @@ implementation
                     begin
                       result:=crealconstnode.create(exp(getconstrealvalue),pbestrealtype^);
                       if (trealconstnode(result).value_real=MathInf.Value) and
-                         ((cs_check_range in current_settings.localswitches) or
-                          (cs_check_overflow in current_settings.localswitches)) then
+                         floating_point_range_check_error then
                         begin
                           result:=crealconstnode.create(0,pbestrealtype^);
                           CGMessage(parser_e_range_check_error);

+ 2 - 0
compiler/pass_2.pas

@@ -195,6 +195,8 @@ implementation
               logsecond(p.nodetype,false);
             if (not codegenerror) then
              begin
+               if (p.location.loc<>p.expectloc) then
+                 Comment(V_Warning,'Location not equal to expectloc: '+nodetype2str[p.nodetype]);
                if (p.location.loc=LOC_INVALID) then
                  Comment(V_Warning,'Location not set in secondpass: '+nodetype2str[p.nodetype]);
              end;

+ 91 - 50
compiler/utils/ppudump.pp

@@ -104,58 +104,79 @@ end;
 
 Function Target2Str(w:longint):string;
 type
-       { taken from systems.pas }
-       ttarget =
-       (
-             target_none,               { 0 }
-             target_i386_GO32V1,        { 1 }
-             target_i386_GO32V2,        { 2 }
-             target_i386_linux,         { 3 }
-             target_i386_OS2,           { 4 }
-             target_i386_Win32,         { 5 }
-             target_i386_freebsd,       { 6 }
-             target_m68k_Amiga,         { 7 }
-             target_m68k_Atari,         { 8 }
-             target_m68k_Mac,           { 9 }
-             target_m68k_linux,         { 10 }
-             target_m68k_PalmOS,        { 11 }
-             target_alpha_linux,        { 12 }
-             target_powerpc_linux,      { 13 }
-             target_powerpc_macos,      { 14 }
-             target_i386_sunos,         { 15 }
-             target_i386_beos,          { 16 }
-             target_i386_netbsd,        { 17 }
-             target_m68k_netbsd,        { 18 }
-             target_i386_Netware,       { 19 }
-             target_i386_qnx,           { 20 }
-             target_i386_wdosx,         { 21 }
-             target_sparc_sunos,        { 22 }
-             target_sparc_linux,        { 23 }
-             target_i386_openbsd,       { 24 }
-             target_m68k_openbsd,       { 25 }
-             system_x86_64_linux,       { 26 }
-             system_powerpc_macosx,     { 27 }
-             target_i386_emx,           { 28 }
-             target_powerpc_netbsd,     { 29 }
-             target_powerpc_openbsd,    { 30 }
-             target_arm_linux,          { 31 }
-             target_i386_watcom,        { 32 }
-             target_powerpc_MorphOS,    { 33 }
-             target_x86_64_freebsd,     { 34 }
-             target_i386_netwlibc,      { 35 }
-             system_powerpc_Amiga,      { 36 }
-             system_x86_64_win64,       { 37 }
-             system_arm_wince,          { 38 }
-             system_ia64_win64,         { 39 }
-             system_i386_wince,         { 40 }
-             system_x86_6432_linux,     { 41 }
-             system_arm_gba,            { 42 }
-             system_arm_nds             { 43 }
-       );
+  { taken from systems.pas }
+  ttarget =
+  (
+        target_none,               { 0 }
+        obsolete_target_i386_GO32V1,{ 1 }
+        target_i386_GO32V2,        { 2 }
+        target_i386_linux,         { 3 }
+        target_i386_OS2,           { 4 }
+        target_i386_Win32,         { 5 }
+        target_i386_freebsd,       { 6 }
+        target_m68k_Amiga,         { 7 }
+        target_m68k_Atari,         { 8 }
+        target_m68k_Mac,           { 9 }
+        target_m68k_linux,         { 10 }
+        target_m68k_PalmOS,        { 11 }
+        target_alpha_linux,        { 12 }
+        target_powerpc_linux,      { 13 }
+        target_powerpc_macos,      { 14 }
+        target_i386_solaris,       { 15 }
+        target_i386_beos,          { 16 }
+        target_i386_netbsd,        { 17 }
+        target_m68k_netbsd,        { 18 }
+        target_i386_Netware,       { 19 }
+        target_i386_qnx,           { 20 }
+        target_i386_wdosx,         { 21 }
+        target_sparc_solaris,      { 22 }
+        target_sparc_linux,        { 23 }
+        target_i386_openbsd,       { 24 }
+        target_m68k_openbsd,       { 25 }
+        target_x86_64_linux,       { 26 }
+        target_powerpc_darwin,     { 27 }
+        target_i386_emx,           { 28 }
+        target_powerpc_netbsd,     { 29 }
+        target_powerpc_openbsd,    { 30 }
+        target_arm_linux,          { 31 }
+        target_i386_watcom,        { 32 }
+        target_powerpc_MorphOS,    { 33 }
+        target_x86_64_freebsd,     { 34 }
+        target_i386_netwlibc,      { 35 }
+        target_powerpc_Amiga,      { 36 }
+        target_x86_64_win64,       { 37 }
+        target_arm_wince,          { 38 }
+        target_ia64_win64,         { 39 }
+        target_i386_wince,         { 40 }
+        target_x86_6432_linux,     { 41 }
+        target_arm_gba,            { 42 }
+        target_powerpc64_linux,    { 43 }
+        target_i386_darwin,        { 44 }
+        target_arm_palmos,         { 45 }
+        target_powerpc64_darwin,   { 46 }
+        target_arm_nds,            { 47 }
+        target_i386_embedded,      { 48 }
+        target_m68k_embedded,      { 49 }
+        target_alpha_embedded,     { 50 }
+        target_powerpc_embedded,   { 51 }
+        target_sparc_embedded,     { 52 }
+        target_vm_embedded,        { 53 }
+        target_iA64_embedded,      { 54 }
+        target_x86_64_embedded,    { 55 }
+        target_mips_embedded,      { 56 }
+        target_arm_embedded,       { 57 }
+        target_powerpc64_embedded, { 58 }
+        target_i386_symbian,       { 59 }
+        target_arm_symbian,        { 60 }
+        target_x86_64_darwin,      { 61 }
+        target_avr_embedded,       { 62 }
+        target_i386_haiku          { 63 }             
+  );
+
 const
   Targets : array[ttarget] of string[17]=(
   { 0 }   'none',
-  { 1 }   'GO32V1',
+  { 1 }   'GO32V1 (obsolete)',
   { 2 }   'GO32V2',
   { 3 }   'Linux-i386',
   { 4 }   'OS/2',
@@ -197,7 +218,27 @@ const
   { 40 }  'WinCE-i386',
   { 41 }  'Linux-x64',
   { 42 }  'GBA-arm',
-  { 43 }  'NDS-arm'
+  { 43 }  'Linux-powerpc64',
+  { 44 }  'Darwin-i386',
+  { 45 }  'PalmOS-arm',
+  { 46 }  'MacOSX-powerpc64',
+  { 47 }  'NDS-arm',
+  { 48 }  'Embedded-i386',
+  { 49 }  'Embedded-m68k',
+  { 50 }  'Embedded-alpha',
+  { 51 }  'Embedded-powerpc',
+  { 52 }  'Embedded-sparc',
+  { 53 }  'Embedded-vm',
+  { 54 }  'Embedded-iA64',
+  { 55 }  'Embedded-x64',
+  { 56 }  'Embedded-mips',
+  { 57 }  'Embedded-arm',
+  { 58 }  'Embedded-powerpc64',
+  { 59 }  'Symbian-i386',
+  { 60 }  'Symbian-arm',
+  { 61 }  'MacOSX-x64',
+  { 62 }  'Embedded-avr',
+  { 63 }  'Haiku-i386'        
   );
 begin
   if w<=ord(high(ttarget)) then

+ 23 - 11
compiler/x86/rax86int.pas

@@ -40,7 +40,7 @@ Unit Rax86int;
       AS_RPAREN,AS_COLON,AS_DOT,AS_PLUS,AS_MINUS,AS_STAR,
       AS_SEPARATOR,AS_ID,AS_REGISTER,AS_OPCODE,AS_SLASH,
        {------------------ Assembler directives --------------------}
-      AS_ALIGN,AS_DB,AS_DW,AS_DD,AS_END,
+      AS_ALIGN,AS_DB,AS_DW,AS_DD,AS_DQ,AS_END,
        {------------------ Assembler Operators  --------------------}
       AS_BYTE,AS_WORD,AS_DWORD,AS_QWORD,AS_TBYTE,AS_DQWORD,AS_NEAR,AS_FAR,
       AS_HIGH,AS_LOW,AS_OFFSET,AS_SIZEOF,AS_VMTOFFSET,AS_SEG,AS_TYPE,AS_PTR,AS_MOD,AS_SHL,AS_SHR,AS_NOT,
@@ -109,7 +109,7 @@ Unit Rax86int;
        _count_asmoperators  = longint(lastoperator)-longint(firstoperator);
 
        _asmdirectives : array[0.._count_asmdirectives] of tasmkeyword =
-       ('ALIGN','DB','DW','DD','END');
+       ('ALIGN','DB','DW','DD','DQ','END');
 
        { problems with shl,shr,not,and,or and xor, they are }
        { context sensitive.                                 }
@@ -123,7 +123,7 @@ Unit Rax86int;
         ',','[',']','(',
         ')',':','.','+','-','*',
         ';','identifier','register','opcode','/',
-        '','','','','END',
+        '','','','','','END',
         '','','','','','','','','',
         '','','sizeof','vmtoffset','','type','ptr','mod','shl','shr','not',
         'and','or','xor'
@@ -877,7 +877,7 @@ Unit Rax86int;
                        if mangledname<>'' then
                          { procsym }
                          Message(asmr_e_wrong_sym_type);
-                     end                         
+                     end
                    else
                     begin
                       searchsym(tempstr,sym,srsymtable);
@@ -1069,6 +1069,7 @@ Unit Rax86int;
             AS_DB,
             AS_DW,
             AS_DD,
+            AS_DQ,
             AS_END,
             AS_RBRACKET,
             AS_SEPARATOR,
@@ -1148,7 +1149,7 @@ Unit Rax86int;
 
           Case actasmtoken of
             AS_ID, { Constant reference expression OR variable reference expression }
-            AS_VMTOFFSET: 
+            AS_VMTOFFSET:
               Begin
                 if not GotPlus then
                   Message(asmr_e_invalid_reference_syntax);
@@ -2039,6 +2040,7 @@ Unit Rax86int;
             AS_DB,
             AS_DW,
             AS_DD,
+            AS_DQ,
             AS_OPCODE,
             AS_END,
             AS_SEPARATOR:
@@ -2118,13 +2120,23 @@ Unit Rax86int;
               inexpression:=false;
             end;
 
-           AS_ALIGN:
-             Begin
-               Consume(AS_ALIGN);
-               ConcatAlign(curlist,BuildConstExpression);
-               if actasmtoken<>AS_SEPARATOR then
+{$ifdef cpu64bitaddr}
+          AS_DQ:
+            Begin
+              inexpression:=true;
+              Consume(AS_DQ);
+              BuildConstant(8);
+              inexpression:=false;
+            end;
+{$endif cpu64bitaddr}
+
+          AS_ALIGN:
+            Begin
+              Consume(AS_ALIGN);
+              ConcatAlign(curlist,BuildConstExpression);
+              if actasmtoken<>AS_SEPARATOR then
                 Consume(AS_SEPARATOR);
-             end;
+            end;
 
           AS_OPCODE :
             Begin

+ 13 - 0
tests/webtbs/tw07584.pp

@@ -0,0 +1,13 @@
+program bug;
+
+{$mode delphi}
+
+uses
+  math;
+
+{$Q+}
+{$R+}
+
+begin
+  Writeln(Math.Infinity);
+end.

+ 11 - 0
tests/webtbs/tw07584a.pp

@@ -0,0 +1,11 @@
+program bug;
+
+{$ifdef fpc}
+{$mode delphi}
+{$endif}
+
+const
+  Inf = 1.0 / 0.0;
+
+begin
+end.