From patchwork Tue May 8 10:35:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard Earnshaw \(lists\)" X-Patchwork-Id: 135146 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4213256lji; Tue, 8 May 2018 03:36:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrvqkSjL3KQ2Tqn3hH/I2cTqKNwpWx2SZIRFCk/m6gRagBUC6dzOdksTJS+IMmghJry/C6Q X-Received: by 2002:a17:902:3c5:: with SMTP id d63-v6mr40369142pld.163.1525775772341; Tue, 08 May 2018 03:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525775772; cv=none; d=google.com; s=arc-20160816; b=EHGbAuxQv++ooyqHAxZT8fhlFTnjV68tLVoYE0Q6QoCMsXUD3YQWwouW2Wc1YGrofy t1wp2b7rGivUDp7U1u7DGqfPTUtKrTTIAdtcUvkNFAF2Gcqq5cwIj09XZ0L8/N35m/uV nBFO5HDPhaPDFjNFXdLSWGHQOL4NVW4K5tA1WhDM3xbo/fSoFYnn9nN85DUQDo+Lsaac pk7hk4zizKdEBI0+j/7uXCCv6OGyiAJH0Oq7lXb9XHrf2131DFlzXXORdKYTHr57v3Qw yIwTBl2Sh2pdeB0ALjztUqiVF2ljXUHvmhU4KAOGCackbz02LeDovG05arYEOfBb6xd+ c4HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:date:message-id:openpgp:subject:from:to :delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=uRY3hRlJrFHMvWFdrB53mwIqEZ070BLtQ/frvz6oLh8=; b=ore6lIQeKS/SU4iwgqg7R/Joygy8+drhyAeu82DrYGxJl/XZI1+FMeYsHogHHCvd6P r2h9KwP7WnCwRWXh65+SXlIIq1B3xFxZBzeQdRw6Zvd2jrM5V6rCSIy1xnT0Ep/aeh10 LyabuMs6ZYoqjMXVeLYUBcovjN1AfOgEw57ZUmDDN+QnJ99LTf9ZqYVkXzd5fe5K+ErG AKQOdVbi4By9v7xt+V01wREWNVlNqJoRYLcYYjWeoiZ6mhGEjm0FzOQWyN1wU7UGXXiC WpYl1WFtnSSC8fVv+IFM1AuG1Ybhu9pRgQvpHz7e0V4z94QjlAHyjgI2YEAa2H4rpeQ4 K5Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kHbVEP7n; spf=pass (google.com: domain of gcc-patches-return-477340-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-477340-patch=linaro.org@gcc.gnu.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id f2-v6si19436798pgt.243.2018.05.08.03.36.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 03:36:12 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-477340-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 header.s=default header.b=kHbVEP7n; spf=pass (google.com: domain of gcc-patches-return-477340-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-477340-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=ulPNwiFen75qwhlS92+rIP03BqjphXUjRctPwA0qwFnOuM04zD MfF/NS8cUJtdFWDXLQzR/3IP0S8VX/C3E4nLwJeD86OCBYzPZCMdkyrO05NdkoaO jsqsvW54CUtFYh25GhsyJLT7PYO1nMCc2esfEownVYvkrfjtv+nYkTCzw= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=SZGwRtKiv0ayQbhIDdphaJpXtBk=; b=kHbVEP7nWAYKOH0cuQKd bMF74e31WL7DUyHEkcKGaoS96gDSuIOa7Nu+7MEg9wh3z/XKMW3LjwdpVbc/16X0 bAgnEE8cT1Vo4REYhekuK5Dpoek4SMUG6CyZdRGViAsTRxhfSdRnubAX9rkzGe+f yvjREyWu9LcNPqpCmk+kIv0= Received: (qmail 3817 invoked by alias); 8 May 2018 10:36:00 -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 3789 invoked by uid 89); 8 May 2018 10:35:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 May 2018 10:35:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 68BC315BE; Tue, 8 May 2018 03:35:56 -0700 (PDT) Received: from e120077-lin.cambridge.arm.com (e120077-lin.cambridge.arm.com [10.2.206.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E7BEC3F592; Tue, 8 May 2018 03:35:55 -0700 (PDT) To: gcc-patches From: "Richard Earnshaw (lists)" Subject: [arm] PR target/85658 Fix operator precedence errors in parsecpu.awk Openpgp: preference=signencrypt Message-ID: Date: Tue, 8 May 2018 11:35:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 There are a number of places in parsecpu.awk where I've managed to get the operator precedence between ! and 'in' incorrect (! binds more tightly). In most cases this just makes a consistency test ineffective, but in a few cases it means we fail to correctly diagnose errors by the user (for example, when passing an invalid cpu or architecture name to configure. This patch fixes all the cases I could find, based on searching for all uses of the two operators in the same expression. The tweak to the API of check_fpu is to bring it into line with the other check functions - it now returns the result rather than printing it directly. The caller now does the printing, in the same way that the chkarch and chkcpu commands do. PR target/85658 * config/arm/parsecpu.awk (check_cpu): Fix operator precedence. (check_arch): Likewise. (check_fpu): Return the result rather than printing it. (end arch): Fix operator precedence. (end cpu): Likewise. (END): Print the result from check_fpu. Committed to trunk and gcc-8 branch. diff --git a/gcc/config/arm/parsecpu.awk b/gcc/config/arm/parsecpu.awk index 56c762b..4d234c3 100644 --- a/gcc/config/arm/parsecpu.awk +++ b/gcc/config/arm/parsecpu.awk @@ -463,7 +463,7 @@ function gen_opt () { function check_cpu (name) { exts = split (name, extensions, "+") - if (! extensions[1] in cpu_cnames) { + if (! (extensions[1] in cpu_cnames)) { return "error" } @@ -477,15 +477,16 @@ function check_cpu (name) { } function check_fpu (name) { - if (name in fpu_cnames) { - print fpu_cnames[name] - } else print "error" + if (! (name in fpu_cnames)) { + return "error" + } + return fpu_cnames[name] } function check_arch (name) { exts = split (name, extensions, "+") - if (! extensions[1] in arch_isa) { + if (! (extensions[1] in arch_isa)) { return "error" } @@ -600,10 +601,10 @@ BEGIN { /^end arch / { if (NF != 3) fatal("syntax: end arch ") if (arch_name != $3) fatal("mimatched end arch") - if (! arch_name in arch_tune_for) { + if (! (arch_name in arch_tune_for)) { fatal("arch definition lacks a \"tune for\" statement") } - if (! arch_name in arch_isa) { + if (! (arch_name in arch_isa)) { fatal("arch definition lacks an \"isa\" statement") } arch_list = arch_list " " arch_name @@ -742,7 +743,7 @@ BEGIN { cpu_cnames[cpu_name] = cpu_name gsub(/[-+.]/, "_", cpu_cnames[cpu_name]) } - if (! cpu_name in cpu_arch) fatal("cpu definition lacks an architecture") + if (! (cpu_name in cpu_arch)) fatal("cpu definition lacks an architecture") cpu_list = cpu_list " " cpu_name cpu_name = "" parse_ok = 1 @@ -776,6 +777,6 @@ END { print check_arch(target[2]) } else if (cmd ~ /^chkfpu /) { split (cmd, target) - check_fpu(target[2]) + print check_fpu(target[2]) } else fatal("unrecognized command: "cmd) }