From patchwork Mon Jun 14 13:47:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 55535 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]) by ozlabs.org (Postfix) with SMTP id 603371007D1 for ; Mon, 14 Jun 2010 23:47:17 +1000 (EST) Received: (qmail 31842 invoked by alias); 14 Jun 2010 13:47:12 -0000 Received: (qmail 31748 invoked by uid 22791); 14 Jun 2010 13:47:10 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Jun 2010 13:47:03 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 98D3BCB021C; Mon, 14 Jun 2010 15:47:06 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6BzmMFsSvg3W; Mon, 14 Jun 2010 15:47:06 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 85A20CB01BA; Mon, 14 Jun 2010 15:47:06 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id ADE6ED9B31; Mon, 14 Jun 2010 15:47:13 +0200 (CEST) Date: Mon, 14 Jun 2010 15:47:13 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] minor improvement to handling of assertion/check messages Message-ID: <20100614134713.GA12751@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 Following a previous change, the "check/assertion will fail" message is posted on the expression rather than on the pragma keyword. This patch makes a similar change for the "check/assertion would fail" message as shown by the following test: Compiling: test_assert_warning.adb 1. procedure test_assert_warning is 2. begin 3. pragma Assert (Integer'Size = 700); | >>> warning: assertion would fail at run-time 4. pragma Check (Other_Check, Integer'Size = 700); | >>> warning: check would fail at run-time 5. pragma Assert (False); 6. if Integer'Size > 600 then 7. pragma Assert (Integer'Size = 700); 8. pragma Check (Other_Check, Integer'Size = 700); 9. null; 10. end if; 11. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-14 Robert Dewar * sem_res.adb (Resolve_Short_Circuit): Fix sloc of "assertion/check would fail" msg. Index: sem_res.adb =================================================================== --- sem_res.adb (revision 160734) +++ sem_res.adb (working copy) @@ -7846,15 +7846,15 @@ package body Sem_Res is then null; else - -- Issue warning. Note that we don't want to make this - -- an unconditional warning, because if the assert is - -- within deleted code we do not want the warning. But - -- we do not want the deletion of the IF/AND-THEN to - -- take this message with it. We achieve this by making - -- sure that the expanded code points to the Sloc of - -- the expression, not the original pragma. + -- Issue warning. We do not want the deletion of the + -- IF/AND-THEN to take this message with it. We achieve + -- this by making sure that the expanded code points to + -- the Sloc of the expression, not the original pragma. - Error_Msg_N ("?assertion would fail at run-time", Orig); + Error_Msg_N + ("?assertion would fail at run-time!", + Expression + (First (Pragma_Argument_Associations (Orig)))); end if; end; @@ -7877,7 +7877,10 @@ package body Sem_Res is then null; else - Error_Msg_N ("?check would fail at run-time", Orig); + Error_Msg_N + ("?check would fail at run-time!", + Expression + (Last (Pragma_Argument_Associations (Orig)))); end if; end; end if;