From patchwork Mon May 22 16:55:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 765495 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 3wWlCz5Hr0z9s7t for ; Tue, 23 May 2017 02:55:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xGn6Nl5u"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=HxyOgIkiDocct6M8F XjZExFafwwWw8CjGD6bN8xjQMHGr8SLKVaZH/owgkyxRGVblRp/82rmzIibsObIt 3D3gzwto5ctPwazt7DruMerZYs2R2N4/dlyTS3nzh0slc1dtUTalsWLPDfVAjNOx ylYkWRLiIbZHHbeyaVCQhdMKfw= 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 :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=Q4rd2rOOJGwcp94MF6QNd08 J7Rg=; b=xGn6Nl5u/xOK4ItiVXDVDhg+nSikYWUxYrq/fSLifX18fNqYbte/CIa KJMAHfFV+TqBemTENAk3N+lJdwGeKg6AqtTCQLjkGE851TGnneZzSAn/7+UcarK5 KeS8AwkUuhOX2PZquaaE6DF1Ave0c3IRsA8wSvrr10yIdpkvZnQM= Received: (qmail 92369 invoked by alias); 22 May 2017 16:55:43 -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 91987 invoked by uid 89); 22 May 2017 16:55:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=Excellent, HCC:D*net, (unknown), writers X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 22 May 2017 16:55:37 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1dCqcL-00026k-P3 from Tom_deVries@mentor.com ; Mon, 22 May 2017 09:55:37 -0700 Received: from [127.0.0.1] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 22 May 2017 17:55:32 +0100 Subject: Re: [RFC, testsuite] Add dg-save-linenr To: Rainer Orth CC: David Malcolm , Mike Stump , GCC Patches , Jakub Jelinek , Jeff Law References: <1493047222.9106.82.camel@redhat.com> <464d854a-3387-ca8f-86bb-54cfc9da8767@mentor.com> From: Tom de Vries Message-ID: <9feb5b24-5ba2-4316-c8d1-012d5a297029@mentor.com> Date: Mon, 22 May 2017 18:55:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) On 05/16/2017 03:12 PM, Rainer Orth wrote: > Hi Tom, > > sorry for chiming in so very late: I've been on vacation and sick in > between... > thanks for review anyway. >> On 04/24/2017 05:20 PM, David Malcolm wrote: >>> On Sat, 2017-04-22 at 19:49 +0200, Tom de Vries wrote: >>>> Hi, >>>> >>>> there are currently two types of line number supported in >>>> dg-{error,warning,message,bogus} directives: absolute and relative. >>>> With an absolute line number, it's immediately clear what line number >>>> is >>>> meant, but when a line is added at the start of the file, the line >>>> number needs to be updated. With a relative line number, that >>>> problem >>>> is solved, but when relative line numbers become large, it becomes >>>> less >>>> clear what line it refers to, and when adding a line inbetween the >>>> directive using the relative line number and the line it refers to, >>>> the >>>> relative line number still needs to be updated. >>>> >>>> This patch adds a directive dg-save-linenr with argument varname, >>>> that >>>> saves the line number of the directive in a variable varname, which >>>> can >>>> be used as line number in dg directives. >>>> >>>> Testing status: >>>> - tested updated test-case objc.dg/try-catch-12.m >>>> - ran tree-ssa.exp >>>> >>>> RFC: >>>> - good idea? >>> >>> Excellent idea; thanks! There are various places where I'd find this >>> useful. >>> >>>> - naming of directive dg-save-linenr (dg-linenr, dg-save-line-nr, >>>> dg-save-lineno, dg-save-line-number, etc) >>> >>> How about just "dg-line"? (if it's not already taken) >> >> Done. > > I'd have preferred dg-linenum: it clarifiers that it's a number and we > have precedent in DejaGnu's dg-linenum-format and dg-format-linenum... > I see. I'll leave it dg-line for now, but I'll mention the dg-linenum variant upstream. >>>> - error message formulation >>> >>> Nit: the new function should have a leading comment, explaining the >>> usage. >>> >> >> Done. > > Not only that, but the new proc needs documenting in sourcebuild.texi. Attached patch adds the missing documentation. It looks like this in gccint.info: ... '{ dg-line LINENUMVAR }' This DejaGnu directive sets the variable LINENUMVAR to the line number of the source line. The variable LINENUMVAR can then be used in subsequent 'dg-error', 'dg-warning', 'dg-message' and 'dg-bogus' directives. For example: int a; /* { dg-line first_def_a } */ float a; /* { dg-error "conflicting types of" } */ /* { dg-message "previous declaration of" "" { target *-*-* } first_def_a } */ ... Note: AFAIK, dg-line does not work in the gnat testsuite. This is similar to PR80219 for relative line numbers. I'm not sure if we should mention this here, or how. OK for trunk like this? > (It's already way too hard for testsuite writers to find their way with > the documentation; if parts are missing, it gets next to impossible.) > Ack. I think the relative line numbers are also not documented. > Besides, it may be worthwhile contributing/suggesting this upstream. Will do. Thanks, - Tom Document dg-line directive 2017-05-22 Tom de Vries * doc/sourcebuild.texi: Document dg-line directive. --- gcc/doc/sourcebuild.texi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 84d9a22..a887337 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1180,6 +1180,18 @@ associated with the bogus message. It is usually used with @samp{xfail} to indicate that the message is a known problem for a particular set of targets. +@item @{ dg-line @var{linenumvar} @} +This DejaGnu directive sets the variable @var{linenumvar} to the line number of +the source line. The variable @var{linenumvar} can then be used in subsequent +@code{dg-error}, @code{dg-warning}, @code{dg-message} and @code{dg-bogus} +directives. For example: + +@smallexample +int a; /* @{ dg-line first_def_a @} */ +float a; /* @{ dg-error "conflicting types of" @} */ +/* @{ dg-message "previous declaration of" "" @{ target *-*-* @} first_def_a @} */ +@end smallexample + @item @{ dg-excess-errors @var{comment} [@{ target/xfail @var{selector} @}] @} This DejaGnu directive indicates that the test is expected to fail due to compiler messages that are not handled by @samp{dg-error},