From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 9A602389440A; Mon, 9 Aug 2021 11:38:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A602389440A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2814] Sanity check that 'Init' doesn't appear without 'Var' in '*.opt' files X-Act-Checkin: gcc X-Git-Author: Thomas Schwinge X-Git-Refname: refs/heads/master X-Git-Oldrev: 06870af3e48daf523a973981f053ee5c6f44c871 X-Git-Newrev: c5230519305946338ddc7107ce45c740812142b4 Message-Id: <20210809113830.9A602389440A@sourceware.org> Date: Mon, 9 Aug 2021 11:38:30 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 11:38:30 -0000 https://gcc.gnu.org/g:c5230519305946338ddc7107ce45c740812142b4 commit r12-2814-gc5230519305946338ddc7107ce45c740812142b4 Author: Thomas Schwinge Date: Tue Aug 3 14:59:56 2021 +0200 Sanity check that 'Init' doesn't appear without 'Var' in '*.opt' files ... as that doesn't make sense. @item Init(@var{value}) The variable specified by the @code{Var} property should be statically initialized to @var{value}. [...] gcc/ * optc-gen.awk: Sanity check that 'Init' doesn't appear without 'Var'. Diff: --- gcc/optc-gen.awk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index 880ac776d8a..77e598efd60 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -195,10 +195,14 @@ for (i = 0; i < n_extra_vars; i++) { } for (i = 0; i < n_opts; i++) { name = var_name(flags[i]); - if (name == "") + init = opt_args("Init", flags[i]) + + if (name == "") { + if (init != "") + print "#error " opts[i] " must specify Var to use Init" continue; + } - init = opt_args("Init", flags[i]) if (init != "") { if (name in var_init && var_init[name] != init) print "#error multiple initializers for " name