From 8a2ced4fe401a36db6a9d4de5813951009a62a9e Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 27 Mar 2023 13:52:01 -0600 Subject: [PATCH] Remove some Ada parser helper functions These helper functions in the Ada parser don't seem all that worthwhile to me, so this patch removes them. --- gdb/ada-exp.y | 52 +++++-------------------- gdb/ada-lex.l | 8 ++-- gdb/testsuite/gdb.base/parse_number.exp | 2 + 3 files changed, 15 insertions(+), 47 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index a9c37bedff0..4095106bb09 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -93,18 +93,8 @@ static const struct block *block_lookup (const struct block *, const char *); static void write_ambiguous_var (struct parser_state *, const struct block *, const char *, int); -static struct type *type_int (struct parser_state *); - -static struct type *type_long (struct parser_state *); - -static struct type *type_long_long (struct parser_state *); - -static struct type *type_long_double (struct parser_state *); - static struct type *type_for_char (struct parser_state *, ULONGEST); -static struct type *type_boolean (struct parser_state *); - static struct type *type_system_address (struct parser_state *); static std::string find_completion_bounds (struct parser_state *); @@ -934,9 +924,15 @@ primary : STRING ; primary : TRUEKEYWORD - { write_int (pstate, 1, type_boolean (pstate)); } + { + write_int (pstate, 1, + parse_type (pstate)->builtin_bool); + } | FALSEKEYWORD - { write_int (pstate, 0, type_boolean (pstate)); } + { + write_int (pstate, 0, + parse_type (pstate)->builtin_bool); + } ; primary : NEW NAME @@ -1268,7 +1264,7 @@ write_object_renaming (struct parser_state *par_state, if (next == renaming_expr) goto BadEncoding; renaming_expr = next; - write_int (par_state, val, type_int (par_state)); + write_int (par_state, val, parse_type (par_state)->builtin_int); } else { @@ -1841,30 +1837,6 @@ write_name_assoc (struct parser_state *par_state, struct stoken name) push_association (ada_pop ()); } -static struct type * -type_int (struct parser_state *par_state) -{ - return parse_type (par_state)->builtin_int; -} - -static struct type * -type_long (struct parser_state *par_state) -{ - return parse_type (par_state)->builtin_long; -} - -static struct type * -type_long_long (struct parser_state *par_state) -{ - return parse_type (par_state)->builtin_long_long; -} - -static struct type * -type_long_double (struct parser_state *par_state) -{ - return parse_type (par_state)->builtin_long_double; -} - static struct type * type_for_char (struct parser_state *par_state, ULONGEST value) { @@ -1880,12 +1852,6 @@ type_for_char (struct parser_state *par_state, ULONGEST value) "wide_wide_character"); } -static struct type * -type_boolean (struct parser_state *par_state) -{ - return parse_type (par_state)->builtin_bool; -} - static struct type * type_system_address (struct parser_state *par_state) { diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 69fc14f7107..0634f337cb2 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -471,9 +471,9 @@ processInt (struct parser_state *par_state, const char *base0, ULONGEST value = result.as_integer (); if (fits_in_type (1, value, int_bits, true)) - yylval.typed_val.type = type_int (par_state); + yylval.typed_val.type = parse_type (par_state)->builtin_int; else if (fits_in_type (1, value, long_bits, true)) - yylval.typed_val.type = type_long (par_state); + yylval.typed_val.type = parse_type (par_state)->builtin_long; else if (fits_in_type (1, value, long_bits, false)) { /* We have a number representable as an unsigned integer quantity. @@ -494,7 +494,7 @@ processInt (struct parser_state *par_state, const char *base0, return INT; } else if (fits_in_type (1, value, long_long_bits, true)) - yylval.typed_val.type = type_long_long (par_state); + yylval.typed_val.type = parse_type (par_state)->builtin_long_long; else if (fits_in_type (1, value, long_long_bits, false)) { yylval.typed_val.type @@ -518,7 +518,7 @@ processInt (struct parser_state *par_state, const char *base0, static int processReal (struct parser_state *par_state, const char *num0) { - yylval.typed_val_float.type = type_long_double (par_state); + yylval.typed_val_float.type = parse_type (par_state)->builtin_long_double; bool parsed = parse_float (num0, strlen (num0), yylval.typed_val_float.type, diff --git a/gdb/testsuite/gdb.base/parse_number.exp b/gdb/testsuite/gdb.base/parse_number.exp index 5dd4fa705e9..8800dead53b 100644 --- a/gdb/testsuite/gdb.base/parse_number.exp +++ b/gdb/testsuite/gdb.base/parse_number.exp @@ -145,6 +145,8 @@ proc parse_number { lang n } { } elseif { [fits_in_type $n $long_long_bits u] } { # Note: Interprets ULLONG_MAX as -1. return [list "<$sizeof_long_long-byte integer>" $n] + } elseif { [fits_in_type $n 128 u] } { + return [list "<16-byte integer>" $n] } else { # Overflow. return [list $re_overflow $re_overflow] -- 2.30.2