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

o patch by Alexander Shishkin, resolves #20409
* eliminate warnings in compiler (i386 & i368->x86_64) and minor refactorings
- comment out unused vars and types
- comment out unneeded comparisons (Longword <=> 0)
- suppress some "comparison always true|false" warnings
- tweak visiblity sections

git-svn-id: trunk@19385 -

florian 14 жил өмнө
parent
commit
111d05c68f

+ 4 - 0
compiler/aasmtai.pas

@@ -416,10 +416,12 @@ interface
           destructor Destroy;override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
+{$push}{$warnings off}
          private
           { this constructor is made private on purpose }
           { because sections should be created via new_section() }
           constructor Create(Asectype:TAsmSectiontype;const Aname:string;Aalign:byte;Asecorder:TasmSectionorder=secorder_default);
+{$pop}
        end;
 
 
@@ -2644,7 +2646,9 @@ implementation
       end;
 
 begin
+{$push}{$warnings off}
   { taitype should fit into a 4 byte set for speed reasons }
   if ord(high(taitype))>31 then
     internalerror(201108181);
+{$pop}
 end.

+ 2 - 0
compiler/cclasses.pas

@@ -1274,8 +1274,10 @@ end;
 
 procedure TFPHashList.SetStrCapacity(NewCapacity: Integer);
 begin
+{$push}{$warnings off}
   If (NewCapacity < FStrCount) or (NewCapacity > MaxHashStrSize) then
      Error (SListCapacityError, NewCapacity);
+{$pop}
   if NewCapacity = FStrCapacity then
     exit;
   ReallocMem(FStrs, NewCapacity);

+ 4 - 0
compiler/i386/daopt386.pas

@@ -715,8 +715,10 @@ function isgp32reg(supreg: tsuperregister): boolean;
 {Checks if the register is a 32 bit general purpose register}
 begin
   isgp32reg := false;
+{$push}{$warnings off}
   if (supreg >= RS_EAX) and (supreg <= RS_EBX) then
     isgp32reg := true
+{$pop}
 end;
 
 
@@ -1375,10 +1377,12 @@ procedure DestroyReg(p1: ptaiprop; supreg: tsuperregister; doincState:Boolean);
  action (e.g. this register holds the contents of a variable and the value
  of the variable in memory is changed) }
 begin
+{$push}{$warnings off}
   { the following happens for fpu registers }
   if (supreg < low(NrOfInstrSinceLastMod)) or
      (supreg > high(NrOfInstrSinceLastMod)) then
     exit;
+{$pop}
   NrOfInstrSinceLastMod[supreg] := 0;
   with p1^.regs[supreg] do
     begin

+ 4 - 4
compiler/machoutils.pas

@@ -1182,7 +1182,7 @@ const
     begin
       if not Assigned(fCnv) then
         IntReadStruct;
-      Result:=(index>=0) and (index<fHdr.ncmds);
+      Result:={(index>=0) and }(index<fHdr.ncmds);
       if not Result then
         Exit;
       Result:=true;
@@ -1198,7 +1198,7 @@ const
       if not Assigned(fCnv) then
         IntReadStruct;
 
-      Result:=(cmdindex>=0) and
+      Result:={(cmdindex>=0) and }
               (cmdindex<fHdr.ncmds) and
               (cmds[cmdindex].cmd in [LC_SEGMENT, LC_SEGMENT_64]);
 
@@ -1226,7 +1226,7 @@ const
       if not Assigned(fCnv) then
         IntReadStruct;
 
-      if (index<0) or
+      if {(index<0) or}
          (index>=longword(length(cmdofs))) then
         Result:=0
       else
@@ -1245,7 +1245,7 @@ const
     begin
       if not Assigned(fCnv) then
         IntReadStruct;
-      Result:=(secindex>=0) and (segindex>=0) and (segindex<fHdr.ncmds) and (cmds[segindex].cmd in [LC_SEGMENT, LC_SEGMENT_64]);
+      Result:={(secindex>=0) and (segindex>=0) and }(segindex<fHdr.ncmds) and (cmds[segindex].cmd in [LC_SEGMENT, LC_SEGMENT_64]);
       if not Result then
         Exit;
 

+ 3 - 3
compiler/nbas.pas

@@ -508,11 +508,11 @@ implementation
     function tblocknode.pass_1 : tnode;
       var
          hp : tstatementnode;
-         count : longint;
+         //count : longint;
       begin
          result:=nil;
          expectloc:=LOC_VOID;
-         count:=0;
+         //count:=0;
          hp:=tstatementnode(left);
          while assigned(hp) do
            begin
@@ -523,7 +523,7 @@ implementation
                    hp.expectloc:=hp.left.expectloc;
                 end;
               expectloc:=hp.expectloc;
-              inc(count);
+              //inc(count);
               hp:=tstatementnode(hp.right);
            end;
       end;

+ 6 - 4
compiler/ncgcnv.pas

@@ -34,6 +34,11 @@ interface
        { tcgtypeconvnode }
 
        tcgtypeconvnode = class(ttypeconvnode)
+       protected
+{$ifdef cpuflags}
+         { CPUs without flags need a specific implementation of int -> bool }
+         procedure second_int_to_bool;override;
+{$endif cpuflags}
          procedure second_int_to_int;override;
          procedure second_cstring_to_pchar;override;
          procedure second_cstring_to_int;override;
