From patchwork Sun Dec 18 12:51:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 88377 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp703076qgi; Sun, 18 Dec 2016 04:51:29 -0800 (PST) X-Received: by 10.84.218.8 with SMTP id q8mr25095859pli.138.1482065489382; Sun, 18 Dec 2016 04:51:29 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 133si15065202pgh.252.2016.12.18.04.51.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Dec 2016 04:51:29 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-444699-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-444699-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-444699-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=pvKFrhGRaFwb0nJ hleGMatzVBhwhBLxQTDn7mxV4fKxImeX7+8uMWG19upXU47iPbLKtCPTJ+44JJ33 w6ondOJtvv3HzPEwlKuWxZP1S5abrdVFL5iOH/v7ZUqRzzBkzKZqkY+RGgwbqgol QRPhun9DJmNAIJ+WultD8WcfO6/A= 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 :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=Rw+zeB8XuZP5xS3UJRYUn KTnvvE=; b=IZBt+CM3+c1aibtLh163zoUe2IldnvX76hI47zjhQeGr+V3d7qknG aecaRnFP4p6teLqtNQu9KXZ/w78myG4OSVdMxn3fF9UKRj+pCA2hINV1Fc4yWrS1 UXHQnymgOddo/XwFcNpLAxy/AAOo+XkKwLbgH9c7hsB49figNA6f4U= Received: (qmail 67635 invoked by alias); 18 Dec 2016 12:51: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 67595 invoked by uid 89); 18 Dec 2016 12:51:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=2016-12-18 X-HELO: mail-io0-f171.google.com Received: from mail-io0-f171.google.com (HELO mail-io0-f171.google.com) (209.85.223.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 18 Dec 2016 12:51:04 +0000 Received: by mail-io0-f171.google.com with SMTP id h30so133336687iod.2 for ; Sun, 18 Dec 2016 04:51:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=p2UJngM3OTh4pLADGrO7VQdOayCGlZbycR819/NrO9c=; b=Szd2DsajKHrn3ddz5kKzKF4jd4MEtsluVWgb9vYfFzeaVXZmn3R+WMWqNTOtYXrc+k TDqpj4qayizVDwEsFcoUjMyKLc4sqLamhBBX8cfE3/l8V0l0exgLsvX+t0j8p2xj/n3/ KTSxq1Du+Em2uS3RwSCCPOyKOQ1OmEqR9myhOMGv/L+lYToZspKbawTmUuWEcQLCKeKH ZDpcEKw7gdwiKBV8QNdEXA+cO942AUBi6eGn6uSYMjTgmMxE94HuTJ3XD7EoOi36zbcv 2MNtAcx9gyEF+tWPVMfjrdrXQXnS1jfElBy8Hi48To491vU4I/IMJcc1YHWHU5wlJCcQ vBsw== X-Gm-Message-State: AIkVDXI3w5IOSQ3j2mq2nsEzp432v1EZ1s8VWeuvrouiegIsy1XVGFDGn5TPhDpP2TBaRT1cdVlG46Unpz6rKryg X-Received: by 10.107.55.136 with SMTP id e130mr10613186ioa.76.1482065462956; Sun, 18 Dec 2016 04:51:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.47.92 with HTTP; Sun, 18 Dec 2016 04:51:02 -0800 (PST) In-Reply-To: <20161218123228.GM21933@tucnak> References: <20161218123228.GM21933@tucnak> From: Prathamesh Kulkarni Date: Sun, 18 Dec 2016 18:21:02 +0530 Message-ID: Subject: Re: [gimplefe] reject invalid pass name in startwith To: Jakub Jelinek Cc: gcc Patches , Richard Biener X-IsSubscribed: yes On 18 December 2016 at 18:02, Jakub Jelinek wrote: > On Sun, Dec 18, 2016 at 05:41:23PM +0530, Prathamesh Kulkarni wrote: >> --- a/gcc/c/gimple-parser.c >> +++ b/gcc/c/gimple-parser.c >> @@ -1046,6 +1046,17 @@ c_parser_gimple_pass_list (c_parser *parser) >> if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) >> return NULL; >> >> + if (pass) >> + { >> + char *full_passname = (char *) xmalloc (strlen ("tree-") + strlen (pass) + 1); >> + strcpy (full_passname, "tree-"); >> + strcat (full_passname, pass); > > Use > char *full_passname = concat ("tree-", pass, NULL); > instead? Thanks! Modified the patch to use concat(). Regards, Prathamesh > > Jakub 2016-12-18 Prathamesh Kulkarni c/ * gimple-parser.c (c_parser_gimple_pass_list): Reject invalid pass name. testsuite/ * gcc.dg/gimplefe-19.c: New test-case. diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index ddecaec..68d2d74 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -1046,6 +1046,15 @@ c_parser_gimple_pass_list (c_parser *parser) if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) return NULL; + if (pass) + { + char *full_passname = concat ("tree-", pass, NULL); + opt_pass *p = g->get_passes ()->get_pass_by_name (full_passname); + if (!p || p->type != GIMPLE_PASS) + error_at (c_parser_peek_token (parser)->location, + "%s is not a valid GIMPLE pass\n", pass); + free (full_passname); + } return pass; } diff --git a/gcc/testsuite/gcc.dg/gimplefe-19.c b/gcc/testsuite/gcc.dg/gimplefe-19.c new file mode 100644 index 0000000..bb5be33 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-19.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple" } */ + +void __GIMPLE (startwith ("combine")) foo () /* { dg-error "not a valid GIMPLE pass" } */ +{ + return; +}