From patchwork Mon Nov 21 13:31:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 126779 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 6B3A6B720D for ; Tue, 22 Nov 2011 00:35:41 +1100 (EST) Received: (qmail 11329 invoked by alias); 21 Nov 2011 13:32:13 -0000 Received: (qmail 11223 invoked by uid 22791); 21 Nov 2011 13:32:07 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Nov 2011 13:31:48 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id C321E2BB26A; Mon, 21 Nov 2011 08:31:47 -0500 (EST) 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 PIdmtMqo-fhi; Mon, 21 Nov 2011 08:31:47 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id A1ADD2BAFD4; Mon, 21 Nov 2011 08:31:47 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 992B192BF6; Mon, 21 Nov 2011 08:31:47 -0500 (EST) Date: Mon, 21 Nov 2011 08:31:47 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [Ada] Locate error message on the first character of an assertion Message-ID: <20111121133147.GA4142@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 The source location of an expression may not be the best place to put a message, in the case of a failed assertion. For example, it gets located on the last "and" keyword in a chain of boolean expressiond and'ed together. It is best to put the message on the first character of an assertion, which is done here. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-11-21 Yannick Moy * exp_prag.adb (Expand_Pragma_Check): Place error on first character of expression. * sem_res.adb (Resolve_Short_Circuit): Place error on first character of expression. Index: exp_prag.adb =================================================================== --- exp_prag.adb (revision 181574) +++ exp_prag.adb (working copy) @@ -270,7 +270,7 @@ procedure Expand_Pragma_Check (N : Node_Id) is Cond : constant Node_Id := Arg2 (N); - Loc : constant Source_Ptr := Sloc (Cond); + Loc : constant Source_Ptr := Sloc (First_Node (Cond)); Nam : constant Name_Id := Chars (Arg1 (N)); Msg : Node_Id; Index: sem_res.adb =================================================================== --- sem_res.adb (revision 181574) +++ sem_res.adb (working copy) @@ -8668,7 +8668,7 @@ -- this by making sure that the expanded code points to -- the Sloc of the expression, not the original pragma. - Error_Msg_N + Error_Msg_F ("?assertion would fail at run time!", Expression (First (Pragma_Argument_Associations (Orig)))); @@ -8694,7 +8694,7 @@ then null; else - Error_Msg_N + Error_Msg_F ("?check would fail at run time!", Expression (Last (Pragma_Argument_Associations (Orig))));