]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Sanity check that 'Init' doesn't appear without 'Var' in '*.opt' files
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 3 Aug 2021 12:59:56 +0000 (14:59 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Mon, 9 Aug 2021 11:38:14 +0000 (13:38 +0200)
... 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

index 880ac776d8a5559081bd60760328c64ce081dc9e..77e598efd605d03e3b6f35671f00e78c78317250 100644 (file)
@@ -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