From 2d8a60a63cafdd9930bdbfb2ec76c47d7d14cd45 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 5 May 2020 16:13:46 +0200 Subject: optgen: make more sanity checks for enums. * opt-functions.awk (opt_args_non_empty): New function. * opt-read.awk: Use the function for various option arguments. --- gcc/opt-functions.awk | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/opt-functions.awk') diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index 2f0442d..b4952b8 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -72,6 +72,16 @@ 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 "#error Empty option argument '" name "' during parsing of: " flags + 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) -- cgit v1.1