From patchwork Tue Dec 16 14:28:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 42338 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7EB462456A for ; Tue, 16 Dec 2014 14:29:23 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id q1sf8759797lam.10 for ; Tue, 16 Dec 2014 06:29:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to :content-type:x-original-sender:x-original-authentication-results; bh=z1lkHrePHkEK4atX9/zkoDz8rBCD5qEFDjnaYas7Mb4=; b=g+gwMbqGXwqr17UjIHHcyYzjDHiQzWpVZlPQrcBRinu/J3PcYhMEBbqtoUYlCx0wMP P8+KdDtQibzSR3oT0XFHLUlm5hkKxrjgLOR8WxRuP69H1CUi79+fvEYvqxESIUIBOod9 +Z978jjjkAYV8Cz2mxlA145VP8OFtsDct+mwz5twrGktj6kLVPcURuXKFU53CcuLuwK4 ngzmP7iMTIY67ONqty9iQ0aqFIJOz21SzYDVCk+xvk4cQ1Z9i36IPgiewj0JHsRtMbAi J32kfnrXzzZc+M+E/P1Vk4X1+DYzN4VgHluzDxy79zlMcY+qAItO9IQK7khUaZS+nUIq 4IRg== X-Gm-Message-State: ALoCoQnJMOWkA6iERpvo22VBbob89F5q9Glz83OfYVCkb6Njo8MEYVOSnHKACgOh0/pySf8djfZz X-Received: by 10.180.85.72 with SMTP id f8mr515318wiz.0.1418740162481; Tue, 16 Dec 2014 06:29:22 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.135 with SMTP id s7ls955196las.33.gmail; Tue, 16 Dec 2014 06:29:22 -0800 (PST) X-Received: by 10.152.42.169 with SMTP id p9mr35974444lal.94.1418740162228; Tue, 16 Dec 2014 06:29:22 -0800 (PST) Received: from mail-lb0-x230.google.com (mail-lb0-x230.google.com. [2a00:1450:4010:c04::230]) by mx.google.com with ESMTPS id m4si912740laa.107.2014.12.16.06.29.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Dec 2014 06:29:21 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::230 as permitted sender) client-ip=2a00:1450:4010:c04::230; Received: by mail-lb0-f176.google.com with SMTP id p9so10788260lbv.7 for ; Tue, 16 Dec 2014 06:29:21 -0800 (PST) X-Received: by 10.112.135.6 with SMTP id po6mr2689258lbb.69.1418740161713; Tue, 16 Dec 2014 06:29:21 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp1053826lbb; Tue, 16 Dec 2014 06:29:19 -0800 (PST) X-Received: by 10.68.213.138 with SMTP id ns10mr60696033pbc.50.1418740159020; Tue, 16 Dec 2014 06:29:19 -0800 (PST) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ok3si1237946pdb.159.2014.12.16.06.29.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Dec 2014 06:29:19 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-387509-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 9806 invoked by alias); 16 Dec 2014 14:29:04 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 9773 invoked by uid 89); 16 Dec 2014 14:29:03 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f52.google.com Received: from mail-la0-f52.google.com (HELO mail-la0-f52.google.com) (209.85.215.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 16 Dec 2014 14:29:01 +0000 Received: by mail-la0-f52.google.com with SMTP id hs14so11492169lab.11 for ; Tue, 16 Dec 2014 06:28:58 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.112.147.199 with SMTP id tm7mr36270344lbb.92.1418740138150; Tue, 16 Dec 2014 06:28:58 -0800 (PST) Received: by 10.25.211.16 with HTTP; Tue, 16 Dec 2014 06:28:57 -0800 (PST) Date: Tue, 16 Dec 2014 19:58:57 +0530 Message-ID: Subject: [match-and-simplify] allow 't' only in user-defined predicates From: Prathamesh Kulkarni To: rguenther@suse.de, gcc-patches@gcc.gnu.org X-IsSubscribed: yes X-Original-Sender: prathamesh.kulkarni@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::230 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 This patch rejects 't' outside user-defined predicates. 2014-12-16 Prathamesh Kulkarni * genmatch.c (parser::parsing_match): New. (parser::parser): Initialize parsing_match to false. (parser::parse_pattern): Reset parsing_match when parsing user-defined predicate. (parser::parse_c_expr): Check if 't' is used when parsing_match is set. Thanks, Prathamesh Index: gcc/genmatch.c =================================================================== --- gcc/genmatch.c (revision 218778) +++ gcc/genmatch.c (working copy) @@ -2746,6 +2746,7 @@ vec simplifiers; vec user_predicates; bool parsing_match_operand; + bool parsing_match; }; /* Lexing helpers. */ @@ -3059,8 +3060,11 @@ /* If this is possibly a user-defined identifier mark it used. */ if (token->type == CPP_NAME) { - id_base *idb = get_operator ((const char *)CPP_HASHNODE - (token->val.node.node)->ident.str); + const char *lexeme = (const char *) CPP_HASHNODE (token->val.node.node)->ident.str; + if (strcmp (lexeme, "t") == 0 && !parsing_match) + fatal_at (token, "'t' is allowed only in predicates"); + + id_base *idb = get_operator (lexeme); user_id *p; if (idb && (p = dyn_cast (idb)) && p->is_oper_list) record_operlist (token->src_loc, p); @@ -3497,6 +3501,7 @@ parse_simplify (token->src_loc, simplifiers, NULL, NULL); else if (strcmp (id, "match") == 0) { + parsing_match = true; bool with_args = false; if (peek ()->type == CPP_OPEN_PAREN) { @@ -3530,6 +3535,7 @@ fatal_at (token, "non-matching number of match operands"); p->nargs = e ? e->ops.length () : 0; parse_simplify (token->src_loc, p->matchers, p, e); + parsing_match = false; } else if (strcmp (id, "for") == 0) parse_for (token->src_loc); @@ -3569,6 +3575,7 @@ oper_lists = vNULL; user_predicates = vNULL; parsing_match_operand = false; + parsing_match = false; const cpp_token *token = next (); while (token->type != CPP_EOF)