From 0f8fab2c906debb0169c9e09b7fcdd24c19db2a5 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Wed, 10 Dec 2025 00:25:19 +0100 Subject: [PATCH] [gdb] Fix whitespace in *.[ly] Add indent-with-non-tab for *.[ly] in gdb/.gitattributes. Fix whitespace in the *.[ly] files in gdb, and add these files to the clean list in gdb/contrib/check-whitespace-pre-commit.py. Tested on x86_64-linux. Approved-By: Tom Tromey --- gdb/.gitattributes | 4 + gdb/ada-exp.y | 82 +++++++------- gdb/ada-lex.l | 64 +++++------ gdb/c-exp.y | 4 +- gdb/contrib/check-whitespace-pre-commit.py | 2 +- gdb/cp-name-parser.y | 20 ++-- gdb/d-exp.y | 1 - gdb/f-exp.y | 120 ++++++++++----------- gdb/m2-exp.y | 16 +-- gdb/p-exp.y | 10 +- 10 files changed, 163 insertions(+), 160 deletions(-) diff --git a/gdb/.gitattributes b/gdb/.gitattributes index cf72455a48f..26250fdf89c 100644 --- a/gdb/.gitattributes +++ b/gdb/.gitattributes @@ -15,3 +15,7 @@ configure -whitespace aclocal.m4 -whitespace + +# Tab-indented files. + +*.[ly] whitespace=space-before-tab,indent-with-non-tab,trailing-space diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index c87b91e92e0..09074e6d927 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -483,7 +483,7 @@ make_tick_completer (struct stoken tok) } %type positional_list component_groups component_associations -%type aggregate_component_list +%type aggregate_component_list %type var_or_type type_prefix opt_type_prefix %token INT NULL_PTR @@ -509,7 +509,7 @@ make_tick_completer (struct stoken tok) %left '*' '/' MOD REM %right STARSTAR ABS NOT -/* Artificial token to give NAME => ... and NAME | priority over reducing +/* Artificial token to give NAME => ... and NAME | priority over reducing NAME to and to give ' priority over reducing to . */ %nonassoc VAR @@ -620,7 +620,7 @@ primary : primary '(' simple_exp DOTDOT simple_exp ')' { ada_wrap3 (); } | var_or_type '(' simple_exp DOTDOT simple_exp ')' - { if ($1 == NULL) + { if ($1 == NULL) ada_wrap3 (); else error (_("Cannot slice a type")); @@ -632,7 +632,7 @@ primary : '(' exp1 ')' { } /* The following rule causes a conflict with the type conversion var_or_type (exp) - To get around it, we give '(' higher priority and add bridge rules for + To get around it, we give '(' higher priority and add bridge rules for var_or_type (exp, exp, ...) var_or_type (exp .. exp) We also have the action for var_or_type(exp) generate a function call @@ -653,7 +653,7 @@ primary : aggregate pstate->push_new (pop_component ()); } - ; + ; primary : '@' { @@ -715,7 +715,7 @@ arglist : exp primary : '{' var_or_type '}' primary %prec '.' /* GDB extension */ - { + { if ($2 == NULL) error (_("Type required within braces in coercion")); operation_up arg = ada_pop (); @@ -786,8 +786,8 @@ relation : simple_exp IN simple_exp DOTDOT simple_exp pstate->push_new (std::move (lhs), std::move (rhs), $5); } - | simple_exp IN var_or_type %prec TICK_ACCESS - { + | simple_exp IN var_or_type %prec TICK_ACCESS + { if ($3 == NULL) error (_("Right operand of 'in' must be type")); operation_up arg = ada_pop (); @@ -805,8 +805,8 @@ relation : simple_exp IN simple_exp DOTDOT simple_exp (std::move (lhs), std::move (rhs), $6); ada_wrap (); } - | simple_exp NOT IN var_or_type %prec TICK_ACCESS - { + | simple_exp NOT IN var_or_type %prec TICK_ACCESS + { if ($4 == NULL) error (_("Right operand of 'in' must be type")); operation_up arg = ada_pop (); @@ -837,7 +837,7 @@ exp : relation ; and_exp : - relation _AND_ relation + relation _AND_ relation { ada_wrap2 (BINOP_BITWISE_AND); } | and_exp _AND_ relation @@ -855,7 +855,7 @@ and_then_exp : ; or_exp : - relation OR relation + relation OR relation { ada_wrap2 (BINOP_BITWISE_IOR); } | or_exp OR relation @@ -878,13 +878,13 @@ xor_exp : relation XOR relation (BINOP_BITWISE_XOR); } ; -/* Primaries can denote types (OP_TYPE). In cases such as +/* Primaries can denote types (OP_TYPE). In cases such as primary TICK_ADDRESS, where a type would be invalid, it will be caught when evaluate_subexp in ada-lang.c tries to evaluate the primary, expecting a value. Precedence rules resolve the ambiguity in NAME TICK_ACCESS in favor of shifting to form a var_or_type. A construct such as aType'access'access will again cause an error when - aType'access evaluates to a type that evaluate_subexp attempts to + aType'access evaluates to a type that evaluate_subexp attempts to evaluate. */ primary : primary TICK_ACCESS { ada_addrof (); } @@ -963,7 +963,7 @@ tick_arglist : %prec '(' type_prefix : var_or_type - { + { if ($1 == NULL) error (_("Prefix must be type")); $$ = $1; @@ -1011,7 +1011,7 @@ primary : NULL_PTR ; primary : STRING - { + { pstate->push_new (copy_name ($1)); } @@ -1049,8 +1049,8 @@ var_or_type: NAME %prec VAR $1, $2); } - | NAME TICK_ACCESS - { + | NAME TICK_ACCESS + { $$ = write_var_or_type (pstate, NULL, $1); if ($$ == NULL) ada_addrof (); @@ -1058,7 +1058,7 @@ var_or_type: NAME %prec VAR $$ = lookup_pointer_type ($$); } | block NAME TICK_ACCESS - { + { $$ = write_var_or_type (pstate, $1, $2); if ($$ == NULL) ada_addrof (); @@ -1112,12 +1112,12 @@ positional_list : push_component (0, ada_pop ()); $$ = 1; - } + } | positional_list exp ',' { push_component ($1, ada_pop ()); - $$ = $1 + 1; + $$ = $1 + 1; } ; @@ -1171,8 +1171,8 @@ component_group : /* We use this somewhat obscure definition in order to handle NAME => and NAME | differently from exp => and exp |. ARROW and '|' have a precedence - above that of the reduction of NAME to var_or_type. By delaying - decisions until after the => or '|', we convert the ambiguity to a + above that of the reduction of NAME to var_or_type. By delaying + decisions until after the => or '|', we convert the ambiguity to a resolved shift/reduce conflict. */ component_associations : NAME ARROW exp @@ -1308,12 +1308,12 @@ write_int (struct parser_state *par_state, LONGEST arg, struct type *type) ada_wrap (); } -/* Emit expression corresponding to the renamed object named +/* Emit expression corresponding to the renamed object named designated by RENAMED_ENTITY[0 .. RENAMED_ENTITY_LEN-1] in the context of ORIG_LEFT_CONTEXT, to which is applied the operations encoded by RENAMING_EXPR. MAX_DEPTH is the maximum number of cascaded renamings to allow. If ORIG_LEFT_CONTEXT is null, it - defaults to the currently selected block. ORIG_SYMBOL is the + defaults to the currently selected block. ORIG_SYMBOL is the symbol that originally encoded the renaming. It is needed only because its prefix also qualifies any index variables used to index or slice an array. It should not be necessary once we go to the @@ -1510,7 +1510,7 @@ select_possible_type_sym (const std::vector &syms) int i; int preferred_index; struct type *preferred_type; - + preferred_index = -1; preferred_type = NULL; for (i = 0; i < syms.size (); i += 1) switch (syms[i].symbol->loc_class ()) @@ -1552,7 +1552,7 @@ find_primitive_type (struct parser_state *par_state, const char *name) /* Check to see if we have a regular definition of this type that just didn't happen to have been read yet. */ struct symbol *sym; - char *expanded_name = + char *expanded_name = (char *) alloca (strlen (name) + sizeof ("standard__")); strcpy (expanded_name, "standard__"); strcat (expanded_name, name); @@ -1602,7 +1602,7 @@ write_selectors (struct parser_state *par_state, const char *sels) { const char *p = chop_separator (sels); sels = p; - while (*sels != '\0' && *sels != '.' + while (*sels != '\0' && *sels != '.' && (sels[0] != '_' || sels[1] != '_')) sels += 1; operation_up arg = ada_pop (); @@ -1678,7 +1678,7 @@ get_symbol_field_type (struct symbol *sym, const char *encoded_field_name) return type->field (fieldno).type (); subfield_name = field_name; - while (*subfield_name != '\0' && *subfield_name != '.' + while (*subfield_name != '\0' && *subfield_name != '.' && (subfield_name[0] != '_' || subfield_name[1] != '_')) subfield_name += 1; @@ -1697,14 +1697,14 @@ get_symbol_field_type (struct symbol *sym, const char *encoded_field_name) return NULL; } -/* Look up NAME0 (an unencoded identifier or dotted name) in BLOCK (or +/* Look up NAME0 (an unencoded identifier or dotted name) in BLOCK (or expression_block_context if NULL). If it denotes a type, return that type. Otherwise, write expression code to evaluate it as an object and return NULL. In this second case, NAME0 will, in general, have the form (.)*, where is an object or renaming encoded in the debugging data. Calls error if no prefix matches a name in the debugging data (i.e., matches - either a complete name or, as a wild-card match, the final + either a complete name or, as a wild-card match, the final identifier). */ static struct type* @@ -1738,7 +1738,7 @@ write_var_or_type (struct parser_state *par_state, for (depth = 0; depth < MAX_RENAMING_CHAIN_LENGTH; depth += 1) { int tail_index; - + tail_index = name_len; while (tail_index > 0) { @@ -1765,7 +1765,7 @@ write_var_or_type (struct parser_state *par_state, renaming_sym = type_sym; else if (syms.size () == 1) renaming_sym = syms[0].symbol; - else + else renaming_sym = NULL; switch (ada_parse_renaming (renaming_sym, &renaming, @@ -1786,7 +1786,7 @@ write_var_or_type (struct parser_state *par_state, encoded_name = new_name; name_len = renaming_len + name_len - tail_index; goto TryAfterRenaming; - } + } case ADA_OBJECT_RENAMING: write_object_renaming (par_state, block, renaming, renaming_len, renaming_expr, MAX_RENAMING_CHAIN_LENGTH); @@ -1799,7 +1799,7 @@ write_var_or_type (struct parser_state *par_state, if (type_sym != NULL) { struct type *field_type; - + if (tail_index == name_len) return type_sym->type (); @@ -1810,7 +1810,7 @@ write_var_or_type (struct parser_state *par_state, = get_symbol_field_type (type_sym, encoded_name + tail_index); if (field_type != NULL) return field_type; - else + else error (_("Invalid attempt to select from type: \"%s\"."), name0.ptr); } @@ -1846,12 +1846,12 @@ write_var_or_type (struct parser_state *par_state, } if (tail_index == name_len - && strncmp (encoded_name, "standard__", + && strncmp (encoded_name, "standard__", sizeof ("standard__") - 1) == 0) error (_("No definition of \"%s\" found."), name0.ptr); tail_index = chop_selector (encoded_name, tail_index); - } + } else { write_ambiguous_var (par_state, block, encoded_name, @@ -1869,7 +1869,7 @@ write_var_or_type (struct parser_state *par_state, error (_("No definition of \"%s\" in current context."), name0.ptr); else error (_("No definition of \"%s\" in specified context."), name0.ptr); - + TryAfterRenaming: ; } @@ -1957,7 +1957,7 @@ write_var_or_type_completion (struct parser_state *par_state, As a result, in the (one hopes) rare case that one writes an aggregate such as (R => 42) where R renames an object or is an ambiguous name, one must write instead ((R) => 42). */ - + static void write_name_assoc (struct parser_state *par_state, struct stoken name) { @@ -1998,7 +1998,7 @@ type_for_char (struct parser_state *par_state, ULONGEST value) static struct type * type_system_address (struct parser_state *par_state) { - struct type *type + struct type *type = language_lookup_primitive_type (par_state->language (), par_state->gdbarch (), "system__address"); diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index eec80cfb207..acd8cf3690b 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -164,11 +164,11 @@ static void rewind_to_char (int); } {NUM10}"#"{NUM16}"."{NUM16}"#"{EXP} { - error (_("Based real literals not implemented yet.")); + error (_("Based real literals not implemented yet.")); } {NUM10}"#"{NUM16}"."{NUM16}"#" { - error (_("Based real literals not implemented yet.")); + error (_("Based real literals not implemented yet.")); } "'"({GRAPHIC}|\")"'" { @@ -178,9 +178,9 @@ static void rewind_to_char (int); } "'[\""{HEXDIG}{2,}"\"]'" { - ULONGEST v = strtoulst (yytext+3, nullptr, 16); + ULONGEST v = strtoulst (yytext+3, nullptr, 16); yylval.typed_char.val = v; - yylval.typed_char.type = type_for_char (pstate, v); + yylval.typed_char.type = type_for_char (pstate, v); return CHARLIT; } @@ -188,29 +188,29 @@ static void rewind_to_char (int); digits here. Currently there's no support for wide or wide-wide strings. */ \"({GRAPHIC}|"[\""({HEXDIG}{2,}|\")"\"]")*\" { - yylval.sval = processString (yytext+1, yyleng-2); + yylval.sval = processString (yytext+1, yyleng-2); return STRING; } \" { - error (_("ill-formed or non-terminated string literal")); + error (_("ill-formed or non-terminated string literal")); } if { - rewind_to_char ('i'); + rewind_to_char ('i'); return 0; } task { - rewind_to_char ('t'); + rewind_to_char ('t'); return 0; } thread{WHITE}+{DIG} { - /* This keyword signals the end of the expression and - will be processed separately. */ - rewind_to_char ('t'); + /* This keyword signals the end of the expression and + will be processed separately. */ + rewind_to_char ('t'); return 0; } @@ -243,7 +243,7 @@ xor { return XOR; } true { return TRUEKEYWORD; } false { return FALSEKEYWORD; } - /* ATTRIBUTES */ + /* ATTRIBUTES */ {TICK}([a-z][a-z_]*)?{COMPLETE}? { BEGIN INITIAL; return processAttribute (yytext); } @@ -277,17 +277,17 @@ false { return FALSEKEYWORD; } return 0; } else - { + { ada_parser->paren_depth -= 1; return ')'; } } "."{WHITE}*{ID}{COMPLETE}? { - yylval.sval = processId (yytext+1, yyleng-1); + yylval.sval = processId (yytext+1, yyleng-1); if (yytext[yyleng - 1] == COMPLETE_CHAR) return DOT_COMPLETE; - return DOT_ID; + return DOT_ID; } "."{WHITE}*{COMPLETE} { @@ -297,25 +297,25 @@ false { return FALSEKEYWORD; } } {ID}({WHITE}*"."{WHITE}*({ID}|\"{OPER}\"))*(" "*"'"|{COMPLETE})? { - int all_posn = find_dot_all (yytext); + int all_posn = find_dot_all (yytext); - if (all_posn == -1 && yytext[yyleng-1] == '\'') + if (all_posn == -1 && yytext[yyleng-1] == '\'') { BEGIN BEFORE_QUAL_QUOTE; yyless (yyleng-1); } - else if (all_posn >= 0) + else if (all_posn >= 0) yyless (all_posn); bool is_completion = yytext[yyleng - 1] == COMPLETE_CHAR; - yylval.sval = processId (yytext, yyleng); - return is_completion ? NAME_COMPLETE : NAME; - } + yylval.sval = processId (yytext, yyleng); + return is_completion ? NAME_COMPLETE : NAME; + } /* GDB EXPRESSION CONSTRUCTS */ "'"[^']+"'"{WHITE}*:: { - yyless (yyleng - 2); + yyless (yyleng - 2); yylval.sval = processId (yytext, yyleng); return NAME; } @@ -572,7 +572,7 @@ processId (const char *name0, int len) } /* Return TEXT[0..LEN-1], a string literal without surrounding quotes, - with special hex character notations replaced with characters. + with special hex character notations replaced with characters. Result valid until the next call to ada_parse. */ static struct stoken @@ -589,13 +589,13 @@ processString (const char *text, int len) while (p < lim) { if (p[0] == '[' && p[1] == '"' && p+2 < lim) - { - if (p[2] == '"') /* "...["""]... */ - { - *q = '"'; + { + if (p[2] == '"') /* "...["""]... */ + { + *q = '"'; p += 4; } - else + else { const char *end; ULONGEST chr = strtoulst (p + 2, &end, 16); @@ -604,9 +604,9 @@ processString (const char *text, int len) *q = (char) chr; p = end + 1; } - } + } else - *q = *p; + *q = *p; q += 1; p += 1; } @@ -755,8 +755,8 @@ rewind_to_char (int ch) /* Dummy definition to suppress warnings about unused static definitions. */ typedef void (*dummy_function) (); -dummy_function ada_flex_use[] = -{ +dummy_function ada_flex_use[] = +{ (dummy_function) yyunput }; diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 20260645b6c..d321e815ca4 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1884,7 +1884,7 @@ name_not_typename : NAME the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable, =exp) or just an exp. If name_not_typename was ever used in an lvalue context where only a name could occur, this might be useful. - | NAME_OR_INT + | NAME_OR_INT */ | oper { @@ -3169,7 +3169,7 @@ classify_name (struct parser_state *par_state, const struct block *block, filename. However, if the name was quoted, then it is better to check for a filename or a block, since this is the only way the user has of requiring the extension to be used. */ - if ((is_a_field_of_this.type == NULL && !is_after_structop) + if ((is_a_field_of_this.type == NULL && !is_after_structop) || is_quoted_name) { /* See if it's a file name. */ diff --git a/gdb/contrib/check-whitespace-pre-commit.py b/gdb/contrib/check-whitespace-pre-commit.py index f084a0879d8..b840aba9f47 100755 --- a/gdb/contrib/check-whitespace-pre-commit.py +++ b/gdb/contrib/check-whitespace-pre-commit.py @@ -18,7 +18,7 @@ import re import subprocess import sys -re_clean = re.compile("(^(gdb/testsuite/|gdbsupport/|gdbserver/)|[.](m4|ac|[ch])$)") +re_clean = re.compile("(^(gdb/testsuite/|gdbsupport/|gdbserver/)|[.](m4|ac|[chly])$)") re_clean_exclude = re.compile("^(gdb/symfile.c|gdb/cli/cli-cmds.c)$") clean = [] diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 7221b785211..f7b88289f15 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -946,7 +946,7 @@ declarator_1 : ptr_operator declarator_1 | direct_declarator_1 /* Function local variable or type. The typespec to - our left is the type of the containing function. + our left is the type of the containing function. This should be OK, because function local types can not be templates, so the return types of their members will not be mangled. If they are hopefully @@ -1163,7 +1163,7 @@ exp : exp '?' exp ':' exp %prec '?' state->fill_comp (DEMANGLE_COMPONENT_TRINARY_ARG2, $3, $5))); } ; - + exp : INT ; @@ -1180,7 +1180,7 @@ exp : SIZEOF '(' type ')' %prec UNARY ; /* C++. */ -exp : TRUEKEYWORD +exp : TRUEKEYWORD { struct demangle_component *i; i = state->make_name ("1", 1); $$ = state->fill_comp (DEMANGLE_COMPONENT_LITERAL, @@ -1189,7 +1189,7 @@ exp : TRUEKEYWORD } ; -exp : FALSEKEYWORD +exp : FALSEKEYWORD { struct demangle_component *i; i = state->make_name ("0", 1); $$ = state->fill_comp (DEMANGLE_COMPONENT_LITERAL, @@ -1364,10 +1364,10 @@ cpname_state::parse_number (const char *p, int len, int parsed_float, c = c_tolower (p[len - 1]); if (c == 'f') - { - len--; - type = make_builtin_type ("float"); - } + { + len--; + type = make_builtin_type ("float"); + } else if (c == 'l') { len--; @@ -1589,7 +1589,7 @@ cp_parse_escape (const char **string_ptr) state->lexptr += 2; \ lvalp->opname = string; \ return token; \ - } + } #define HANDLE_TOKEN3(string, token) \ if (state->lexptr[1] == string[1] && state->lexptr[2] == string[2]) \ @@ -1597,7 +1597,7 @@ cp_parse_escape (const char **string_ptr) state->lexptr += 3; \ lvalp->opname = string; \ return token; \ - } + } /* Read one token, getting characters through LEXPTR. */ diff --git a/gdb/d-exp.y b/gdb/d-exp.y index e774dee8449..f6b56296b22 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -1629,4 +1629,3 @@ yyerror (const char *msg) { pstate->parse_error (msg); } - diff --git a/gdb/f-exp.y b/gdb/f-exp.y index a8ee9a361f9..aed6e47e59f 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -20,8 +20,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* This was blantantly ripped off the C expression parser, please - be aware of that as you look at its basic structure -FMB */ +/* This was blantantly ripped off the C expression parser, please + be aware of that as you look at its basic structure -FMB */ /* Parse a F77 expression from text in a string, and return the result as a struct expression pointer. @@ -39,7 +39,7 @@ with include files ( and for example) just became too messy, particularly when such includes can be inserted at random times by the parser generator. */ - + %{ #include "expression.h" @@ -134,7 +134,7 @@ static int parse_number (struct parser_state *, const char *, int, int, YYSTYPE *); %} -%type exp type_exp start variable +%type exp type_exp start variable %type type typebase %type nonempty_typelist /* %type block */ @@ -156,7 +156,7 @@ static int parse_number (struct parser_state *, const char *, int, %token STRING_LITERAL %token BOOLEAN_LITERAL -%token NAME +%token NAME %token TYPENAME %token COMPLETE %type name @@ -167,7 +167,7 @@ static int parse_number (struct parser_state *, const char *, int, E.g. "c" when input_radix==16. Depending on the parse, it will be turned into a name or into a number. */ -%token NAME_OR_INT +%token NAME_OR_INT %token SIZEOF KIND %token ERROR @@ -180,9 +180,9 @@ static int parse_number (struct parser_state *, const char *, int, %token REAL_KEYWORD REAL_S4_KEYWORD REAL_S8_KEYWORD REAL_S16_KEYWORD %token COMPLEX_KEYWORD COMPLEX_S4_KEYWORD COMPLEX_S8_KEYWORD %token COMPLEX_S16_KEYWORD -%token BOOL_AND BOOL_OR BOOL_NOT +%token BOOL_AND BOOL_OR BOOL_NOT %token SINGLE DOUBLE PRECISION -%token CHARACTER +%token CHARACTER %token DOLLAR_VARIABLE @@ -208,7 +208,7 @@ static int parse_number (struct parser_state *, const char *, int, %left '*' '/' %right STARSTAR %right '%' -%right UNARY +%right UNARY %right '(' @@ -255,14 +255,14 @@ exp : KIND '(' exp ')' %prec UNARY { pstate->wrap (); } ; -/* No more explicit array operators, we treat everything in F77 as - a function call. The disambiguation as to whether we are - doing a subscript operation or a function call is done +/* No more explicit array operators, we treat everything in F77 as + a function call. The disambiguation as to whether we are + doing a subscript operation or a function call is done later in eval.c. */ -exp : exp '(' +exp : exp '(' { pstate->start_arglist (); } - arglist ')' + arglist ')' { std::vector args = pstate->pop_vector (pstate->end_arglist ()); @@ -337,7 +337,7 @@ arglist : exp arglist : subrange { pstate->arglist_len = 1; } ; - + arglist : arglist ',' exp %prec ABOVE_COMMA { pstate->arglist_len++; } ; @@ -435,8 +435,8 @@ subrange: ':' ':' exp %prec ABOVE_COMMA } ; -complexnum: exp ',' exp - { } +complexnum: exp ',' exp + { } ; exp : '(' complexnum ')' @@ -647,7 +647,7 @@ ptype : typebase int array_size; struct type *follow_type = $1; struct type *range_type; - + while (!done) switch (type_stack->pop ()) { @@ -734,9 +734,9 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ { $$ = parse_f_type (pstate)->builtin_integer; } | INT_S8_KEYWORD { $$ = parse_f_type (pstate)->builtin_integer_s8; } - | CHARACTER + | CHARACTER { $$ = parse_f_type (pstate)->builtin_character; } - | LOGICAL_S1_KEYWORD + | LOGICAL_S1_KEYWORD { $$ = parse_f_type (pstate)->builtin_logical_s1; } | LOGICAL_S2_KEYWORD { $$ = parse_f_type (pstate)->builtin_logical_s2; } @@ -746,7 +746,7 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ { $$ = parse_f_type (pstate)->builtin_logical; } | LOGICAL_S8_KEYWORD { $$ = parse_f_type (pstate)->builtin_logical_s8; } - | REAL_KEYWORD + | REAL_KEYWORD { $$ = parse_f_type (pstate)->builtin_real; } | REAL_S4_KEYWORD { $$ = parse_f_type (pstate)->builtin_real; } @@ -764,7 +764,7 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ { $$ = parse_f_type (pstate)->builtin_complex; } | COMPLEX_S8_KEYWORD { $$ = parse_f_type (pstate)->builtin_complex_s8; } - | COMPLEX_S16_KEYWORD + | COMPLEX_S16_KEYWORD { $$ = parse_f_type (pstate)->builtin_complex_s16; if ($$->code () == TYPE_CODE_ERROR) error (_("unsupported type %s"), @@ -806,7 +806,7 @@ name_not_typename : NAME the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable, =exp) or just an exp. If name_not_typename was ever used in an lvalue context where only a name could occur, this might be useful. - | NAME_OR_INT + | NAME_OR_INT */ ; @@ -1039,7 +1039,7 @@ parse_number (struct parser_state *par_state, len -= 2; } break; - + case 't': case 'T': case 'd': @@ -1051,12 +1051,12 @@ parse_number (struct parser_state *par_state, len -= 2; } break; - + default: base = 8; break; } - + while (len-- > 0) { c = *p++; @@ -1087,12 +1087,12 @@ parse_number (struct parser_state *par_state, range_error (_("Overflow on numeric constant.")); prevn = n; } - + /* If the number is too big to be an int, or it's got an l suffix then it's a long. Work out if this has to be a long by shifting right and seeing if anything remains, and the target int size is different to the target long size. - + In the expression below, we could have tested (n >> gdbarch_int_bit (parse_gdbarch)) to see if it was zero, @@ -1112,28 +1112,28 @@ parse_number (struct parser_state *par_state, unsigned_type = parse_type (par_state)->builtin_unsigned_long; signed_type = parse_type (par_state)->builtin_long; } - else + else { bits_available = gdbarch_int_bit (par_state->gdbarch ()); unsigned_type = parse_type (par_state)->builtin_unsigned_int; signed_type = parse_type (par_state)->builtin_int; - } + } high_bit = ((ULONGEST)1) << (bits_available - 1); - + if (RANGE_CHECK && ((n >> 2) >> (bits_available - 2))) range_error (_("Overflow on numeric constant.")); putithere->typed_val.val = n; - + /* If the high bit of the worked out type is set then this number has to be unsigned. */ - - if (unsigned_p || (n & high_bit)) + + if (unsigned_p || (n & high_bit)) putithere->typed_val.type = unsigned_type; - else + else putithere->typed_val.type = signed_type; - + return INT; } @@ -1343,7 +1343,7 @@ static const f_token f_keywords[] = /* Implementation of a dynamically expandable buffer for processing input characters acquired through lexptr and building a value to return in - yylval. Ripped off from ch-exp.y */ + yylval. Ripped off from ch-exp.y */ static char *tempbuf; /* Current buffer contents */ static int tempbufsize; /* Size of allocated buffer */ @@ -1376,9 +1376,9 @@ growbuf_by_size (int count) tempbuf = (char *) realloc (tempbuf, tempbufsize); } -/* Blatantly ripped off from ch-exp.y. This routine recognizes F77 +/* Blatantly ripped off from ch-exp.y. This routine recognizes F77 string-literals. - + Recognize a string literal. A string literal is a nonzero sequence of characters enclosed in matching single quotes, except that a single character inside single quotes is a character literal, which @@ -1438,9 +1438,9 @@ yylex (void) last_was_structop = false; retry: - + pstate->prev_lexptr = pstate->lexptr; - + tokstart = pstate->lexptr; /* First of all, let us make sure we are not dealing with the @@ -1482,43 +1482,43 @@ yylex (void) else if (pstate->parse_completion && saw_structop) return COMPLETE; return 0; - + case ' ': case '\t': case '\n': pstate->lexptr++; goto retry; - + case '\'': token = match_string_literal (); if (token != 0) return (token); break; - + case '(': paren_depth++; pstate->lexptr++; return c; - + case ')': if (paren_depth == 0) return 0; paren_depth--; pstate->lexptr++; return c; - + case ',': if (pstate->comma_terminates && paren_depth == 0) return 0; pstate->lexptr++; return c; - + case '.': /* Might be a floating point number. */ if (pstate->lexptr[1] < '0' || pstate->lexptr[1] > '9') goto symbol; /* Nope, must be a symbol. */ [[fallthrough]]; - + case '0': case '1': case '2': @@ -1534,7 +1534,7 @@ yylex (void) int got_dot = 0, got_e = 0, got_d = 0, toktype; const char *p = tokstart; int hex = input_radix > 10; - + if (c == '0' && (p[1] == 'x' || p[1] == 'X')) { p += 2; @@ -1546,7 +1546,7 @@ yylex (void) p += 2; hex = 0; } - + for (;; ++p) { if (!hex && !got_e && (*p == 'e' || *p == 'E')) @@ -1604,26 +1604,26 @@ yylex (void) pstate->lexptr++; return c; } - + if (!(c == '_' || c == '$' || c ==':' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) /* We must have come across a bad character (e.g. ';'). */ error (_("Invalid character '%c' in expression."), c); - + namelen = 0; for (c = tokstart[namelen]; (c == '_' || c == '$' || c == ':' || (c >= '0' && c <= '9') - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); + || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); c = tokstart[++namelen]); - - /* The token "if" terminates the expression and is NOT + + /* The token "if" terminates the expression and is NOT removed from the input stream. */ - + if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') return 0; - + pstate->lexptr += namelen; - + /* Catch specific keywords. */ for (const auto &keyword : f_keywords) @@ -1639,7 +1639,7 @@ yylex (void) yylval.sval.ptr = tokstart; yylval.sval.length = namelen; - + if (*tokstart == '$') return DOLLAR_VARIABLE; @@ -1699,7 +1699,7 @@ yylex (void) && ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))) { - YYSTYPE newlval; /* Its value is ignored. */ + YYSTYPE newlval; /* Its value is ignored. */ hextype = parse_number (pstate, tokstart, namelen, 0, &newlval); if (hextype == INT) { diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index 55d5f2e3056..c72cdf6aed1 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -34,7 +34,7 @@ with include files ( and for example) just became too messy, particularly when such includes can be inserted at random times by the parser generator. */ - + %{ #include "expression.h" @@ -96,8 +96,8 @@ using namespace expr; %type exp type_exp start set %type variable %type type -%type block -%type fblock +%type block +%type fblock %token INT HEX ERROR %token UINT M2_TRUE M2_FALSE CHAR @@ -139,7 +139,7 @@ using namespace expr; %right '^' DOT '[' '(' %right NOT '~' %left COLONCOLON QID -/* This is not an actual token ; it is used for precedence. +/* This is not an actual token ; it is used for precedence. %right QID */ @@ -338,8 +338,8 @@ non_empty_arglist non_empty_arglist : non_empty_arglist ',' exp %prec ABOVE_COMMA - { pstate->arglist_len++; } - ; + { pstate->arglist_len++; } + ; /* GDB construct */ exp : '{' type '}' exp %prec UNARY @@ -489,7 +489,7 @@ exp : STRING ; /* This will be used for extensions later. Like adding modules. */ -block : fblock +block : fblock { $$ = $1->value_block (); } ; @@ -500,7 +500,7 @@ fblock : BLOCKNAME SEARCH_VFT, 0).symbol; $$ = sym;} ; - + /* GDB scope operator */ fblock : block COLONCOLON BLOCKNAME diff --git a/gdb/p-exp.y b/gdb/p-exp.y index a68443a5b7f..ff84e7726ec 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -540,8 +540,8 @@ exp : DOLLAR_VARIABLE intvar); current_type = val->type (); } - } - ; + } + ; exp : SIZEOF '(' type ')' %prec UNARY { @@ -782,7 +782,7 @@ name_not_typename : NAME the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable, =exp) or just an exp. If name_not_typename was ever used in an lvalue context where only a name could occur, this might be useful. - | NAME_OR_INT + | NAME_OR_INT */ ; @@ -1408,7 +1408,7 @@ yylex (void) { yylval.lval = 1; free (uptokstart); - return TRUEKEYWORD; + return TRUEKEYWORD; } if (strcmp (uptokstart, "SELF") == 0) { @@ -1637,7 +1637,7 @@ yylex (void) && ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))) { - YYSTYPE newlval; /* Its value is ignored. */ + YYSTYPE newlval; /* Its value is ignored. */ hextype = parse_number (pstate, tokstart, namelen, 0, &newlval); if (hextype == INT) { -- 2.47.3