From ed08e2b3714e9ea80f68443efb92967300a8897f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 14 Mar 2024 12:19:22 -0600 Subject: [PATCH] Move "iterated_associations" into ada_parse_state This patch moves the "iterated_associations" global into ada_parse_state. --- gdb/ada-exp.y | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 207fdcb2707..09cf6ccf186 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -96,6 +96,10 @@ struct ada_parse_state to implement '@', the target name symbol. */ std::vector assignments; + /* Track currently active iterated assignment names. */ + std::unordered_map> + iterated_associations; + private: /* We don't have a good way to manage non-POD data in Yacc, so store @@ -443,10 +447,6 @@ make_tick_completer (struct stoken tok) (new ada_tick_completer (std::string (tok.ptr, tok.length)))); } -/* Track currently active iterated assignment names. */ -static std::unordered_map> - iterated_associations; - %} %union @@ -1127,12 +1127,12 @@ component_group : { std::string name = copy_name ($2); - auto iter = iterated_associations.find (name); - if (iter != iterated_associations.end ()) + auto iter = ada_parser->iterated_associations.find (name); + if (iter != ada_parser->iterated_associations.end ()) error (_("Nested use of index parameter '%s'"), name.c_str ()); - iterated_associations[name] = {}; + ada_parser->iterated_associations[name] = {}; } component_associations { @@ -1141,12 +1141,12 @@ component_group : ada_choices_component *choices = choice_component (); choices->set_associations (pop_associations ($5)); - auto iter = iterated_associations.find (name); - gdb_assert (iter != iterated_associations.end ()); + auto iter = ada_parser->iterated_associations.find (name); + gdb_assert (iter != ada_parser->iterated_associations.end ()); for (ada_index_var_operation *var : iter->second) var->set_choices (choices); - iterated_associations.erase (name); + ada_parser->iterated_associations.erase (name); choices->set_name (std::move (name)); } @@ -1256,7 +1256,6 @@ ada_parse (struct parser_state *par_state) lexer_init (yyin); /* (Re-)initialize lexer. */ obstack_free (&temp_parse_space, NULL); obstack_init (&temp_parse_space); - iterated_associations.clear (); int result = yyparse (); if (!result) @@ -1706,8 +1705,8 @@ write_var_or_type (struct parser_state *par_state, if (block == nullptr) { - auto iter = iterated_associations.find (name_storage); - if (iter != iterated_associations.end ()) + auto iter = ada_parser->iterated_associations.find (name_storage); + if (iter != ada_parser->iterated_associations.end ()) { auto op = std::make_unique (); iter->second.push_back (op.get ());