From patchwork Sat Jun 10 08:03:04 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: 774209 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 3wlBVp64Y4z9s9Y for ; Sat, 10 Jun 2017 18:03:29 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="UIF7aEMw"; 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:from:to:cc:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=R3YVmhjfwX2DXYKrw iuuP7MbwKdCJcUQ4hOG2dQVgZ/6c4S5Z3ZQKGetqCre7NX+tIphvxB3cdeNe1B9q L8WQ1k5PeFmo/1d29PolWvidzihZNq9UZDP5o9ris6aWD9Cj9uRjyYjwDnVuFrGq X0GXtT+OlPgDi3iqfSVN/PxORM= 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:from:to:cc:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=r9EwFaEEVuB+m79XQ14saJx 1Rjs=; b=UIF7aEMw6D9fPbawsIParyIBfoWKR3FK17PF1i0xV07pMYYFyIMxZlR KCXupxLjgm8Mt4zb9heiinz7c5DoLGkvM61hEfuo8w/bt6zdPFG0F9RPQm1d2f+D cVT4gkOgfRVUl2ObIxu6YCI+fobt9Nbc+Zl4EGlVIOW2qs/qhxCk= Received: (qmail 53537 invoked by alias); 10 Jun 2017 08:03:17 -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 53514 invoked by uid 89); 10 Jun 2017 08:03:15 -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 autolearn=ham version=3.3.2 spammy= 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; Sat, 10 Jun 2017 08:03:14 +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 1dJbMb-0007Kr-6m from Tom_deVries@mentor.com ; Sat, 10 Jun 2017 01:03:17 -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; Sat, 10 Jun 2017 09:03:12 +0100 Subject: Re: [RFC] Dejagnu patch to handle multi-line directives From: Tom de Vries To: GCC Patches CC: Jakub Jelinek , Rainer Orth , Mike Stump References: Message-ID: Date: Sat, 10 Jun 2017 10:03:04 +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) [ attached patch ] On 06/10/2017 09:57 AM, Tom de Vries wrote: > Hi, > > one thing that has bothered me on a regular basis is the inability to > spread long dejagnu directives over multiple lines. > > I've written a demonstrator patch (for the dejagnu sources) and tested > it by splitting this 108 chars line: > ... > /* { dg-additional-options "-DSTACK_SIZE=[dg-effective-target-value > stack_size]" { target { stack_size } } } */ > ... > into: > ... > /* { dg-additional-options } > { dg-dc "-DSTACK_SIZE=[dg-effective-target-value stack_size]" } > { dg-dc { target { stack_size } } } */ > ... > > Good idea to fix this? > > Good idea to fix this like this? > > If so, any other comments, before I suggest this at dejagnu project? > > Thanks, > - Tom > Add dg-dc support --- lib/dg.exp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/lib/dg.exp b/lib/dg.exp index 7a894cb..67f46ab 100644 --- a/lib/dg.exp +++ b/lib/dg.exp @@ -181,15 +181,64 @@ proc dg-format-linenum { linenum } { # we return: # # { dg-prms-id 1 1234 } { dg-build 2 fatal "some comment" } +# +# Directive dg-dc (short for dg-directive-continue) can be used for multi-line +# directives. This: +# +# /* { dg-x a b c } */ +# +# is equivalent to: +# +# /* { dg-x } */ +# /* { dg-dc a b } */ +# /* { dg-dc c } */ +# +# and to: +# +# /* { dg-x a } */ +# /* { dg-dc b c} */ proc dg-get-options { prog } { set result "" - - set tmp [grep $prog "{\[ \t\]\+dg-\[-a-z\]\+\[ \t\]\+.*\[ \t\]\+}" line] + set cmd_prev "" + + set grep_pattern [join { + "{" + "\[ \t\]\+" + "dg-\[-a-z\]\+" + "\[ \t\]\+" + "(.*\[ \t\]\+)?" + "}" + } ""] + set tmp [grep $prog $grep_pattern line] if {![string match "" $tmp]} { + set pattern [join { + "(\[0-9\]+)" + "\[ \t\]+" + "{" + "\[ \t\]+" + "(dg-\[-a-z\]+)" + "\[ \t\]+" + "((.*)\[ \t\]+)?" + "}" + "\[^\}\]*" + "(\n|$)" + } ""] foreach i $tmp { - regexp "(\[0-9\]+)\[ \t\]+{\[ \t\]+(dg-\[-a-z\]+)\[ \t\]+(.*)\[ \t\]+}\[^\}\]*(\n|$)" $i i line cmd args - append result " { $cmd $line $args }" + regexp $pattern $i dummy line cmd ws_args args + if { "$cmd" == "dg-dc" } { + set args_prev "$args_prev $args" + } else { + if { "$cmd_prev" != "" } { + append result " { $cmd_prev $line_prev $args_prev }" + } + set cmd_prev $cmd + set line_prev $line + set args_prev "$args" + } + } + if { "$cmd_prev" != "" } { + append result " { $cmd_prev $line_prev $args_prev }" } } return $result