Browse Source

* prettify the "Use of +offset(%ebp) is not compatible with regcall convention"
and "Use of +offset(%ebp) for parameters invalid here" warning messages by
showing the exact register used (bp, ebp or rbp) and using the original asm
syntax (Intel: [EBP+offset]; AT&T: +offset(%ebp) )

git-svn-id: trunk@42207 -

nickysn 6 years ago
parent
commit
1e07606cbf
4 changed files with 246 additions and 220 deletions
  1. 2 2
      compiler/msg/errore.msg
  2. 1 1
      compiler/msgidx.inc
  3. 213 214
      compiler/msgtxt.inc
  4. 30 3
      compiler/x86/rax86.pas

+ 2 - 2
compiler/msg/errore.msg

@@ -2758,10 +2758,10 @@ asmr_w_unable_to_determine_reference_size_using_byte=07101_W_No size specified a
 % the compiler is unable to determine what size (byte,word,dword,etc.) it
 % should use for the reference. This warning is only used in Delphi mode where
 % it falls back to use BYTE as default.
-asmr_w_no_direct_ebp_for_parameter=07102_W_Use of +offset(%ebp) for parameters invalid here
+asmr_w_no_direct_ebp_for_parameter=07102_W_Use of $1 for parameters invalid here
 % Using direct 8(%ebp) reference for function/procedure parameters is invalid
 % if parameters are in registers.
-asmr_w_direct_ebp_for_parameter_regcall=07103_W_Use of +offset(%ebp) is not compatible with regcall convention
+asmr_w_direct_ebp_for_parameter_regcall=07103_W_Use of $1 is not compatible with regcall convention
 % Using direct 8(%ebp) reference for function/procedure parameters is invalid
 % if parameters are in registers.
 asmr_w_direct_ebp_neg_offset=07104_W_Use of -offset(%ebp) is not recommended for local variable access

+ 1 - 1
compiler/msgidx.inc

@@ -1110,7 +1110,7 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 83042;
+  MsgTxtSize = 83020;
 
   MsgIdxMax : array[1..20] of longint=(
     28,106,351,126,99,61,142,34,221,67,

File diff suppressed because it is too large
+ 213 - 214
compiler/msgtxt.inc


+ 30 - 3
compiler/x86/rax86.pas

@@ -248,7 +248,8 @@ begin
 end;
 
 Function Tx86Operand.CheckOperand: boolean;
-
+var
+  ErrorRefStr: string;
 begin
   result:=true;
   if (opr.typ=OPR_Reference) then
@@ -257,10 +258,36 @@ begin
         begin
           if (getsupreg(opr.ref.base)=RS_EBP) and (opr.ref.offset>0) then
             begin
+              if current_settings.asmmode in [asmmode_i8086_intel,asmmode_i386_intel,asmmode_x86_64_intel] then
+                begin
+                  case getsubreg(opr.ref.base) of
+                    R_SUBW:
+                      ErrorRefStr:='[BP+offset]';
+                    R_SUBD:
+                      ErrorRefStr:='[EBP+offset]';
+                    R_SUBQ:
+                      ErrorRefStr:='[RBP+offset]';
+                    else
+                      internalerror(2019061001);
+                  end;
+                end
+              else
+                begin
+                  case getsubreg(opr.ref.base) of
+                    R_SUBW:
+                      ErrorRefStr:='+offset(%bp)';
+                    R_SUBD:
+                      ErrorRefStr:='+offset(%ebp)';
+                    R_SUBQ:
+                      ErrorRefStr:='+offset(%rbp)';
+                    else
+                      internalerror(2019061002);
+                  end;
+                end;
               if current_procinfo.procdef.proccalloption=pocall_register then
-                message(asmr_w_no_direct_ebp_for_parameter)
+                message1(asmr_w_no_direct_ebp_for_parameter,ErrorRefStr)
               else
-                message(asmr_w_direct_ebp_for_parameter_regcall);
+                message1(asmr_w_direct_ebp_for_parameter_regcall,ErrorRefStr);
             end
           else if (getsupreg(opr.ref.base)=RS_EBP) and (opr.ref.offset<0) then
             message(asmr_w_direct_ebp_neg_offset)

Some files were not shown because too many files changed in this diff