diff options
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r-- | gdb/c-exp.y | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 9b4b88a..22cd50a 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -2644,7 +2644,6 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name) { int c; int namelen; - unsigned int i; const char *tokstart; bool saw_structop = last_was_structop; @@ -2667,33 +2666,33 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name) tokstart = pstate->lexptr; /* See if it is a special token of length 3. */ - for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++) - if (strncmp (tokstart, tokentab3[i].oper, 3) == 0) + for (const auto &token : tokentab3) + if (strncmp (tokstart, token.oper, 3) == 0) { - if ((tokentab3[i].flags & FLAG_CXX) != 0 + if ((token.flags & FLAG_CXX) != 0 && par_state->language ()->la_language != language_cplus) break; - gdb_assert ((tokentab3[i].flags & FLAG_C) == 0); + gdb_assert ((token.flags & FLAG_C) == 0); pstate->lexptr += 3; - yylval.opcode = tokentab3[i].opcode; - return tokentab3[i].token; + yylval.opcode = token.opcode; + return token.token; } /* See if it is a special token of length 2. */ - for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++) - if (strncmp (tokstart, tokentab2[i].oper, 2) == 0) + for (const auto &token : tokentab2) + if (strncmp (tokstart, token.oper, 2) == 0) { - if ((tokentab2[i].flags & FLAG_CXX) != 0 + if ((token.flags & FLAG_CXX) != 0 && par_state->language ()->la_language != language_cplus) break; - gdb_assert ((tokentab2[i].flags & FLAG_C) == 0); + gdb_assert ((token.flags & FLAG_C) == 0); pstate->lexptr += 2; - yylval.opcode = tokentab2[i].opcode; - if (tokentab2[i].token == ARROW) + yylval.opcode = token.opcode; + if (token.token == ARROW) last_was_structop = 1; - return tokentab2[i].token; + return token.token; } switch (c = *tokstart) @@ -2979,18 +2978,18 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name) /* Catch specific keywords. */ std::string copy = copy_name (yylval.sval); - for (i = 0; i < sizeof ident_tokens / sizeof ident_tokens[0]; i++) - if (copy == ident_tokens[i].oper) + for (const auto &token : ident_tokens) + if (copy == token.oper) { - if ((ident_tokens[i].flags & FLAG_CXX) != 0 + if ((token.flags & FLAG_CXX) != 0 && par_state->language ()->la_language != language_cplus) break; - if ((ident_tokens[i].flags & FLAG_C) != 0 + if ((token.flags & FLAG_C) != 0 && par_state->language ()->la_language != language_c && par_state->language ()->la_language != language_objc) break; - if ((ident_tokens[i].flags & FLAG_SHADOW) != 0) + if ((token.flags & FLAG_SHADOW) != 0) { struct field_of_this_result is_a_field_of_this; @@ -3009,8 +3008,8 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name) /* It is ok to always set this, even though we don't always strictly need to. */ - yylval.opcode = ident_tokens[i].opcode; - return ident_tokens[i].token; + yylval.opcode = token.opcode; + return token.token; } if (*tokstart == '$') |