From 28aaf3fdf9562c018dcf6ab4d0a4c644fff8d696 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 24 Mar 2019 11:33:10 -0600 Subject: Remove paren_depth global This removes the "paren_depth" global. In most cases, it is made into a static global in a given parser. I consider this a slight improvement, because it makes it clear that the variable isn't used for communication between different modules of gdb. The one exception is the Rust parser, which already incorporates all local state into a transient object; in this case the parser depth is now a member. gdb/ChangeLog 2019-04-04 Tom Tromey * rust-exp.y (struct rust_parser) : New member. (rustyylex, rust_lex_test_init, rust_lex_test_one) (rust_lex_test_sequence, rust_lex_test_push_back): Update. * parser-defs.h (paren_depth): Don't declare. * parse.c (paren_depth): Remove global. (parse_exp_in_context): Update. * p-exp.y (paren_depth): New global. (pascal_parse): Initialize it. * m2-exp.y (paren_depth): New global. (m2_parse): Initialize it. * go-exp.y (paren_depth): New global. (go_parse): Initialize it. * f-exp.y (paren_depth): New global. (f_parse): Initialize it. * d-exp.y (paren_depth): New global. (d_parse): Initialize it. * c-exp.y (paren_depth): New global. (c_parse): Initialize it. * ada-lex.l (paren_depth): New global. (lexer_init): Initialize it. --- gdb/c-exp.y | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gdb/c-exp.y') diff --git a/gdb/c-exp.y b/gdb/c-exp.y index e6d6c20..cb9e9e0 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -2527,6 +2527,9 @@ static int saw_name_at_eof; operator -- either '.' or ARROW. */ static bool last_was_structop; +/* Depth of parentheses. */ +static int paren_depth; + /* Read one token, getting characters through lexptr. */ static int @@ -3315,6 +3318,7 @@ c_parse (struct parser_state *par_state) /* Initialize some state used by the lexer. */ last_was_structop = false; saw_name_at_eof = 0; + paren_depth = 0; token_fifo.clear (); popping = 0; -- cgit v1.1