From patchwork Fri Aug 1 13:26:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 375755 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 54E87140119 for ; Fri, 1 Aug 2014 23:26:37 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=aCPmiZUGNQ4CDZ5xVZn1g/TvAAtgEZ8U0p7pzqKHFWQkyhFwA3 vvyXe6c2W4jyEGpHA2lqtmBBfN4DRcxfyL40Ij7bMqWaHgCgRY+L+1U0J/vtXKPQ M4Mx6zwPzgCYrj/PNPXRaKLB7f9yCvMEr9+mX/WZ4wY5KO8wZEkavqiKM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=p6B38iCJiDaE87FHTzKK+ErdU1Y=; b=TwFzxktu7vOJl/FZCHIl FP5FkJ/Kd0axK1Z70gVFBbWb6+/z12xxJduKMriFIRpVxS0VAVnO2I5SbNn1Lj9Q T+1b+jK38n9K+xGFgQgzngGU8M7Yty38HKz5FBZoSF6uMaC2s9EvbwxgqhhpMZmr A3k/1HdyMh+uDDXZB3AK5is= Received: (qmail 13566 invoked by alias); 1 Aug 2014 13:26:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 13556 invoked by uid 89); 1 Aug 2014 13:26:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 01 Aug 2014 13:26:28 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 67A6B116279; Fri, 1 Aug 2014 09:26:26 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Yp9KcD-EJdSs; Fri, 1 Aug 2014 09:26:26 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [IPv6:2620:20:4000:0:a6ba:dbff:fe26:1f63]) by rock.gnat.com (Postfix) with ESMTP id 4B8C811625A; Fri, 1 Aug 2014 09:26:26 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 489CA91976; Fri, 1 Aug 2014 09:26:26 -0400 (EDT) Date: Fri, 1 Aug 2014 09:26:26 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Improved handling of info messages Message-ID: <20140801132626.GA25100@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) The count of info messages is now separated from the count of warnings and -gnatwe never turns info messages into errors. The following compiles as shown, and generates object code since no error is found when compilation options -gnatwe -gnatld7 -gnatj55 are used. Compiling: infoerr.adb 1. with Text_IO; use Text_IO; 2. procedure InfoErr is 3. J : Natural; 4. begin 5. J := 1; 6. <> | >>> info: code between label and backwards goto rewritten as loop 7. Put_Line (J'Img); 8. J := J + 1; 9. if J > 3 then 10. goto DONE; 11. end if; 12. goto ENTER; 13. <> 14. null; 15. end; 15 lines: No errors, 1 info message Tested on x86_64-pc-linux-gnu, committed on trunk 2014-08-01 Robert Dewar * atree.ads (Info_Messages): New counter. * err_vars.ads: Minor comment update. * errout.adb (Delete_Warning_And_Continuations): Deal with new Info_Messages counter. (Error_Msg_Internal): ditto. (Delete_Warning): ditto. (Initialize): ditto. (Write_Error_Summary): ditto. (Output_Messages): ditto. (To_Be_Removed): ditto. * erroutc.adb (Delete_Msg): Deal with Info_Messages counter. (Compilation_Errors): ditto. * errutil.adb (Error_Msg): Deal with Info_Messages counter. (Finalize): ditto. (Initialize): ditto. * sem_prag.adb (Analyze_Pragma): Minor comment addition. * gnat_ugn.texi: Document that -gnatwe does not affect info messages. Index: atree.ads =================================================================== --- atree.ads (revision 213263) +++ atree.ads (working copy) @@ -313,8 +313,13 @@ Warnings_Detected : Nat := 0; -- Number of warnings detected. Initialized to zero at the start of - -- compilation. Initialized for -gnatVa use, see comment above. + -- compilation. Initialized for -gnatVa use, see comment above. This + -- count includes the count of style and info messages. + Info_Messages : Nat := 0; + -- Number of info messages generated. Info messages are neved treated as + -- errors (whether from use of the pragma, or the compiler switch -gnatwe). + Warnings_Treated_As_Errors : Nat := 0; -- Number of warnings changed into errors as a result of matching a pattern -- given in a Warning_As_Error configuration pragma. Index: err_vars.ads =================================================================== --- err_vars.ads (revision 213431) +++ err_vars.ads (working copy) @@ -39,10 +39,10 @@ -- from invalid values in such cases. -- Note on error counts (Serious_Errors_Detected, Total_Errors_Detected, - -- Warnings_Detected). These counts might more logically appear in this - -- unit, but we place them in atree.ads, because of licensing issues. We - -- need to be able to access these counts from units that have the more - -- general licensing conditions. + -- Warnings_Detected, Info_Messages). These counts might more logically + -- appear in this unit, but we place them instead in atree.ads, because of + -- licensing issues. We need to be able to access these counts from units + -- that have the more general licensing conditions. ---------------------------------- -- Error Message Mode Variables -- Index: errout.adb =================================================================== --- errout.adb (revision 213369) +++ errout.adb (working copy) @@ -261,8 +261,12 @@ M.Deleted := True; Warnings_Detected := Warnings_Detected - 1; + if M.Info then + Info_Messages := Info_Messages - 1; + end if; + if M.Warn_Err then - Warnings_Treated_As_Errors := Warnings_Treated_As_Errors + 1; + Warnings_Treated_As_Errors := Warnings_Treated_As_Errors - 1; end if; end if; @@ -1132,6 +1136,10 @@ if Errors.Table (Cur_Msg).Warn or else Errors.Table (Cur_Msg).Style then Warnings_Detected := Warnings_Detected + 1; + if Errors.Table (Cur_Msg).Info then + Info_Messages := Info_Messages + 1; + end if; + else Total_Errors_Detected := Total_Errors_Detected + 1; @@ -1340,8 +1348,12 @@ Errors.Table (E).Deleted := True; Warnings_Detected := Warnings_Detected - 1; + if Errors.Table (E).Info then + Info_Messages := Info_Messages - 1; + end if; + if Errors.Table (E).Warn_Err then - Warnings_Treated_As_Errors := Warnings_Treated_As_Errors + 1; + Warnings_Treated_As_Errors := Warnings_Treated_As_Errors - 1; end if; end if; end Delete_Warning; @@ -1566,6 +1578,7 @@ Total_Errors_Detected := 0; Warnings_Treated_As_Errors := 0; Warnings_Detected := 0; + Info_Messages := 0; Warnings_As_Errors_Count := 0; Cur_Msg := No_Error_Msg; List_Pragmas.Init; @@ -1656,8 +1669,7 @@ begin -- Extra blank line if error messages or source listing were output - if Total_Errors_Detected + Warnings_Detected > 0 - or else Full_List + if Total_Errors_Detected + Warnings_Detected > 0 or else Full_List then Write_Eol; end if; @@ -1666,8 +1678,8 @@ -- This normally goes to Standard_Output. The exception is when brief -- mode is not set, verbose mode (or full list mode) is set, and -- there are errors. In this case we send the message to standard - -- error to make sure that *something* appears on standard error in - -- an error situation. + -- error to make sure that *something* appears on standard error + -- in an error situation. if Total_Errors_Detected + Warnings_Detected /= 0 and then not Brief_Output @@ -1702,12 +1714,12 @@ Write_Str (" errors"); end if; - if Warnings_Detected /= 0 then + if Warnings_Detected - Info_Messages /= 0 then Write_Str (", "); Write_Int (Warnings_Detected); Write_Str (" warning"); - if Warnings_Detected /= 1 then + if Warnings_Detected - Info_Messages /= 1 then Write_Char ('s'); end if; @@ -1727,6 +1739,16 @@ end if; end if; + if Info_Messages /= 0 then + Write_Str (", "); + Write_Int (Info_Messages); + Write_Str (" info message"); + + if Info_Messages > 1 then + Write_Char ('s'); + end if; + end if; + Write_Eol; Set_Standard_Output; end Write_Error_Summary; @@ -2027,8 +2049,9 @@ Write_Max_Errors; if Warning_Mode = Treat_As_Error then - Total_Errors_Detected := Total_Errors_Detected + Warnings_Detected; - Warnings_Detected := 0; + Total_Errors_Detected := + Total_Errors_Detected + Warnings_Detected - Info_Messages; + Warnings_Detected := Info_Messages; end if; end Output_Messages; @@ -2200,6 +2223,11 @@ and then not Errors.Table (E).Uncond then Warnings_Detected := Warnings_Detected - 1; + + if Errors.Table (E).Info then + Info_Messages := Info_Messages - 1; + end if; + return True; -- No removal required Index: erroutc.adb =================================================================== --- erroutc.adb (revision 213263) +++ erroutc.adb (working copy) @@ -143,7 +143,7 @@ if Errors.Table (D).Warn_Err then Warnings_Treated_As_Errors := - Warnings_Treated_As_Errors + 1; + Warnings_Treated_As_Errors - 1; end if; else @@ -233,7 +233,7 @@ function Compilation_Errors return Boolean is begin return Total_Errors_Detected /= 0 - or else (Warnings_Detected /= 0 + or else (Warnings_Detected - Info_Messages /= 0 and then Warning_Mode = Treat_As_Error) or else Warnings_Treated_As_Errors /= 0; end Compilation_Errors; Index: errutil.adb =================================================================== --- errutil.adb (revision 213431) +++ errutil.adb (working copy) @@ -309,6 +309,10 @@ then Warnings_Detected := Warnings_Detected + 1; + if Errors.Table (Cur_Msg).Info then + Info_Messages := Info_Messages + 1; + end if; + else Total_Errors_Detected := Total_Errors_Detected + 1; @@ -536,19 +540,19 @@ Write_Str (" errors"); end if; - if Warnings_Detected /= 0 then + if Warnings_Detected - Info_Messages /= 0 then Write_Str (", "); - Write_Int (Warnings_Detected); + Write_Int (Warnings_Detected - Info_Messages); Write_Str (" warning"); - if Warnings_Detected /= 1 then + if Warnings_Detected - Info_Messages /= 1 then Write_Char ('s'); end if; if Warning_Mode = Treat_As_Error then Write_Str (" (treated as error"); - if Warnings_Detected /= 1 then + if Warnings_Detected - Info_Messages /= 1 then Write_Char ('s'); end if; @@ -575,8 +579,9 @@ end if; if Warning_Mode = Treat_As_Error then - Total_Errors_Detected := Total_Errors_Detected + Warnings_Detected; - Warnings_Detected := 0; + Total_Errors_Detected := + Total_Errors_Detected + Warnings_Detected - Info_Messages; + Warnings_Detected := Info_Messages; end if; -- Prevent displaying the same messages again in the future @@ -596,6 +601,7 @@ Serious_Errors_Detected := 0; Total_Errors_Detected := 0; Warnings_Detected := 0; + Info_Messages := 0; Cur_Msg := No_Error_Msg; -- Initialize warnings table, if all warnings are suppressed, supply Index: gnat_ugn.texi =================================================================== --- gnat_ugn.texi (revision 213446) +++ gnat_ugn.texi (working copy) @@ -4995,6 +4995,8 @@ The warning string still appears, but the warning messages are counted as errors, and prevent the generation of an object file. Note that this is the only -gnatw switch that affects the handling of style check messages. +Note also that this switch has no effect on info (information) messages, which +are not treated as errors if this switch is present. @item -gnatw.e @emph{Activate every optional warning} Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 213448) +++ sem_prag.adb (working copy) @@ -20715,6 +20715,8 @@ -- Warning_As_Error -- ---------------------- + -- pragma Warning_As_Error (static_string_EXPRESSION); + when Pragma_Warning_As_Error => GNAT_Pragma; Check_Arg_Count (1);