From 6eb099ae9324f1210d98a406dee07f22ab26a4eb Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 14 Jan 2023 22:13:54 +1030 Subject: Tidy gas/expr.c static state * expr.c (seen, nr_seen): Make file scope. (expr_begin): Clear seen, nr_seen, and expr_symbol_lines. (expr_end): New function. * expr.h (expr_end): Declare. * output-file.c (output_file_close): Call expr_end. * config/tc-hppa.c (expr_end): Rename to expr_parse_end. * config/tc-mips.c: Likewise. * config/tc-riscv.c: Likewise. * config/tc-sparc.c: Likewise. --- gas/expr.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'gas/expr.c') diff --git a/gas/expr.c b/gas/expr.c index 28ec58c..ba3d210 100644 --- a/gas/expr.c +++ b/gas/expr.c @@ -130,12 +130,12 @@ expr_symbol_where (symbolS *sym, const char **pfile, unsigned int *pline) /* Look up a previously used .startof. / .sizeof. symbol, or make a fresh one. */ +static symbolS **seen[2]; +static unsigned int nr_seen[2]; static symbolS * symbol_lookup_or_make (const char *name, bool start) { - static symbolS **seen[2]; - static unsigned int nr_seen[2]; char *buf = concat (start ? ".startof." : ".sizeof.", name, NULL); symbolS *symbolP; unsigned int i; @@ -1596,6 +1596,17 @@ expr_begin (void) e.X_op = O_max; gas_assert (e.X_op == O_max); } + + memset (seen, 0, sizeof seen); + memset (nr_seen, 0, sizeof nr_seen); + expr_symbol_lines = NULL; +} + +void +expr_end (void) +{ + for (size_t i = 0; i < ARRAY_SIZE (seen); i++) + free (seen[i]); } /* Return the encoding for the operator at INPUT_LINE_POINTER, and -- cgit v1.1