@@ -51,11 +56,8 @@ interface
          procedure second_class_to_intf;override;
          procedure second_char_to_char;override;
          procedure second_nothing;override;
+       public
          procedure pass_generate_code;override;
-{$ifdef cpuflags}
-         { CPUs without flags need a specific implementation of int -> bool }
-         procedure second_int_to_bool;override;
-{$endif cpuflags}
        end;
 
        tcgasnode = class(tasnode)

+ 3 - 3
compiler/node.pas

@@ -390,7 +390,7 @@ interface
       { this node is the anchestor for all nodes with at least   }
       { one child, you have to use it if you want to use         }
       { true- and current_procinfo.CurrFalseLabel                                     }
-      punarynode = ^tunarynode;
+      //punarynode = ^tunarynode;
       tunarynode = class(tnode)
          left : tnode;
          constructor create(t:tnodetype;l : tnode);
@@ -407,7 +407,7 @@ interface
          procedure printnodedata(var t:text);override;
       end;
 
-      pbinarynode = ^tbinarynode;
+      //pbinarynode = ^tbinarynode;
       tbinarynode = class(tunarynode)
          right : tnode;
          constructor create(t:tnodetype;l,r : tnode);
@@ -426,7 +426,7 @@ interface
          procedure printnodelist(var t:text);
       end;
 
-      ptertiarynode = ^ttertiarynode;
+      //ptertiarynode = ^ttertiarynode;
       ttertiarynode = class(tbinarynode)
          third : tnode;
          constructor create(_t:tnodetype;l,r,t : tnode);

+ 1 - 1
compiler/ogcoff.pas

@@ -3018,7 +3018,7 @@ const pemagic : array[0..3] of byte = (
             DLLReader.Seek(sechdr.datapos+expdir.AddrNames-sechdr.rvaofs+i*4);
             DLLReader.Read(NameOfs,4);
             Dec(NameOfs,sechdr.rvaofs);
-            if (NameOfs<0) or
+            if {(NameOfs<0) or}
                (NameOfs>sechdr.vsize) then
               begin
                 Comment(V_Error,'DLL does contains invalid exports');

+ 3 - 3
compiler/ognlm.pas

@@ -254,9 +254,9 @@ const NLM_MAX_DESCRIPTION_LENGTH = 127;
          nlmVersionHeader   : nlm32_i386_external_version_header;
          nlmExtHeader       : nlm32_i386_external_extended_header;
          nlmCustHeader      : nlm32_i386_external_custom_header;
-         nlmHelpFileName    : TCmdStr;
-         nlmMessagesFileName: TCmdStr;
-         nlmXdcFileName     : TCmdStr;
+         //nlmHelpFileName    : TCmdStr;
+         //nlmMessagesFileName: TCmdStr;
+         //nlmXdcFileName     : TCmdStr;
          nlmCopyright       : string;
          nlmThreadname      : string;
          nlmScreenname      : string;

+ 2 - 0
compiler/symdef.pas

@@ -1690,8 +1690,10 @@ implementation
 
     procedure tenumdef.calcsavesize;
       begin
+{$IFDEF CPU32} {$push}{$warnings off} {$ENDIF} //comparison always false warning
         if (current_settings.packenum=8) or (min<low(longint)) or (int64(max)>high(cardinal)) then
          savesize:=8
+{$IFDEF CPU32} {$pop} {$ENDIF}
         else
          if (current_settings.packenum=4) or (min<low(smallint)) or (max>high(word)) then
           savesize:=4

+ 5 - 3
compiler/x86/agx86att.pas

@@ -229,7 +229,9 @@ interface
     procedure Tx86InstrWriter.WriteInstruction(hp: tai);
       var
        op       : tasmop;
+{$ifdef x86_64}
        val      : aint;
+{$endif}
        calljmp  : boolean;
        need_second_mov : boolean;
        i        : integer;
@@ -244,12 +246,12 @@ interface
           the fix consists of simply setting only the 4-byte register
           as the upper 4-bytes will be zeroed at the same time. }
         need_second_mov:=false;
+{$ifdef x86_64}
         if (op=A_MOV) and (taicpu(hp).opsize=S_Q) and
            (taicpu(hp).oper[0]^.typ = top_const) then
            begin
              val := taicpu(hp).oper[0]^.val;
-{$ifdef x86_64}
-	     if (val > int64($7fffffff)) and (val < int64($100000000)) then
+             if (val > int64($7fffffff)) and (val < int64($100000000)) then
                begin
                  owner.AsmWrite(target_asm.comment);
                  owner.AsmWritePChar('Fix for Win64-GAS bug');
@@ -262,8 +264,8 @@ interface
                  else
                    internalerror(20100902);
                end;
-{$endif x86_64}
            end;
+{$endif x86_64}
         owner.AsmWrite(#9);
         { movsd should not be translated to movsl when there
           are (xmm) arguments }

+ 1 - 1
compiler/x86/nx86cnv.pas

@@ -30,7 +30,7 @@ interface
 
     type
        tx86typeconvnode = class(tcgtypeconvnode)
-         protected
+       protected
          function first_real_to_real : tnode;override;
          { procedure second_int_to_int;override; }
          { procedure second_string_to_string;override; }