This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Tested on i686-linux, committed on trunk. This patch implements a new specific control over warnings: pragma Warnings (On | Off, static_string_EXPRESSION); the string is a pattern that matches specific warning messages, it implements a limited form of regular expression matching * at start of string matches anything "*" in middle of string matches " followed by any text followed by " * at end of string matches anything. This can be used in two ways a) as a configuration pragma (Off only) in which case it suppresses all matching messages b) as an Off/ON pair (with matching pattern strings) to surround a specific warning and suppress it. In this case there must be matching On for the Off, and it must actually succeed in suppressing at least one warning. Here are examples: Compiling: k.adb 1. procedure k is 2. W,X,Y,Z : Integer; 3. begin 4. pragma Warnings (Off, """X"" may be referenced before*"); 5. X := X + 1; 6. pragma Warnings (On, """X"" may be referenced before*"); 7. 8. pragma Warnings (Off, """W"" may be referenced before"); | >>> warning: no warning suppressed by this pragma 9. W := W + 1; | >>> warning: "W" may be referenced before it has a value 10. pragma Warnings (On, """W"" may be referenced before"); 11. 12. pragma Warnings (Off, "*may be referenced before*"); 13. Y := Y + 1; 14. pragma Warnings (On, "*may be referenced before*"); 15. 16. pragma Warnings (Off, """*"" may be referenced before it has a value"); 17. Z := Z + 1; 18. pragma Warnings (On, """*"" may be referenced before it has a value"); 19. end k; 19 lines: No errors, 2 warnings Compiling: l.adb 1. procedure l is 2. X : Integer; 3. begin 4. pragma Warnings (Off, """X"" may be refrenced before"); | >>> warning: no warning suppressed by this pragma 5. X := X + 1; | >>> warning: "X" may be referenced before it has a value 6. pragma Warnings (On, """X"" may be refrenced before"); 7. 8. pragma Warnings (Off, "rubblish"); | >>> warning: pragma Warnings Off with no matching Warnings On 9. X := X + 1; 10. pragma Warnings (On, "rubbish"); | >>> warning: pragma Warnings On with no matching Warnings Off 11. end l; 11 lines: No errors, 4 warnings This patch also implements a new switch -gnatjnn which affects the output of error and warning messages. In normal mode (-gnatj not specified, or given a zero parameter), the behavior is as before. Each call to Error_Msg{_xx} results in a separate error or warning line, and these separate lines are counted as separate in the statistics of total errors and warnings. If a non-zero value is given for -gnatj, then the effect is to change the handling of messages significantly. First, a message and all its continuation lines are viewed as a single unit. Second, the text of this combined message is then split up so no single line is longer than the value specified for -gnatj. For instance -gnatj79 will ensure that messages fit nicely on an 80 character display. Another feature adds a \\ continuation, which is like \, except that it insists on the continuation starting a new line, even in -gnatjnn mode. The normal single \ continuation causes the text of the continuation message to be concatenated with what it follows, separated only by a comma. The following test program: procedure q (A : in out String) is begin A (1) := 'a'; end; in normal mode generates when compiled in -gnatv mode: 3. A (1) := 'a'; | >>> warning: index for "A" may assume lower bound of 1 >>> warning: suggested replacement: "A'First" 6 lines: No errors, 2 warnings But if compiled with -gnatv -gnatj60, we get 3. A (1) := 'a'; | >>> warning: index for "A" may assume lower bound of 1, suggested replacement: "A'First" 6 lines: No errors, 1 warning 2006-10-31 Robert Dewar <dewar@adacore.com> * erroutc.ads, erroutc.adb (Set_Specific_Warning_On): New procedure (Set_Specific_Warning_Off): New procedure (Warning_Specifically_Suppressed): New function (Validate_Specific_Warnings): New procedure (Output_Msg_Text): Complete rewrite to support -gnatjnn * err_vars.ads: Implement insertion character ~ (insert string)
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |