From patchwork Tue Mar 17 15:46:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1256581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48hcwv411Qz9sSG for ; Wed, 18 Mar 2020 02:46:38 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70CEB3944420; Tue, 17 Mar 2020 15:46:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 0A372385E82C for ; Tue, 17 Mar 2020 15:46:33 +0000 (GMT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C4140AD46 for ; Tue, 17 Mar 2020 15:46:31 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [stage1][PATCH] optgen: make more sanity checks for enums. To: gcc-patches@gcc.gnu.org Message-ID: Date: Tue, 17 Mar 2020 16:46:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-25.0 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi. The patch is about better sanity check in option generation script. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed in stage1? Thanks, Martin gcc/ChangeLog: 2020-03-17 Martin Liska * opt-functions.awk (opt_args_non_empty): New function. * opt-read.awk: Use the function for various option arguments. --- 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") \