View Issue Details

IDProjectCategoryView StatusLast Update
0013957FPCCompilerpublic2009-08-12 19:15
ReporterPetr-KAssigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status newResolutionopen 
PlatformallOSallOS Version
Product Version2.3.1Product Build13256 
Target VersionFixed in Version 
Summary0013957: Compiler message verbosity remapping patch
DescriptionI extend my patch for suppressing compiler messages. Now it is possible

to remap compiler message verbosity by command parametr:
-vm5024_,5025w,5026e which means:
suppress message 5024, 5025 is warning and 5026 is error
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files
  • msgremap.patch (2,986 bytes)
    Index: compiler/verbose.pas
    ===================================================================
    --- compiler/verbose.pas	(revision 13256)
    +++ compiler/verbose.pas	(working copy)
    @@ -177,11 +177,13 @@
           end;
     
     
    -    function ClearMessageVerbosity(s: string; var i: integer): boolean;
    +    function SetMessageVerbosity(s: string; var i: integer): boolean;
           var
             tok : string;
             code : longint;
             msgnr: longint;
    +        len : longint;
    +        ch : char;
           begin
             { delete everything up to and including 'm' }
             delete(s,1,i);
    @@ -192,10 +194,13 @@
               tok:=GetToken(s,',');
               if (tok='') then
                 break;
    +          len := length(tok);
    +          ch := tok[len];
    +          delete(tok, len, 1);
               val(tok, msgnr, code);
               if (code<>0) then
                 exit;
    -          if not msg^.clearverbosity(msgnr) then
    +          if not msg^.setverbosity(msgnr, ch) then
                 exit;
             until false;
             result:=true;
    @@ -247,7 +252,7 @@
                                 status.print_source_path:=true;
                            end;
                      'M' : if inverse or
    -                          not ClearMessageVerbosity(s, i) then
    +                          not SetMessageVerbosity(s, i) then
                              begin
                                result:=false;
                                exit
    Index: compiler/cmsgs.pas
    ===================================================================
    --- compiler/cmsgs.pas	(revision 13256)
    +++ compiler/cmsgs.pas	(working copy)
    @@ -52,7 +52,7 @@
         procedure ClearIdx;
         procedure CreateIdx;
         function  GetPChar(nr:longint):pchar;
    -    function  ClearVerbosity(nr:longint):boolean;
    +    function SetVerbosity(nr:longint; ch:char):boolean;
         function  Get(nr:longint;const args:array of string):ansistring;
       end;
     
    @@ -375,7 +375,7 @@
       GetPChar:=msgidx[nr div 1000]^[nr mod 1000];
     end;
     
    -function TMessage.ClearVerbosity(nr:longint):boolean;
    +function TMessage.SetVerbosity(nr:longint; ch:char):boolean;
     var
       hp: pchar;
       i, txtbegin: longint;
    @@ -399,7 +399,7 @@
             end;
         end;
       for i:=0 to txtbegin-1 do
    -    hp[i]:='_';
    +    hp[i]:=ch;
       result:=true;
     end;
     
    Index: compiler/msg/errore.msg
    ===================================================================
    --- compiler/msg/errore.msg	(revision 13256)
    +++ compiler/msg/errore.msg	(working copy)
    @@ -2888,7 +2888,8 @@
     **2*_b : Write file names messages with full path
     **2*_v : Write fpcdebug.txt with     p : Write tree.log with parse tree
     **2*_    lots of debugging info      q : Show message numbers
    -**2*_m<x>,<y> : Don't show messages numbered <x> and <y>
    +**2*_m<x>_,<y>w : Messages verbosity remaping.
    +**2*_    Don't show message numbered <x>, msg <y> treat as warning
     3*1W<x>_Target-specific options (targets)
     A*1W<x>_Target-specific options (targets)
     P*1W<x>_Target-specific options (targets)
    Index: packages/fcl-db/src/base/dataset.inc
    
    msgremap.patch (2,986 bytes)
  • msgremap1.patch (3,129 bytes)
    Index: compiler/verbose.pas
    ===================================================================
    --- compiler/verbose.pas	(revision 13256)
    +++ compiler/verbose.pas	(working copy)
    @@ -177,11 +177,13 @@
           end;
     
     
    -    function ClearMessageVerbosity(s: string; var i: integer): boolean;
    +    function SetMessageVerbosity(s: string; var i: integer): boolean;
           var
             tok : string;
             code : longint;
             msgnr: longint;
    +        len : longint;
    +        ch : char;
           begin
             { delete everything up to and including 'm' }
             delete(s,1,i);
    @@ -192,10 +194,17 @@
               tok:=GetToken(s,',');
               if (tok='') then
                 break;
    +          len := length(tok);
    +          ch := tok[len];
    +          if ch = '-' then
    +            ch := '_'; { syntactic sugar }
    +          if not (ch in ['f', 'e', 'w', 'n', 'h', 'i', '_']) then
    +            exit;
    +          delete(tok, len, 1);
               val(tok, msgnr, code);
               if (code<>0) then
                 exit;
    -          if not msg^.clearverbosity(msgnr) then
    +          if not msg^.setverbosity(msgnr, ch) then
                 exit;
             until false;
             result:=true;
    @@ -247,7 +256,7 @@
                                 status.print_source_path:=true;
                            end;
                      'M' : if inverse or
    -                          not ClearMessageVerbosity(s, i) then
    +                          not SetMessageVerbosity(s, i) then
                              begin
                                result:=false;
                                exit
    Index: compiler/cmsgs.pas
    ===================================================================
    --- compiler/cmsgs.pas	(revision 13256)
    +++ compiler/cmsgs.pas	(working copy)
    @@ -52,7 +52,7 @@
         procedure ClearIdx;
         procedure CreateIdx;
         function  GetPChar(nr:longint):pchar;
    -    function  ClearVerbosity(nr:longint):boolean;
    +    function SetVerbosity(nr:longint; ch:char):boolean;
         function  Get(nr:longint;const args:array of string):ansistring;
       end;
     
    @@ -375,7 +375,7 @@
       GetPChar:=msgidx[nr div 1000]^[nr mod 1000];
     end;
     
    -function TMessage.ClearVerbosity(nr:longint):boolean;
    +function TMessage.SetVerbosity(nr:longint; ch:char):boolean;
     var
       hp: pchar;
       i, txtbegin: longint;
    @@ -399,7 +399,7 @@
             end;
         end;
       for i:=0 to txtbegin-1 do
    -    hp[i]:='_';
    +    hp[i]:=ch;
       result:=true;
     end;
     
    Index: compiler/msg/errore.msg
    ===================================================================
    --- compiler/msg/errore.msg	(revision 13256)
    +++ compiler/msg/errore.msg	(working copy)
    @@ -2888,7 +2888,8 @@
     **2*_b : Write file names messages with full path
     **2*_v : Write fpcdebug.txt with     p : Write tree.log with parse tree
     **2*_    lots of debugging info      q : Show message numbers
    -**2*_m<x>,<y> : Don't show messages numbered <x> and <y>
    +**2*_m<mn1>-,<mn2>w : Messages verbosity remaping. Modifiers: fewnhi-. 
    +**2*_    Don't show message numbered <mn1>, msg <mn2> treat as warning
     3*1W<x>_Target-specific options (targets)
     A*1W<x>_Target-specific options (targets)
     P*1W<x>_Target-specific options (targets)
    
    msgremap1.patch (3,129 bytes)
  • msgremap2.patch (3,227 bytes)
    Index: compiler/verbose.pas
    ===================================================================
    --- compiler/verbose.pas	(revision 13256)
    +++ compiler/verbose.pas	(working copy)
    @@ -177,11 +177,13 @@
           end;
     
     
    -    function ClearMessageVerbosity(s: string; var i: integer): boolean;
    +    function SetMessageVerbosity(s: string; var i: integer): boolean;
           var
             tok : string;
             code : longint;
             msgnr: longint;
    +        len : longint;
    +        ch : char;
           begin
             { delete everything up to and including 'm' }
             delete(s,1,i);
    @@ -192,10 +194,17 @@
               tok:=GetToken(s,',');
               if (tok='') then
                 break;
    +          len := length(tok);
    +          ch := tok[len];
    +          if ch = '-' then
    +            ch := '_'; { syntactic sugar }
    +          if not (ch in ['f', 'e', 'w', 'n', 'h', 'i', '_']) then
    +            exit;
    +          delete(tok, len, 1);
               val(tok, msgnr, code);
               if (code<>0) then
                 exit;
    -          if not msg^.clearverbosity(msgnr) then
    +          if not msg^.setverbosity(msgnr, ch) then
                 exit;
             until false;
             result:=true;
    @@ -247,7 +256,7 @@
                                 status.print_source_path:=true;
                            end;
                      'M' : if inverse or
    -                          not ClearMessageVerbosity(s, i) then
    +                          not SetMessageVerbosity(s, i) then
                              begin
                                result:=false;
                                exit
    Index: compiler/cmsgs.pas
    ===================================================================
    --- compiler/cmsgs.pas	(revision 13256)
    +++ compiler/cmsgs.pas	(working copy)
    @@ -52,7 +52,7 @@
         procedure ClearIdx;
         procedure CreateIdx;
         function  GetPChar(nr:longint):pchar;
    -    function  ClearVerbosity(nr:longint):boolean;
    +    function SetVerbosity(nr:longint; ch:char):boolean;
         function  Get(nr:longint;const args:array of string):ansistring;
       end;
     
    @@ -375,7 +375,7 @@
       GetPChar:=msgidx[nr div 1000]^[nr mod 1000];
     end;
     
    -function TMessage.ClearVerbosity(nr:longint):boolean;
    +function TMessage.SetVerbosity(nr:longint; ch:char):boolean;
     var
       hp: pchar;
       i, txtbegin: longint;
    @@ -399,7 +399,8 @@
             end;
         end;
       for i:=0 to txtbegin-1 do
    -    hp[i]:='_';
    +    if not (hp[i] in ['E', 'e', 'F', 'f']) then { do'nt allow modify error or fatal messages }
    +      hp[i]:=ch;
       result:=true;
     end;
     
    Index: compiler/msg/errore.msg
    ===================================================================
    --- compiler/msg/errore.msg	(revision 13256)
    +++ compiler/msg/errore.msg	(working copy)
    @@ -2888,7 +2888,8 @@
     **2*_b : Write file names messages with full path
     **2*_v : Write fpcdebug.txt with     p : Write tree.log with parse tree
     **2*_    lots of debugging info      q : Show message numbers
    -**2*_m<x>,<y> : Don't show messages numbered <x> and <y>
    +**2*_m<mn1>-,<mn2>w : Messages verbosity remaping. Modifiers: fewnhi-. 
    +**2*_    Don't show message numbered <mn1>, msg <mn2> treat as warning
     3*1W<x>_Target-specific options (targets)
     A*1W<x>_Target-specific options (targets)
     P*1W<x>_Target-specific options (targets)
    
    msgremap2.patch (3,227 bytes)
  • msgremap3.patch (3,509 bytes)
    Index: cmsgs.pas
    ===================================================================
    --- cmsgs.pas	(revision 13286)
    +++ cmsgs.pas	(working copy)
    @@ -52,7 +52,7 @@
         procedure ClearIdx;
         procedure CreateIdx;
         function  GetPChar(nr:longint):pchar;
    -    function  ClearVerbosity(nr:longint):boolean;
    +    function  SetVerbosity(nr:longint; ch:char):boolean;
         function  Get(nr:longint;const args:array of string):ansistring;
       end;
     
    @@ -375,10 +375,11 @@
       GetPChar:=msgidx[nr div 1000]^[nr mod 1000];
     end;
     
    -function TMessage.ClearVerbosity(nr:longint):boolean;
    +function TMessage.SetVerbosity(nr:longint; ch:char):boolean;
     var
       hp: pchar;
       i, txtbegin: longint;
    +  changed: boolean;
     begin
        result:=false;
       if ((nr div 1000) < low(msgidx)) or
    @@ -398,9 +399,14 @@
               break;
             end;
         end;
    +  changed:=false;
       for i:=0 to txtbegin-1 do
    -    hp[i]:='_';
    -  result:=true;
    +    if not (hp[i] in ['E', 'e', 'F', 'f']) then { do'nt allow modify error or fatal messages }
    +      begin
    +        hp[i]:=ch;
    +        changed:=true;
    +      end;
    +  result:=changed;
     end;
     
     function TMessage.Get(nr:longint;const args:array of string):ansistring;
    Index: verbose.pas
    ===================================================================
    --- verbose.pas	(revision 13286)
    +++ verbose.pas	(working copy)
    @@ -177,11 +177,13 @@
           end;
     
     
    -    function ClearMessageVerbosity(s: string; var i: integer): boolean;
    +    function SetMessageVerbosity(s: string; var i: integer): boolean;
           var
             tok : string;
             code : longint;
             msgnr: longint;
    +        len : longint;
    +        ch : char;
           begin
             { delete everything up to and including 'm' }
             delete(s,1,i);
    @@ -192,10 +194,17 @@
               tok:=GetToken(s,',');
               if (tok='') then
                 break;
    +          len := length(tok);
    +          ch := tok[len];
    +          if ch = '-' then
    +            ch := '_'; { syntactic sugar }
    +          if not (ch in ['f', 'e', 'w', 'n', 'h', 'i', '_']) then
    +            exit;
    +          delete(tok, len, 1);
               val(tok, msgnr, code);
               if (code<>0) then
                 exit;
    -          if not msg^.clearverbosity(msgnr) then
    +          if not msg^.setverbosity(msgnr, ch) then
                 exit;
             until false;
             result:=true;
    @@ -247,7 +256,7 @@
                                 status.print_source_path:=true;
                            end;
                      'M' : if inverse or
    -                          not ClearMessageVerbosity(s, i) then
    +                          not SetMessageVerbosity(s, i) then
                              begin
                                result:=false;
                                exit
    Index: msg/errore.msg
    ===================================================================
    --- msg/errore.msg	(revision 13286)
    +++ msg/errore.msg	(working copy)
    @@ -2889,7 +2889,9 @@
     **2*_b : Write file names messages   p : Write tree.log with parse tree
     **2*_    with full path              v : Write fpcdebug.txt with
     **2*_                                    lots of debugging info
    -**2*_m<x>,<y> : Don't show messages numbered <x> and <y>
    +**2*_m : Message verbosity remapping. Modifiers: fewnhi- (fatal, error,
    +**2*_    warning, note, hint, info, disable). Errors cannot be remapped.
    +**2*_    E.g.: -vm1-,2w means "disable msg 1, msg 2 becomes a warning"
     3*1W<x>_Target-specific options (targets)
     A*1W<x>_Target-specific options (targets)
     P*1W<x>_Target-specific options (targets)
    
    msgremap3.patch (3,509 bytes)

Activities

2009-06-11 14:28

 

msgremap.patch (2,986 bytes)
Index: compiler/verbose.pas
===================================================================
--- compiler/verbose.pas	(revision 13256)
+++ compiler/verbose.pas	(working copy)
@@ -177,11 +177,13 @@
       end;
 
 
-    function ClearMessageVerbosity(s: string; var i: integer): boolean;
+    function SetMessageVerbosity(s: string; var i: integer): boolean;
       var
         tok : string;
         code : longint;
         msgnr: longint;
+        len : longint;
+        ch : char;
       begin
         { delete everything up to and including 'm' }
         delete(s,1,i);
@@ -192,10 +194,13 @@
           tok:=GetToken(s,',');
           if (tok='') then
             break;
+          len := length(tok);
+          ch := tok[len];
+          delete(tok, len, 1);
           val(tok, msgnr, code);
           if (code<>0) then
             exit;
-          if not msg^.clearverbosity(msgnr) then
+          if not msg^.setverbosity(msgnr, ch) then
             exit;
         until false;
         result:=true;
@@ -247,7 +252,7 @@
                             status.print_source_path:=true;
                        end;
                  'M' : if inverse or
-                          not ClearMessageVerbosity(s, i) then
+                          not SetMessageVerbosity(s, i) then
                          begin
                            result:=false;
                            exit
Index: compiler/cmsgs.pas
===================================================================
--- compiler/cmsgs.pas	(revision 13256)
+++ compiler/cmsgs.pas	(working copy)
@@ -52,7 +52,7 @@
     procedure ClearIdx;
     procedure CreateIdx;
     function  GetPChar(nr:longint):pchar;
-    function  ClearVerbosity(nr:longint):boolean;
+    function SetVerbosity(nr:longint; ch:char):boolean;
     function  Get(nr:longint;const args:array of string):ansistring;
   end;
 
@@ -375,7 +375,7 @@
   GetPChar:=msgidx[nr div 1000]^[nr mod 1000];
 end;
 
-function TMessage.ClearVerbosity(nr:longint):boolean;
+function TMessage.SetVerbosity(nr:longint; ch:char):boolean;
 var
   hp: pchar;
   i, txtbegin: longint;
@@ -399,7 +399,7 @@
         end;
     end;
   for i:=0 to txtbegin-1 do
-    hp[i]:='_';
+    hp[i]:=ch;
   result:=true;
 end;
 
Index: compiler/msg/errore.msg
===================================================================
--- compiler/msg/errore.msg	(revision 13256)
+++ compiler/msg/errore.msg	(working copy)
@@ -2888,7 +2888,8 @@
 **2*_b : Write file names messages with full path
 **2*_v : Write fpcdebug.txt with     p : Write tree.log with parse tree
 **2*_    lots of debugging info      q : Show message numbers
-**2*_m<x>,<y> : Don't show messages numbered <x> and <y>
+**2*_m<x>_,<y>w : Messages verbosity remaping.
+**2*_    Don't show message numbered <x>, msg <y> treat as warning
 3*1W<x>_Target-specific options (targets)
 A*1W<x>_Target-specific options (targets)
 P*1W<x>_Target-specific options (targets)
Index: packages/fcl-db/src/base/dataset.inc
msgremap.patch (2,986 bytes)

Florian

2009-06-11 18:35

administrator   ~0028478

I propose to use
-vm5024-,5025w,5026e
instead as syntax. Though I'am still not completly happy with this syntax, it's still not intuitive imo. Anybody a better idea?

Jonas Maebe

2009-06-11 18:37

manager   ~0028479

Whatever the syntax, I'd propose to prevent downgrading and disabling errors and fatal errors, because that may cause compiler crashes and/or invalid code generation.

2009-06-16 08:52

 

msgremap1.patch (3,129 bytes)
Index: compiler/verbose.pas
===================================================================
--- compiler/verbose.pas	(revision 13256)
+++ compiler/verbose.pas	(working copy)
@@ -177,11 +177,13 @@
       end;
 
 
-    function ClearMessageVerbosity(s: string; var i: integer): boolean;
+    function SetMessageVerbosity(s: string; var i: integer): boolean;
       var
         tok : string;
         code : longint;
         msgnr: longint;
+        len : longint;
+        ch : char;
       begin
         { delete everything up to and including 'm' }
         delete(s,1,i);
@@ -192,10 +194,17 @@
           tok:=GetToken(s,',');
           if (tok='') then
             break;
+          len := length(tok);
+          ch := tok[len];
+          if ch = '-' then
+            ch := '_'; { syntactic sugar }
+          if not (ch in ['f', 'e', 'w', 'n', 'h', 'i', '_']) then
+            exit;
+          delete(tok, len, 1);
           val(tok, msgnr, code);
           if (code<>0) then
             exit;
-          if not msg^.clearverbosity(msgnr) then
+          if not msg^.setverbosity(msgnr, ch) then
             exit;
         until false;
         result:=true;
@@ -247,7 +256,7 @@
                             status.print_source_path:=true;
                        end;
                  'M' : if inverse or
-                          not ClearMessageVerbosity(s, i) then
+                          not SetMessageVerbosity(s, i) then
                          begin
                            result:=false;
                            exit
Index: compiler/cmsgs.pas
===================================================================
--- compiler/cmsgs.pas	(revision 13256)
+++ compiler/cmsgs.pas	(working copy)
@@ -52,7 +52,7 @@
     procedure ClearIdx;
     procedure CreateIdx;
     function  GetPChar(nr:longint):pchar;
-    function  ClearVerbosity(nr:longint):boolean;
+    function SetVerbosity(nr:longint; ch:char):boolean;
     function  Get(nr:longint;const args:array of string):ansistring;
   end;
 
@@ -375,7 +375,7 @@
   GetPChar:=msgidx[nr div 1000]^[nr mod 1000];
 end;
 
-function TMessage.ClearVerbosity(nr:longint):boolean;
+function TMessage.SetVerbosity(nr:longint; ch:char):boolean;
 var
   hp: pchar;
   i, txtbegin: longint;
@@ -399,7 +399,7 @@
         end;
     end;
   for i:=0 to txtbegin-1 do
-    hp[i]:='_';
+    hp[i]:=ch;
   result:=true;
 end;
 
Index: compiler/msg/errore.msg
===================================================================
--- compiler/msg/errore.msg	(revision 13256)
+++ compiler/msg/errore.msg	(working copy)
@@ -2888,7 +2888,8 @@
 **2*_b : Write file names messages with full path
 **2*_v : Write fpcdebug.txt with     p : Write tree.log with parse tree
 **2*_    lots of debugging info      q : Show message numbers
-**2*_m<x>,<y> : Don't show messages numbered <x> and <y>
+**2*_m<mn1>-,<mn2>w : Messages verbosity remaping. Modifiers: fewnhi-. 
+**2*_    Don't show message numbered <mn1>, msg <mn2> treat as warning
 3*1W<x>_Target-specific options (targets)
 A*1W<x>_Target-specific options (targets)
 P*1W<x>_Target-specific options (targets)
msgremap1.patch (3,129 bytes)

Petr-K

2009-06-16 09:10

reporter   ~0028567

I add another version of the patch. Modified syntax.
It is possible use -vm5054- -vm5026e syntax or commpressed -vm5024-,5026e too.
Added check for modifiers, only ['f', 'e', 'w', 'n', 'h', 'i', '_'] are allowed.
I'am not sure if this is complete set.

About disabling errors -- I think that user which uses message remaping knows what to do. In fpc exists for example parameter -Se<x> which allows halt after <x> errors.

Jonas Maebe

2009-06-16 10:02

manager   ~0028568

Last edited: 2009-06-16 10:58

-Se<x> does not mean that the compiler will successfully compile a program with <x-1> errors. It only means that the compiler will continue to try parsing the source code of the current unit until <x> errors have been found. As soon as one error is detected, the source will never be successfully compiled.

I am also pretty sure that almost no one will know what they are really doing if they would disable a particular error. At least I could not tell you what would happen for most error message when disabling them.

2009-06-16 10:54

 

msgremap2.patch (3,227 bytes)
Index: compiler/verbose.pas
===================================================================
--- compiler/verbose.pas	(revision 13256)
+++ compiler/verbose.pas	(working copy)
@@ -177,11 +177,13 @@
       end;
 
 
-    function ClearMessageVerbosity(s: string; var i: integer): boolean;
+    function SetMessageVerbosity(s: string; var i: integer): boolean;
       var
         tok : string;
         code : longint;
         msgnr: longint;
+        len : longint;
+        ch : char;
       begin
         { delete everything up to and including 'm' }
         delete(s,1,i);
@@ -192,10 +194,17 @@
           tok:=GetToken(s,',');
           if (tok='') then
             break;
+          len := length(tok);
+          ch := tok[len];
+          if ch = '-' then
+            ch := '_'; { syntactic sugar }
+          if not (ch in ['f', 'e', 'w', 'n', 'h', 'i', '_']) then
+            exit;
+          delete(tok, len, 1);
           val(tok, msgnr, code);
           if (code<>0) then
             exit;
-          if not msg^.clearverbosity(msgnr) then
+          if not msg^.setverbosity(msgnr, ch) then
             exit;
         until false;
         result:=true;
@@ -247,7 +256,7 @@
                             status.print_source_path:=true;
                        end;
                  'M' : if inverse or
-                          not ClearMessageVerbosity(s, i) then
+                          not SetMessageVerbosity(s, i) then
                          begin
                            result:=false;
                            exit
Index: compiler/cmsgs.pas
===================================================================
--- compiler/cmsgs.pas	(revision 13256)
+++ compiler/cmsgs.pas	(working copy)
@@ -52,7 +52,7 @@
     procedure ClearIdx;
     procedure CreateIdx;
     function  GetPChar(nr:longint):pchar;
-    function  ClearVerbosity(nr:longint):boolean;
+    function SetVerbosity(nr:longint; ch:char):boolean;
     function  Get(nr:longint;const args:array of string):ansistring;
   end;
 
@@ -375,7 +375,7 @@
   GetPChar:=msgidx[nr div 1000]^[nr mod 1000];
 end;
 
-function TMessage.ClearVerbosity(nr:longint):boolean;
+function TMessage.SetVerbosity(nr:longint; ch:char):boolean;
 var
   hp: pchar;
   i, txtbegin: longint;
@@ -399,7 +399,8 @@
         end;
     end;
   for i:=0 to txtbegin-1 do
-    hp[i]:='_';
+    if not (hp[i] in ['E', 'e', 'F', 'f']) then { do'nt allow modify error or fatal messages }
+      hp[i]:=ch;
   result:=true;
 end;
 
Index: compiler/msg/errore.msg
===================================================================
--- compiler/msg/errore.msg	(revision 13256)
+++ compiler/msg/errore.msg	(working copy)
@@ -2888,7 +2888,8 @@
 **2*_b : Write file names messages with full path
 **2*_v : Write fpcdebug.txt with     p : Write tree.log with parse tree
 **2*_    lots of debugging info      q : Show message numbers
-**2*_m<x>,<y> : Don't show messages numbered <x> and <y>
+**2*_m<mn1>-,<mn2>w : Messages verbosity remaping. Modifiers: fewnhi-. 
+**2*_    Don't show message numbered <mn1>, msg <mn2> treat as warning
 3*1W<x>_Target-specific options (targets)
 A*1W<x>_Target-specific options (targets)
 P*1W<x>_Target-specific options (targets)
msgremap2.patch (3,227 bytes)

Petr-K

2009-06-16 10:55

reporter   ~0028570

Ok, in msgremap2.patch is not allowed to remap 'F' and 'E' messages.

2009-06-20 17:00

 

msgremap3.patch (3,509 bytes)
Index: cmsgs.pas
===================================================================
--- cmsgs.pas	(revision 13286)
+++ cmsgs.pas	(working copy)
@@ -52,7 +52,7 @@
     procedure ClearIdx;
     procedure CreateIdx;
     function  GetPChar(nr:longint):pchar;
-    function  ClearVerbosity(nr:longint):boolean;
+    function  SetVerbosity(nr:longint; ch:char):boolean;
     function  Get(nr:longint;const args:array of string):ansistring;
   end;
 
@@ -375,10 +375,11 @@
   GetPChar:=msgidx[nr div 1000]^[nr mod 1000];
 end;
 
-function TMessage.ClearVerbosity(nr:longint):boolean;
+function TMessage.SetVerbosity(nr:longint; ch:char):boolean;
 var
   hp: pchar;
   i, txtbegin: longint;
+  changed: boolean;
 begin
    result:=false;
   if ((nr div 1000) < low(msgidx)) or
@@ -398,9 +399,14 @@
           break;
         end;
     end;
+  changed:=false;
   for i:=0 to txtbegin-1 do
-    hp[i]:='_';
-  result:=true;
+    if not (hp[i] in ['E', 'e', 'F', 'f']) then { do'nt allow modify error or fatal messages }
+      begin
+        hp[i]:=ch;
+        changed:=true;
+      end;
+  result:=changed;
 end;
 
 function TMessage.Get(nr:longint;const args:array of string):ansistring;
Index: verbose.pas
===================================================================
--- verbose.pas	(revision 13286)
+++ verbose.pas	(working copy)
@@ -177,11 +177,13 @@
       end;
 
 
-    function ClearMessageVerbosity(s: string; var i: integer): boolean;
+    function SetMessageVerbosity(s: string; var i: integer): boolean;
       var
         tok : string;
         code : longint;
         msgnr: longint;
+        len : longint;
+        ch : char;
       begin
         { delete everything up to and including 'm' }
         delete(s,1,i);
@@ -192,10 +194,17 @@
           tok:=GetToken(s,',');
           if (tok='') then
             break;
+          len := length(tok);
+          ch := tok[len];
+          if ch = '-' then
+            ch := '_'; { syntactic sugar }
+          if not (ch in ['f', 'e', 'w', 'n', 'h', 'i', '_']) then
+            exit;
+          delete(tok, len, 1);
           val(tok, msgnr, code);
           if (code<>0) then
             exit;
-          if not msg^.clearverbosity(msgnr) then
+          if not msg^.setverbosity(msgnr, ch) then
             exit;
         until false;
         result:=true;
@@ -247,7 +256,7 @@
                             status.print_source_path:=true;
                        end;
                  'M' : if inverse or
-                          not ClearMessageVerbosity(s, i) then
+                          not SetMessageVerbosity(s, i) then
                          begin
                            result:=false;
                            exit
Index: msg/errore.msg
===================================================================
--- msg/errore.msg	(revision 13286)
+++ msg/errore.msg	(working copy)
@@ -2889,7 +2889,9 @@
 **2*_b : Write file names messages   p : Write tree.log with parse tree
 **2*_    with full path              v : Write fpcdebug.txt with
 **2*_                                    lots of debugging info
-**2*_m<x>,<y> : Don't show messages numbered <x> and <y>
+**2*_m : Message verbosity remapping. Modifiers: fewnhi- (fatal, error,
+**2*_    warning, note, hint, info, disable). Errors cannot be remapped.
+**2*_    E.g.: -vm1-,2w means "disable msg 1, msg 2 becomes a warning"
 3*1W<x>_Target-specific options (targets)
 A*1W<x>_Target-specific options (targets)
 P*1W<x>_Target-specific options (targets)
msgremap3.patch (3,509 bytes)

Jonas Maebe

2009-06-20 17:04

manager   ~0028643

I've attached a version of msgremap2.patch in which the error checking is corrected (now you get an error when you try to remap an error, instead of the compiler silently ignoring what you did) and some more explanations in the help.

But while working on it and starting on writing a test, I started to like this less and less. I don't really see the use of this feature (all tests I could come up with were extremely artificial), and the fact that syntax changes means that Lazarus' usage of it will also break (this is acceptable since it's an unreleased feature, but there should be a good reason for doing so).

So I'm not going to commit it. If someone else wants to take responsibility for committing/maintaining it and writing tests for it (and changing tests/test/tmsg*.pp so they work with the new syntax), feel free to do so.

Alexander S. Klenin

2009-06-22 03:45

reporter   ~0028676

I think that disabling of messages/hints is extremely useful,
but only if done _locally_ via compiler directive, not via a switch.

So something like {$WARNING 5054 OFF}/{$WARNING 5054 ON} would be
very nice to have, while the implementation proposed in this
issue in indeed of little use.

Jonas Maebe

2009-06-22 11:09

manager   ~0028679

There is already a switch to disable individual messages. What this patch adds is the ability to change e.g. a particular hint into a warning.

Florian

2009-08-12 18:37

administrator   ~0029793

The compiler should imo throw an error if a message cannot be remapped because it is an error or fatal error.

Jonas Maebe

2009-08-12 19:15

manager   ~0029795

> The compiler should imo throw an error if a message cannot be
> remapped because it is an error or fatal error.

My version of the attached patch should do that (see comment 0028643 above).

Issue History

Date Modified Username Field Change
2009-06-11 14:28 Petr-K New Issue
2009-06-11 14:28 Petr-K File Added: msgremap.patch
2009-06-11 18:35 Florian Note Added: 0028478
2009-06-11 18:37 Jonas Maebe Note Added: 0028479
2009-06-16 08:52 Petr-K File Added: msgremap1.patch
2009-06-16 09:10 Petr-K Note Added: 0028567
2009-06-16 10:02 Jonas Maebe Note Added: 0028568
2009-06-16 10:54 Petr-K File Added: msgremap2.patch
2009-06-16 10:55 Petr-K Note Added: 0028570
2009-06-16 10:58 Jonas Maebe Note Edited: 0028568
2009-06-20 17:00 Jonas Maebe File Added: msgremap3.patch
2009-06-20 17:04 Jonas Maebe Note Added: 0028643
2009-06-22 03:45 Alexander S. Klenin Note Added: 0028676
2009-06-22 11:09 Jonas Maebe Note Added: 0028679
2009-08-12 18:37 Florian Note Added: 0029793
2009-08-12 19:15 Jonas Maebe Note Added: 0029795