From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81258 invoked by alias); 21 Feb 2020 09:43:06 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 81239 invoked by uid 89); 21 Feb 2020 09:43:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=HTo:U*tkoenig, H*MI:sk:bfa84e3, H*i:sk:bfa84e3, H*f:sk:bfa84e3 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Feb 2020 09:43:04 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A3177AAC2; Fri, 21 Feb 2020 09:43:01 +0000 (UTC) Subject: Re: Request for better syntax checking in lang.opt To: Thomas Koenig , gcc mailing list Cc: "fortran@gcc.gnu.org" References: <2406b2a4-a996-b220-5026-7022552fae48@netcologne.de> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <4a2af157-b21e-311f-3ff4-8dd432d67a05@suse.cz> Date: Fri, 21 Feb 2020 09:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------B0FC55DC7C6D888FFAD33DFC" X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00169.txt.bz2 This is a multi-part message in MIME format. --------------B0FC55DC7C6D888FFAD33DFC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 740 On 2/20/20 7:08 PM, Thomas Koenig wrote: > Hi Martin, > >> Sure, I can improve sanity checking. > > Thanks! > >> What exactly have you screwed up? > I had, in lang.opt > > EnumValue > Enum (gfc_fcoarray) String (native) Value (GFC_FCOARRAY_NATIVE) > > It was a bit non-obvious to me that this led to the whole sub-option > being ignored due to > > *drum roll* > > the space between the keywords and the opening parenthesis.  I have > internalized the GNU style guides to such an extent that I hardly > ever see the space there :-) Hello. I was able to write a sanity check for these kind of issues, but it does not resolve all similar issues for other keywords. It's not easy to do it. Martin > > Regards > >     Thomas --------------B0FC55DC7C6D888FFAD33DFC Content-Type: text/x-patch; charset=UTF-8; name="0001-Make-more-sanity-checks-for-enums.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Make-more-sanity-checks-for-enums.patch" Content-length: 1985 >From 440fda0ccd2211cfd0478f50cc20d0969fe8bce0 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 21 Feb 2020 10:40:57 +0100 Subject: [PATCH] Make more sanity checks for enums. --- gcc/opt-functions.awk | 13 +++++++++++++ gcc/opt-read.awk | 10 +++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index 2f0442dc563..be4b9e66165 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -72,6 +72,19 @@ function opt_args(name, flags) return flags } +# If FLAGS contains a "NAME(...argument...)" flag, return the value +# of the argument. Print error message otherwise. +function opt_args_non_empty(name, flags, description) +{ + args = opt_args(name, flags) + if (args == "") + { + print "Empty option argument '" name "' during parsing of: " flags >> "/dev/stderr" + exit 1 + } + return args +} + # Return the Nth comma-separated element of S. Return the empty string # if S does not contain N elements. function nth_arg(n, s) diff --git a/gcc/opt-read.awk b/gcc/opt-read.awk index a2e16f29aff..9bb9dfcf6ca 100644 --- a/gcc/opt-read.awk +++ b/gcc/opt-read.awk @@ -81,8 +81,8 @@ BEGIN { } else if ($1 == "Enum") { props = $2 - name = opt_args("Name", props) - type = opt_args("Type", props) + name = opt_args_non_empty("Name", props) + type = opt_args_non_empty("Type", props) unknown_error = opt_args("UnknownError", props) enum_names[n_enums] = name enum_type[name] = type @@ -93,9 +93,9 @@ BEGIN { } else if ($1 == "EnumValue") { props = $2 - enum_name = opt_args("Enum", props) - string = opt_args("String", props) - value = opt_args("Value", props) + enum_name = opt_args_non_empty("Enum", props) + string = opt_args_non_empty("String", props) + value = opt_args_non_empty("Value", props) val_flags = "0" val_flags = val_flags \ test_flag("Canonical", props, "| CL_ENUM_CANONICAL") \ -- 2.25.0 --------------B0FC55DC7C6D888FFAD33DFC--