From 67b88991c4a37e63bfecd9a0a17d9d7561b23dce Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 3 Aug 2021 14:59:56 +0200
Subject: [PATCH] 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'.
---
gcc/optc-gen.awk | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
@@ -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
--
2.25.1