Add `set print repeats' tests for C/C++ arrays
[binutils-gdb.git] / gdb / d-exp.y
index 1a75431ea2763371212e7a97486c82588271cfd2..ef858ecbd4b753bd2c962fee66d4b54cc0cf3f96 100644 (file)
@@ -1,6 +1,6 @@
 /* YACC parser for D expressions, for GDB.
 
-   Copyright (C) 2014-2021 Free Software Foundation, Inc.
+   Copyright (C) 2014-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -452,8 +452,7 @@ PrimaryExpression:
                    {
                      if (symbol_read_needs_frame (sym.symbol))
                        pstate->block_tracker->update (sym);
-                     pstate->push_new<var_value_operation> (sym.symbol,
-                                                            sym.block);
+                     pstate->push_new<var_value_operation> (sym);
                    }
                  else if (is_a_field_of_this.type != NULL)
                     {
@@ -470,8 +469,7 @@ PrimaryExpression:
                      /* Lookup foreign name in global static symbols.  */
                      msymbol = lookup_bound_minimal_symbol (copy.c_str ());
                      if (msymbol.minsym != NULL)
-                       pstate->push_new<var_msym_value_operation>
-                         (msymbol.minsym, msymbol.objfile);
+                       pstate->push_new<var_msym_value_operation> (msymbol);
                      else if (!have_full_symbols () && !have_partial_symbols ())
                        error (_("No symbol table is loaded.  Use the \"file\" command"));
                      else
@@ -641,7 +639,7 @@ type_aggregate_p (struct type *type)
          || type->code () == TYPE_CODE_UNION
          || type->code () == TYPE_CODE_MODULE
          || (type->code () == TYPE_CODE_ENUM
-             && TYPE_DECLARED_CLASS (type)));
+             && type->is_declared_class ()));
 }
 
 /* Take care of parsing a number (anything that starts with a digit).
@@ -965,25 +963,25 @@ static const struct token tokentab2[] =
     {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR},
     {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
     {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
-    {"++", INCREMENT, BINOP_END},
-    {"--", DECREMENT, BINOP_END},
-    {"&&", ANDAND, BINOP_END},
-    {"||", OROR, BINOP_END},
-    {"^^", HATHAT, BINOP_END},
-    {"<<", LSH, BINOP_END},
-    {">>", RSH, BINOP_END},
-    {"==", EQUAL, BINOP_END},
-    {"!=", NOTEQUAL, BINOP_END},
-    {"<=", LEQ, BINOP_END},
-    {">=", GEQ, BINOP_END},
-    {"..", DOTDOT, BINOP_END},
+    {"++", INCREMENT, OP_NULL},
+    {"--", DECREMENT, OP_NULL},
+    {"&&", ANDAND, OP_NULL},
+    {"||", OROR, OP_NULL},
+    {"^^", HATHAT, OP_NULL},
+    {"<<", LSH, OP_NULL},
+    {">>", RSH, OP_NULL},
+    {"==", EQUAL, OP_NULL},
+    {"!=", NOTEQUAL, OP_NULL},
+    {"<=", LEQ, OP_NULL},
+    {">=", GEQ, OP_NULL},
+    {"..", DOTDOT, OP_NULL},
   };
 
 /* Identifier-like tokens.  */
 static const struct token ident_tokens[] =
   {
-    {"is", IDENTITY, BINOP_END},
-    {"!is", NOTIDENTITY, BINOP_END},
+    {"is", IDENTITY, OP_NULL},
+    {"!is", NOTIDENTITY, OP_NULL},
 
     {"cast", CAST_KEYWORD, OP_NULL},
     {"const", CONST_KEYWORD, OP_NULL},
@@ -1029,7 +1027,6 @@ lex_one_token (struct parser_state *par_state)
 {
   int c;
   int namelen;
-  unsigned int i;
   const char *tokstart;
   int saw_structop = last_was_structop;
 
@@ -1041,21 +1038,21 @@ lex_one_token (struct parser_state *par_state)
 
   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)
       {
        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)
       {
        pstate->lexptr += 2;
-       yylval.opcode = tokentab2[i].opcode;
-       return tokentab2[i].token;
+       yylval.opcode = token.opcode;
+       return token.token;
       }
 
   switch (c = *tokstart)
@@ -1276,13 +1273,13 @@ lex_one_token (struct parser_state *par_state)
 
   /* 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)
       {
        /* 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 == '$')