From patchwork Wed Jan 2 09:38:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 208979 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 150232C0094 for ; Wed, 2 Jan 2013 20:38:29 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1357724310; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=jNr2Le11CbaJYc/L58Op Tj7pGFw=; b=Lee9McPlEOf/MBut2a2lWLayzTB2ChIJa1mPKp61wI4wiW0CMch9 3MsFJuex8XNFHhY0rk3kpvIOXcQeXzzu5AF7XZQMaUhTCLC/obUA4/00HTWseXTe lUwW843KIh9koWGvvSBGu/COqy3rkr3FNBnecLAPULE8kFJKV/eeplc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=UvYoBCjskkIRwgpMcvedikgz/cFGxs6Pv5Ux/3vVz0NPGKiIkx3cg2pj/xIWjl 9DbOgTcP4TinJ6QohQIlMOaLuNi0xGWld6HUnuOKGk+XL0hfYaNp3ayeRKpq3mDs z/UqYhlJIuYqys8PCcPeQ/C6luGXjNL9yfu53iSaNKOC8=; Received: (qmail 20785 invoked by alias); 2 Jan 2013 09:38:20 -0000 Received: (qmail 20746 invoked by uid 22791); 2 Jan 2013 09:38:19 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_05, KHOP_SPAMHAUS_DROP, RCVD_IN_HOSTKARMA_NO 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; Wed, 02 Jan 2013 09:38:15 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 9A2321C68F3; Wed, 2 Jan 2013 04:38:14 -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 ZhLJjHSCwXwr; Wed, 2 Jan 2013 04:38:14 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 6EA101C6256; Wed, 2 Jan 2013 04:38:14 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 6A1AC3FF09; Wed, 2 Jan 2013 04:38:14 -0500 (EST) Date: Wed, 2 Jan 2013 04:38:14 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Thomas Quinot Subject: [Ada] Debug information for code generated for pragma Check Message-ID: <20130102093814.GA31164@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 This change corrects an anomaly in the source locations produced in debug information for code implementing a pragma Check that could cause incorrect coverage analyses. Tested on x86_64-pc-linux-gnu, committed on trunk 2013-01-02 Thomas Quinot * exp_prag.adb (Expand_Pragma_Check): The statements generated for the pragma must have the sloc of the pragma, not the sloc of the condition, otherwise this creates anomalies in the generated debug information that confuse coverage analysis tools. Index: exp_prag.adb =================================================================== --- exp_prag.adb (revision 194781) +++ exp_prag.adb (working copy) @@ -274,18 +274,18 @@ -------------------------- procedure Expand_Pragma_Check (N : Node_Id) is + Loc : constant Source_Ptr := Sloc (N); + -- Location of the pragma node. Note: it is important to use this + -- location (and not the location of the expression) for the generated + -- statements, otherwise the implicit return statement in the body + -- of a pre/postcondition subprogram may inherit the source location + -- of part of the expression, which causes confusing debug information + -- to be generated, which interferes with coverage analysis tools. + Cond : constant Node_Id := Arg2 (N); Nam : constant Name_Id := Chars (Arg1 (N)); Msg : Node_Id; - Loc : constant Source_Ptr := Sloc (First_Node (Cond)); - -- Source location used in the case of a failed assertion. Note that - -- the source location of the expression is not usually the best choice - -- here. 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 the assertion, which is the effect - -- of the First_Node call here. - begin -- We already know that this check is enabled, because otherwise the -- semantic pass dealt with rewriting the assertion (see Sem_Prag) @@ -362,7 +362,15 @@ else declare - Msg_Loc : constant String := Build_Location_String (Loc); + Msg_Loc : constant String := + Build_Location_String (Sloc (First_Node (Cond))); + -- Source location used in the case of a failed assertion: + -- point to the failing condition, not Loc. Note that the + -- source location of the expression is not usually the best + -- choice here. 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 the + -- condition, which is the effect of the First_Node call here. begin Name_Len := 0;