Support rvalue reference type in parser
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index 714e02ef918421914ba081eb6ac0d620bac23210..7c25641738bebbf4167c57af79728a2d1ad23106 100644 (file)
@@ -1,5 +1,5 @@
 /* YACC parser for C expressions, for GDB.
-   Copyright (C) 1986-2014 Free Software Foundation, Inc.
+   Copyright (C) 1986-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    with include files (<malloc.h> and <stdlib.h> for example) just became
    too messy, particularly when such includes can be inserted at random
    times by the parser generator.  */
-   
+
 %{
 
 #include "defs.h"
-#include <string.h>
 #include <ctype.h>
 #include "expression.h"
 #include "value.h"
 
 #define parse_type(ps) builtin_type (parse_gdbarch (ps))
 
-/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
-   as well as gratuitiously global symbol names, so we can have multiple
-   yacc generated parsers in gdb.  Note that these are only the variables
-   produced by yacc.  If other parser generators (bison, byacc, etc) produce
-   additional global names that conflict at link time, then those parser
-   generators need to be fixed instead of adding those names to this list. */
-
-#define        yymaxdepth c_maxdepth
-#define        yyparse c_parse_internal
-#define        yylex   c_lex
-#define        yyerror c_error
-#define        yylval  c_lval
-#define        yychar  c_char
-#define        yydebug c_debug
-#define        yypact  c_pact  
-#define        yyr1    c_r1                    
-#define        yyr2    c_r2                    
-#define        yydef   c_def           
-#define        yychk   c_chk           
-#define        yypgo   c_pgo           
-#define        yyact   c_act           
-#define        yyexca  c_exca
-#define yyerrflag c_errflag
-#define yynerrs        c_nerrs
-#define        yyps    c_ps
-#define        yypv    c_pv
-#define        yys     c_s
-#define        yy_yys  c_yys
-#define        yystate c_state
-#define        yytmp   c_tmp
-#define        yyv     c_v
-#define        yy_yyv  c_yyv
-#define        yyval   c_val
-#define        yylloc  c_lloc
-#define yyreds c_reds          /* With YYDEBUG defined */
-#define yytoks c_toks          /* With YYDEBUG defined */
-#define yyname c_name          /* With YYDEBUG defined */
-#define yyrule c_rule          /* With YYDEBUG defined */
-#define yylhs  c_yylhs
-#define yylen  c_yylen
-#define yydefred c_yydefred
-#define yydgoto        c_yydgoto
-#define yysindex c_yysindex
-#define yyrindex c_yyrindex
-#define yygindex c_yygindex
-#define yytable         c_yytable
-#define yycheck         c_yycheck
-#define yyss   c_yyss
-#define yysslim        c_yysslim
-#define yyssp  c_yyssp
-#define yystacksize c_yystacksize
-#define yyvs   c_yyvs
-#define yyvsp  c_yyvsp
-
-#ifndef YYDEBUG
-#define        YYDEBUG 1               /* Default to yydebug support */
-#endif
-
-#define YYFPRINTF parser_fprintf
+/* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
+   etc).  */
+#define GDB_YY_REMAP_PREFIX c_
+#include "yy-remap.h"
 
 /* The state of the parser, used internally when we are parsing the
    expression.  */
@@ -165,7 +109,7 @@ static int type_aggregate_p (struct type *);
 
     struct type_stack *type_stack;
 
-    struct objc_class_str class;
+    struct objc_class_str theclass;
   }
 
 %{
@@ -216,11 +160,11 @@ static void c_print_token (FILE *file, int type, YYSTYPE value);
 %token <ssym> UNKNOWN_CPP_NAME
 %token <voidval> COMPLETE
 %token <tsym> TYPENAME
-%token <class> CLASSNAME       /* ObjC Class name */
+%token <theclass> CLASSNAME    /* ObjC Class name */
 %type <sval> name
 %type <svec> string_exp
 %type <ssym> name_not_typename
-%type <tsym> typename
+%type <tsym> type_name
 
  /* This is like a '[' token, but is only generated when parsing
     Objective C.  This lets us reuse the same parser without
@@ -232,14 +176,14 @@ static void c_print_token (FILE *file, int type, YYSTYPE value);
    E.g. "c" when input_radix==16.  Depending on the parse, it will be
    turned into a name or into a number.  */
 
-%token <ssym> NAME_OR_INT 
+%token <ssym> NAME_OR_INT
 
 %token OPERATOR
 %token STRUCT CLASS UNION ENUM SIZEOF UNSIGNED COLONCOLON
 %token TEMPLATE
 %token ERROR
 %token NEW DELETE
-%type <sval> operator
+%type <sval> oper
 %token REINTERPRET_CAST DYNAMIC_CAST STATIC_CAST CONST_CAST
 %token ENTRY
 %token TYPEOF
@@ -276,7 +220,7 @@ static void c_print_token (FILE *file, int type, YYSTYPE value);
 %left '*' '/' '%'
 %right UNARY INCREMENT DECREMENT
 %right ARROW ARROW_STAR '.' DOT_STAR '[' OBJC_LBRAC '('
-%token <ssym> BLOCKNAME 
+%token <ssym> BLOCKNAME
 %token <bval> FILENAME
 %type <bval> block
 %left COLONCOLON
@@ -480,17 +424,17 @@ exp       :       exp OBJC_LBRAC exp1 ']'
 
 exp    :       OBJC_LBRAC TYPENAME
                        {
-                         CORE_ADDR class;
+                         CORE_ADDR theclass;
 
-                         class = lookup_objc_class (parse_gdbarch (pstate),
+                         theclass = lookup_objc_class (parse_gdbarch (pstate),
                                                     copy_name ($2.stoken));
-                         if (class == 0)
+                         if (theclass == 0)
                            error (_("%s is not an ObjC Class"),
                                   copy_name ($2.stoken));
                          write_exp_elt_opcode (pstate, OP_LONG);
                          write_exp_elt_type (pstate,
                                            parse_type (pstate)->builtin_int);
-                         write_exp_elt_longcst (pstate, (LONGEST) class);
+                         write_exp_elt_longcst (pstate, (LONGEST) theclass);
                          write_exp_elt_opcode (pstate, OP_LONG);
                          start_msglist();
                        }
@@ -506,7 +450,7 @@ exp :       OBJC_LBRAC CLASSNAME
                          write_exp_elt_opcode (pstate, OP_LONG);
                          write_exp_elt_type (pstate,
                                            parse_type (pstate)->builtin_int);
-                         write_exp_elt_longcst (pstate, (LONGEST) $2.class);
+                         write_exp_elt_longcst (pstate, (LONGEST) $2.theclass);
                          write_exp_elt_opcode (pstate, OP_LONG);
                          start_msglist();
                        }
@@ -543,7 +487,7 @@ msgarg      :       name ':' exp
                        { add_msglist(0, 0);   }
        ;
 
-exp    :       exp '(' 
+exp    :       exp '('
                        /* This is to save the value of arglist_len
                           being accumulated by an outer function call.  */
                        { start_arglist (); }
@@ -716,7 +660,7 @@ exp :       exp OROR exp
 exp    :       exp '?' exp ':' exp     %prec '?'
                        { write_exp_elt_opcode (pstate, TERNOP_COND); }
        ;
-                         
+
 exp    :       exp '=' exp
                        { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
        ;
@@ -794,13 +738,13 @@ exp       :       SIZEOF '(' type ')'     %prec UNARY
                                              (parse_language (pstate),
                                               parse_gdbarch (pstate),
                                               "int"));
-                         CHECK_TYPEDEF (type);
+                         type = check_typedef (type);
 
                            /* $5.3.3/2 of the C++ Standard (n3290 draft)
                               says of sizeof:  "When applied to a reference
                               or a reference type, the result is the size of
                               the referenced type."  */
-                         if (TYPE_CODE (type) == TYPE_CODE_REF)
+                         if (TYPE_IS_REFERENCE (type))
                            type = check_typedef (TYPE_TARGET_TYPE (type));
                          write_exp_elt_longcst (pstate,
                                                 (LONGEST) TYPE_LENGTH (type));
@@ -840,7 +784,7 @@ string_exp:
 
                          vec->type = $1.type;
                          vec->length = $1.length;
-                         vec->ptr = malloc ($1.length + 1);
+                         vec->ptr = (char *) malloc ($1.length + 1);
                          memcpy (vec->ptr, $1.ptr, $1.length + 1);
                        }
 
@@ -850,10 +794,10 @@ string_exp:
                             for convenience.  */
                          char *p;
                          ++$$.len;
-                         $$.tokens = realloc ($$.tokens,
-                                              $$.len * sizeof (struct typed_stoken));
+                         $$.tokens = XRESIZEVEC (struct typed_stoken,
+                                                 $$.tokens, $$.len);
 
-                         p = malloc ($2.length + 1);
+                         p = (char *) malloc ($2.length + 1);
                          memcpy (p, $2.ptr, $2.length + 1);
 
                          $$.tokens[$$.len - 1].type = $2.type;
@@ -865,7 +809,7 @@ string_exp:
 exp    :       string_exp
                        {
                          int i;
-                         enum c_string_type type = C_STRING;
+                         c_string_type type = C_STRING;
 
                          for (i = 0; i < $1.len; ++i)
                            {
@@ -879,7 +823,7 @@ exp :       string_exp
                                  if (type != C_STRING
                                      && type != $1.tokens[i].type)
                                    error (_("Undefined string concatenation."));
-                                 type = $1.tokens[i].type;
+                                 type = (enum c_string_type_values) $1.tokens[i].type;
                                  break;
                                default:
                                  /* internal error */
@@ -904,7 +848,7 @@ exp     :   NSSTRING        /* ObjC NextStep NSString constant
        ;
 
 /* C++.  */
-exp     :       TRUEKEYWORD    
+exp     :       TRUEKEYWORD
                         { write_exp_elt_opcode (pstate, OP_LONG);
                           write_exp_elt_type (pstate,
                                          parse_type (pstate)->builtin_bool);
@@ -912,7 +856,7 @@ exp     :       TRUEKEYWORD
                           write_exp_elt_opcode (pstate, OP_LONG); }
        ;
 
-exp     :       FALSEKEYWORD   
+exp     :       FALSEKEYWORD
                         { write_exp_elt_opcode (pstate, OP_LONG);
                           write_exp_elt_type (pstate,
                                          parse_type (pstate)->builtin_bool);
@@ -924,8 +868,8 @@ exp     :       FALSEKEYWORD
 
 block  :       BLOCKNAME
                        {
-                         if ($1.sym)
-                           $$ = SYMBOL_BLOCK_VALUE ($1.sym);
+                         if ($1.sym.symbol)
+                           $$ = SYMBOL_BLOCK_VALUE ($1.sym.symbol);
                          else
                            error (_("No file or function \"%s\"."),
                                   copy_name ($1.stoken));
@@ -939,7 +883,8 @@ block       :       BLOCKNAME
 block  :       block COLONCOLON name
                        { struct symbol *tem
                            = lookup_symbol (copy_name ($3), $1,
-                                            VAR_DOMAIN, NULL);
+                                            VAR_DOMAIN, NULL).symbol;
+
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
                            error (_("No function \"%s\" in specified context."),
                                   copy_name ($3));
@@ -947,7 +892,7 @@ block       :       block COLONCOLON name
        ;
 
 variable:      name_not_typename ENTRY
-                       { struct symbol *sym = $1.sym;
+                       { struct symbol *sym = $1.sym.symbol;
 
                          if (sym == NULL || !SYMBOL_IS_ARGUMENT (sym)
                              || !symbol_read_needs_frame (sym))
@@ -962,31 +907,31 @@ variable: name_not_typename ENTRY
        ;
 
 variable:      block COLONCOLON name
-                       { struct symbol *sym;
-                         sym = lookup_symbol (copy_name ($3), $1,
-                                              VAR_DOMAIN, NULL);
-                         if (sym == 0)
+                       { struct block_symbol sym
+                           = lookup_symbol (copy_name ($3), $1,
+                                            VAR_DOMAIN, NULL);
+
+                         if (sym.symbol == 0)
                            error (_("No symbol \"%s\" in specified context."),
                                   copy_name ($3));
-                         if (symbol_read_needs_frame (sym))
+                         if (symbol_read_needs_frame (sym.symbol))
                            {
                              if (innermost_block == 0
-                                 || contained_in (block_found,
+                                 || contained_in (sym.block,
                                                   innermost_block))
-                               innermost_block = block_found;
+                               innermost_block = sym.block;
                            }
 
                          write_exp_elt_opcode (pstate, OP_VAR_VALUE);
-                         /* block_found is set by lookup_symbol.  */
-                         write_exp_elt_block (pstate, block_found);
-                         write_exp_elt_sym (pstate, sym);
+                         write_exp_elt_block (pstate, sym.block);
+                         write_exp_elt_sym (pstate, sym.symbol);
                          write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
        ;
 
 qualified_name:        TYPENAME COLONCOLON name
                        {
                          struct type *type = $1.type;
-                         CHECK_TYPEDEF (type);
+                         type = check_typedef (type);
                          if (!type_aggregate_p (type))
                            error (_("`%s' is not defined as an aggregate type."),
                                   TYPE_SAFE_NAME (type));
@@ -1002,11 +947,11 @@ qualified_name:  TYPENAME COLONCOLON name
                          struct stoken tmp_token;
                          char *buf;
 
-                         CHECK_TYPEDEF (type);
+                         type = check_typedef (type);
                          if (!type_aggregate_p (type))
                            error (_("`%s' is not defined as an aggregate type."),
                                   TYPE_SAFE_NAME (type));
-                         buf = alloca ($4.length + 2);
+                         buf = (char *) alloca ($4.length + 2);
                          tmp_token.ptr = buf;
                          tmp_token.length = $4.length + 1;
                          buf[0] = '~';
@@ -1036,9 +981,9 @@ variable:  qualified_name
                          struct symbol *sym;
                          struct bound_minimal_symbol msymbol;
 
-                         sym =
-                           lookup_symbol (name, (const struct block *) NULL,
-                                          VAR_DOMAIN, NULL);
+                         sym
+                           lookup_symbol (name, (const struct block *) NULL,
+                                            VAR_DOMAIN, NULL).symbol;
                          if (sym)
                            {
                              write_exp_elt_opcode (pstate, OP_VAR_VALUE);
@@ -1059,24 +1004,21 @@ variable:       qualified_name
        ;
 
 variable:      name_not_typename
-                       { struct symbol *sym = $1.sym;
+                       { struct block_symbol sym = $1.sym;
 
-                         if (sym)
+                         if (sym.symbol)
                            {
-                             if (symbol_read_needs_frame (sym))
+                             if (symbol_read_needs_frame (sym.symbol))
                                {
                                  if (innermost_block == 0
-                                     || contained_in (block_found, 
+                                     || contained_in (sym.block,
                                                       innermost_block))
-                                   innermost_block = block_found;
+                                   innermost_block = sym.block;
                                }
 
                              write_exp_elt_opcode (pstate, OP_VAR_VALUE);
-                             /* We want to use the selected frame, not
-                                another more inner frame which happens to
-                                be in the same block.  */
-                             write_exp_elt_block (pstate, NULL);
-                             write_exp_elt_sym (pstate, sym);
+                             write_exp_elt_block (pstate, sym.block);
+                             write_exp_elt_sym (pstate, sym.symbol);
                              write_exp_elt_opcode (pstate, OP_VAR_VALUE);
                            }
                          else if ($1.is_a_field_of_this)
@@ -1085,9 +1027,9 @@ variable: name_not_typename
                                 not inadvertently convert from a method call
                                 to data ref.  */
                              if (innermost_block == 0
-                                 || contained_in (block_found,
+                                 || contained_in (sym.block,
                                                   innermost_block))
-                               innermost_block = block_found;
+                               innermost_block = sym.block;
                              write_exp_elt_opcode (pstate, OP_THIS);
                              write_exp_elt_opcode (pstate, OP_THIS);
                              write_exp_elt_opcode (pstate, STRUCTOP_PTR);
@@ -1124,10 +1066,10 @@ cv_with_space_id : const_or_volatile space_identifier const_or_volatile
        ;
 
 const_or_volatile_or_space_identifier_noopt: cv_with_space_id
-       | const_or_volatile_noopt 
+       | const_or_volatile_noopt
        ;
 
-const_or_volatile_or_space_identifier: 
+const_or_volatile_or_space_identifier:
                const_or_volatile_or_space_identifier_noopt
        |
        ;
@@ -1136,13 +1078,17 @@ ptr_operator:
                ptr_operator '*'
                        { insert_type (tp_pointer); }
                const_or_volatile_or_space_identifier
-       |       '*' 
+       |       '*'
                        { insert_type (tp_pointer); }
                const_or_volatile_or_space_identifier
        |       '&'
                        { insert_type (tp_reference); }
        |       '&' ptr_operator
                        { insert_type (tp_reference); }
+       |       ANDAND
+                       { insert_type (tp_rvalue_reference); }
+       |       ANDAND ptr_operator
+                       { insert_type (tp_rvalue_reference); }
        ;
 
 ptr_operator_ts: ptr_operator
@@ -1156,7 +1102,7 @@ ptr_operator_ts: ptr_operator
 
 abs_decl:      ptr_operator_ts direct_abs_decl
                        { $$ = append_type_stack ($2, $1); }
-       |       ptr_operator_ts 
+       |       ptr_operator_ts
        |       direct_abs_decl
        ;
 
@@ -1315,7 +1261,7 @@ typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
                        { $$ = lookup_unsigned_typename (parse_language (pstate),
                                                         parse_gdbarch (pstate),
                                                         "short"); }
-       |       SHORT UNSIGNED 
+       |       SHORT UNSIGNED
                        { $$ = lookup_unsigned_typename (parse_language (pstate),
                                                         parse_gdbarch (pstate),
                                                         "short"); }
@@ -1354,12 +1300,12 @@ typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
                                              expression_context_block); }
        |       CLASS COMPLETE
                        {
-                         mark_completion_tag (TYPE_CODE_CLASS, "", 0);
+                         mark_completion_tag (TYPE_CODE_STRUCT, "", 0);
                          $$ = NULL;
                        }
        |       CLASS name COMPLETE
                        {
-                         mark_completion_tag (TYPE_CODE_CLASS, $2.ptr,
+                         mark_completion_tag (TYPE_CODE_STRUCT, $2.ptr,
                                               $2.length);
                          $$ = NULL;
                        }
@@ -1391,7 +1337,7 @@ typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
                                               $2.length);
                          $$ = NULL;
                        }
-       |       UNSIGNED typename
+       |       UNSIGNED type_name
                        { $$ = lookup_unsigned_typename (parse_language (pstate),
                                                         parse_gdbarch (pstate),
                                                         TYPE_NAME($2.type)); }
@@ -1399,7 +1345,7 @@ typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
                        { $$ = lookup_unsigned_typename (parse_language (pstate),
                                                         parse_gdbarch (pstate),
                                                         "int"); }
-       |       SIGNED_KEYWORD typename
+       |       SIGNED_KEYWORD type_name
                        { $$ = lookup_signed_typename (parse_language (pstate),
                                                       parse_gdbarch (pstate),
                                                       TYPE_NAME($2.type)); }
@@ -1409,18 +1355,18 @@ typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
                                                       "int"); }
                 /* It appears that this rule for templates is never
                    reduced; template recognition happens by lookahead
-                   in the token processing code in yylex. */         
+                   in the token processing code in yylex. */
        |       TEMPLATE name '<' type '>'
                        { $$ = lookup_template_type(copy_name($2), $4,
                                                    expression_context_block);
                        }
-       | const_or_volatile_or_space_identifier_noopt typebase 
+       | const_or_volatile_or_space_identifier_noopt typebase
                        { $$ = follow_types ($2); }
-       | typebase const_or_volatile_or_space_identifier_noopt 
+       | typebase const_or_volatile_or_space_identifier_noopt
                        { $$ = follow_types ($1); }
        ;
 
-typename:      TYPENAME
+type_name:     TYPENAME
        |       INT_KEYWORD
                {
                  $$.stoken.ptr = "int";
@@ -1492,9 +1438,9 @@ const_and_volatile:       CONST_KEYWORD VOLATILE_KEYWORD
        |               VOLATILE_KEYWORD CONST_KEYWORD
        ;
 
-const_or_volatile_noopt:       const_and_volatile 
+const_or_volatile_noopt:       const_and_volatile
                        { insert_type (tp_const);
-                         insert_type (tp_volatile); 
+                         insert_type (tp_volatile);
                        }
        |               CONST_KEYWORD
                        { insert_type (tp_const); }
@@ -1502,7 +1448,7 @@ const_or_volatile_noopt:          const_and_volatile
                        { insert_type (tp_volatile); }
        ;
 
-operator:      OPERATOR NEW
+oper:  OPERATOR NEW
                        { $$ = operator_stoken (" new"); }
        |       OPERATOR DELETE
                        { $$ = operator_stoken (" delete"); }
@@ -1613,16 +1559,11 @@ operator:       OPERATOR NEW
        |       OPERATOR OBJC_LBRAC ']'
                        { $$ = operator_stoken ("[]"); }
        |       OPERATOR conversion_type_id
-                       { char *name;
-                         long length;
-                         struct ui_file *buf = mem_fileopen ();
+                       { string_file buf;
 
-                         c_print_type ($2, NULL, buf, -1, 0,
+                         c_print_type ($2, NULL, &buf, -1, 0,
                                        &type_print_raw_options);
-                         name = ui_file_xstrdup (buf, &length);
-                         ui_file_delete (buf);
-                         $$ = operator_stoken (name);
-                         free (name);
+                         $$ = operator_stoken (buf.c_str ());
                        }
        ;
 
@@ -1633,7 +1574,7 @@ name      :       NAME { $$ = $1.stoken; }
        |       TYPENAME { $$ = $1.stoken; }
        |       NAME_OR_INT  { $$ = $1.stoken; }
        |       UNKNOWN_CPP_NAME  { $$ = $1.stoken; }
-       |       operator { $$ = $1; }
+       |       oper { $$ = $1; }
        ;
 
 name_not_typename :    NAME
@@ -1645,7 +1586,7 @@ name_not_typename :       NAME
    context where only a name could occur, this might be useful.
        |       NAME_OR_INT
  */
-       |       operator
+       |       oper
                        {
                          struct field_of_this_result is_a_field_of_this;
 
@@ -1667,7 +1608,7 @@ name_not_typename :       NAME
 static void
 write_destructor_name (struct parser_state *par_state, struct stoken token)
 {
-  char *copy = alloca (token.length + 1);
+  char *copy = (char *) alloca (token.length + 1);
 
   copy[0] = '~';
   memcpy (&copy[1], token.ptr, token.length);
@@ -1679,7 +1620,8 @@ write_destructor_name (struct parser_state *par_state, struct stoken token)
 }
 
 /* Returns a stoken of the operator name given by OP (which does not
-   include the string "operator").  */ 
+   include the string "operator").  */
+
 static struct stoken
 operator_stoken (const char *op)
 {
@@ -1688,7 +1630,7 @@ operator_stoken (const char *op)
   char *buf;
 
   st.length = strlen (operator_string) + strlen (op);
-  buf = malloc (st.length + 1);
+  buf = (char *) malloc (st.length + 1);
   strcpy (buf, operator_string);
   strcat (buf, op);
   st.ptr = buf;
@@ -1773,7 +1715,7 @@ parse_number (struct parser_state *par_state,
   struct type *unsigned_type;
   char *p;
 
-  p = alloca (len);
+  p = (char *) alloca (len);
   memcpy (p, buf, len);
 
   if (parsed_float)
@@ -1825,7 +1767,7 @@ parse_number (struct parser_state *par_state,
     }
 
   /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
-  if (p[0] == '0')
+  if (p[0] == '0' && len > 1)
     switch (p[1])
       {
       case 'x':
@@ -1958,7 +1900,7 @@ parse_number (struct parser_state *par_state,
   else
     {
       int shift;
-      if (sizeof (ULONGEST) * HOST_CHAR_BIT 
+      if (sizeof (ULONGEST) * HOST_CHAR_BIT
          < gdbarch_long_long_bit (parse_gdbarch (par_state)))
        /* A long long does not fit in a LONGEST.  */
        shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
@@ -1974,11 +1916,11 @@ parse_number (struct parser_state *par_state,
    /* 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_int.type = unsigned_type;
      }
-   else 
+   else
      {
        putithere->typed_val_int.type = signed_type;
      }
@@ -2160,12 +2102,13 @@ c_parse_escape (const char **ptr, struct obstack *output)
    stored in VALUE.  This returns a token value, either STRING or
    CHAR, depending on what was parsed.  *HOST_CHARS is set to the
    number of host characters in the literal.  */
+
 static int
 parse_string_or_char (const char *tokptr, const char **outptr,
                      struct typed_stoken *value, int *host_chars)
 {
   int quote;
-  enum c_string_type type;
+  c_string_type type;
   int is_objc = 0;
 
   /* Build the gdb internal form of the input string in tempbuf.  Note
@@ -2248,7 +2191,7 @@ parse_string_or_char (const char *tokptr, const char **outptr,
   ++tokptr;
 
   value->type = type;
-  value->ptr = obstack_base (&tempbuf);
+  value->ptr = (char *) obstack_base (&tempbuf);
   value->length = obstack_object_size (&tempbuf);
 
   *outptr = tokptr;
@@ -2258,7 +2201,7 @@ parse_string_or_char (const char *tokptr, const char **outptr,
 
 /* This is used to associate some attributes with a token.  */
 
-enum token_flags
+enum token_flag
 {
   /* If this bit is set, the token is C++-only.  */
 
@@ -2270,13 +2213,14 @@ enum token_flags
 
   FLAG_SHADOW = 2
 };
+DEF_ENUM_FLAGS_TYPE (enum token_flag, token_flags);
 
 struct token
 {
-  char *operator;
+  char *oper;
   int token;
   enum exp_opcode opcode;
-  enum token_flags flags;
+  token_flags flags;
 };
 
 static const struct token tokentab3[] =
@@ -2400,7 +2344,8 @@ scan_macro_expansion (char *expansion)
 
   /* Copy to the obstack, and then free the intermediate
      expansion.  */
-  copy = obstack_copy0 (&expansion_obstack, expansion, strlen (expansion));
+  copy = (char *) obstack_copy0 (&expansion_obstack, expansion,
+                                strlen (expansion));
   xfree (expansion);
 
   /* Save the old lexptr value, so we can return to it when we're done
@@ -2409,15 +2354,13 @@ scan_macro_expansion (char *expansion)
   lexptr = copy;
 }
 
-
 static int
 scanning_macro_expansion (void)
 {
   return macro_original_text != 0;
 }
 
-
-static void 
+static void
 finished_macro_expansion (void)
 {
   /* There'd better be something to pop back to.  */
@@ -2428,7 +2371,6 @@ finished_macro_expansion (void)
   macro_original_text = 0;
 }
 
-
 static void
 scan_macro_cleanup (void *dummy)
 {
@@ -2495,7 +2437,7 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name)
   tokstart = 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].operator, 3) == 0)
+    if (strncmp (tokstart, tokentab3[i].oper, 3) == 0)
       {
        if ((tokentab3[i].flags & FLAG_CXX) != 0
            && parse_language (par_state)->la_language != language_cplus)
@@ -2508,7 +2450,7 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name)
 
   /* 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].operator, 2) == 0)
+    if (strncmp (tokstart, tokentab2[i].oper, 2) == 0)
       {
        if ((tokentab2[i].flags & FLAG_CXX) != 0
            && parse_language (par_state)->la_language != language_cplus)
@@ -2755,7 +2697,6 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name)
                 that we look ahead only when the '<' adjoins non-whitespace
                 characters; for comparison expressions, e.g. "a < b > c",
                 there must be spaces before the '<', etc. */
-               
              const char *p = find_template_name_end (tokstart + namelen);
 
              if (p)
@@ -2806,7 +2747,7 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name)
   /* Catch specific keywords.  */
   copy = copy_name (yylval.sval);
   for (i = 0; i < sizeof ident_tokens / sizeof ident_tokens[0]; i++)
-    if (strcmp (copy, ident_tokens[i].operator) == 0)
+    if (strcmp (copy, ident_tokens[i].oper) == 0)
       {
        if ((ident_tokens[i].flags & FLAG_CXX) != 0
            && parse_language (par_state)->la_language != language_cplus)
@@ -2820,7 +2761,7 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name)
                               VAR_DOMAIN,
                               (parse_language (par_state)->la_language
                                == language_cplus ? &is_a_field_of_this
-                               : NULL))
+                               : NULL)).symbol
                != NULL)
              {
                /* The keyword is shadowed.  */
@@ -2841,7 +2782,8 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name)
     saw_name_at_eof = 1;
 
   yylval.ssym.stoken = yylval.sval;
-  yylval.ssym.sym = NULL;
+  yylval.ssym.sym.symbol = NULL;
+  yylval.ssym.sym.block = NULL;
   yylval.ssym.is_a_field_of_this = 0;
   return NAME;
 }
@@ -2871,11 +2813,12 @@ static struct obstack name_obstack;
    in which lookups start; this can be NULL to mean the global scope.
    IS_QUOTED_NAME is non-zero if the name token was originally quoted
    in single quotes.  */
+
 static int
 classify_name (struct parser_state *par_state, const struct block *block,
               int is_quoted_name)
 {
-  struct symbol *sym;
+  struct block_symbol bsym;
   char *copy;
   struct field_of_this_result is_a_field_of_this;
 
@@ -2885,17 +2828,17 @@ classify_name (struct parser_state *par_state, const struct block *block,
      we can refer to it unconditionally below.  */
   memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
 
-  sym = lookup_symbol (copy, block, VAR_DOMAIN, 
-                      parse_language (par_state)->la_name_of_this
-                      ? &is_a_field_of_this : NULL);
+  bsym = lookup_symbol (copy, block, VAR_DOMAIN,
+                       parse_language (par_state)->la_name_of_this
+                       ? &is_a_field_of_this : NULL);
 
-  if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
+  if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK)
     {
-      yylval.ssym.sym = sym;
+      yylval.ssym.sym = bsym;
       yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
       return BLOCKNAME;
     }
-  else if (!sym)
+  else if (!bsym.symbol)
     {
       /* If we found a field of 'this', we might have erroneously
         found a constructor where we wanted a type name.  Handle this
@@ -2908,11 +2851,11 @@ classify_name (struct parser_state *par_state, const struct block *block,
        {
          struct field_of_this_result inner_is_a_field_of_this;
 
-         sym = lookup_symbol (copy, block, STRUCT_DOMAIN,
-                              &inner_is_a_field_of_this);
-         if (sym != NULL)
+         bsym = lookup_symbol (copy, block, STRUCT_DOMAIN,
+                               &inner_is_a_field_of_this);
+         if (bsym.symbol != NULL)
            {
-             yylval.tsym.type = SYMBOL_TYPE (sym);
+             yylval.tsym.type = SYMBOL_TYPE (bsym.symbol);
              return TYPENAME;
            }
        }
@@ -2929,36 +2872,31 @@ classify_name (struct parser_state *par_state, const struct block *block,
          symtab = lookup_symtab (copy);
          if (symtab)
            {
-             yylval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab),
+             yylval.bval = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab),
                                               STATIC_BLOCK);
              return FILENAME;
            }
        }
     }
 
-  if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+  if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_TYPEDEF)
     {
-      yylval.tsym.type = SYMBOL_TYPE (sym);
+      yylval.tsym.type = SYMBOL_TYPE (bsym.symbol);
       return TYPENAME;
     }
 
-  yylval.tsym.type
-    = language_lookup_primitive_type_by_name (parse_language (par_state),
-                                             parse_gdbarch (par_state),
-                                             copy);
-  if (yylval.tsym.type != NULL)
-    return TYPENAME;
-
   /* See if it's an ObjC classname.  */
-  if (parse_language (par_state)->la_language == language_objc && !sym)
+  if (parse_language (par_state)->la_language == language_objc && !bsym.symbol)
     {
       CORE_ADDR Class = lookup_objc_class (parse_gdbarch (par_state), copy);
       if (Class)
        {
-         yylval.class.class = Class;
+         struct symbol *sym;
+
+         yylval.theclass.theclass = Class;
          sym = lookup_struct_typedef (copy, expression_context_block, 1);
          if (sym)
-           yylval.class.type = SYMBOL_TYPE (sym);
+           yylval.theclass.type = SYMBOL_TYPE (sym);
          return CLASSNAME;
        }
     }
@@ -2966,26 +2904,27 @@ classify_name (struct parser_state *par_state, const struct block *block,
   /* Input names that aren't symbols but ARE valid hex numbers, when
      the input radix permits them, can be names or numbers depending
      on the parse.  Note we support radixes > 16 here.  */
-  if (!sym
+  if (!bsym.symbol
       && ((copy[0] >= 'a' && copy[0] < 'a' + input_radix - 10)
          || (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10)))
     {
       YYSTYPE newlval; /* Its value is ignored.  */
       int hextype = parse_number (par_state, copy, yylval.sval.length,
                                  0, &newlval);
+
       if (hextype == INT)
        {
-         yylval.ssym.sym = sym;
+         yylval.ssym.sym = bsym;
          yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
          return NAME_OR_INT;
        }
     }
 
   /* Any other kind of symbol */
-  yylval.ssym.sym = sym;
+  yylval.ssym.sym = bsym;
   yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
 
-  if (sym == NULL
+  if (bsym.symbol == NULL
       && parse_language (par_state)->la_language == language_cplus
       && is_a_field_of_this.type == NULL
       && lookup_minimal_symbol (copy, NULL, NULL).minsym == NULL)
@@ -3013,14 +2952,15 @@ classify_inner_name (struct parser_state *par_state,
     return ERROR;
 
   copy = copy_name (yylval.ssym.stoken);
-  yylval.ssym.sym = cp_lookup_nested_symbol (type, copy, block);
+  /* N.B. We assume the symbol can only be in VAR_DOMAIN.  */
+  yylval.ssym.sym = cp_lookup_nested_symbol (type, copy, block, VAR_DOMAIN);
 
   /* If no symbol was found, search for a matching base class named
      COPY.  This will allow users to enter qualified names of class members
      relative to the `this' pointer.  */
-  if (yylval.ssym.sym == NULL)
+  if (yylval.ssym.sym.symbol == NULL)
     {
-      struct type *base_type = find_type_baseclass_by_name (type, copy);
+      struct type *base_type = cp_find_type_baseclass_by_name (type, copy);
 
       if (base_type != NULL)
        {
@@ -3031,7 +2971,7 @@ classify_inner_name (struct parser_state *par_state,
       return ERROR;
     }
 
-  switch (SYMBOL_CLASS (yylval.ssym.sym))
+  switch (SYMBOL_CLASS (yylval.ssym.sym.symbol))
     {
     case LOC_BLOCK:
     case LOC_LABEL:
@@ -3039,7 +2979,7 @@ classify_inner_name (struct parser_state *par_state,
         named COPY when we really wanted a base class of the same name.
         Double-check this case by looking for a base class.  */
       {
-       struct type *base_type = find_type_baseclass_by_name (type, copy);
+       struct type *base_type = cp_find_type_baseclass_by_name (type, copy);
 
        if (base_type != NULL)
          {
@@ -3050,7 +2990,7 @@ classify_inner_name (struct parser_state *par_state,
       return ERROR;
 
     case LOC_TYPEDEF:
-      yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym);;
+      yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym.symbol);
       return TYPENAME;
 
     default:
@@ -3065,11 +3005,12 @@ classify_inner_name (struct parser_state *par_state,
    problem in our parsing approach, where the parser could not
    distinguish between qualified names and qualified types at the
    right point.
-   
+
    This approach is still not ideal, because it mishandles template
    types.  See the comment in lex_one_token for an example.  However,
    this is still an improvement over the earlier approach, and will
    suffice until we move to better parsing technology.  */
+
 static int
 yylex (void)
 {
@@ -3176,13 +3117,13 @@ yylex (void)
          obstack_grow (&name_obstack, next->value.sval.ptr,
                        next->value.sval.length);
 
-         yylval.sval.ptr = obstack_base (&name_obstack);
+         yylval.sval.ptr = (const char *) obstack_base (&name_obstack);
          yylval.sval.length = obstack_object_size (&name_obstack);
          current.value = yylval;
          current.token = classification;
 
          last_was_coloncolon = 0;
-         
+
          if (classification == NAME)
            break;
 
@@ -3201,9 +3142,10 @@ yylex (void)
      the FIFO, and delete the other constituent tokens.  */
   if (checkpoint > 0)
     {
-      current.value.sval.ptr = obstack_copy0 (&expansion_obstack,
-                                             current.value.sval.ptr,
-                                             current.value.sval.length);
+      current.value.sval.ptr
+       = (const char *) obstack_copy0 (&expansion_obstack,
+                                       current.value.sval.ptr,
+                                       current.value.sval.length);
 
       VEC_replace (token_and_value, token_fifo, 0, &current);
       if (checkpoint > 1)
@@ -3275,47 +3217,47 @@ c_print_token (FILE *file, int type, YYSTYPE value)
   switch (type)
     {
     case INT:
-      fprintf (file, "typed_val_int<%s, %s>",
-              TYPE_SAFE_NAME (value.typed_val_int.type),
-              pulongest (value.typed_val_int.val));
+      parser_fprintf (file, "typed_val_int<%s, %s>",
+                     TYPE_SAFE_NAME (value.typed_val_int.type),
+                     pulongest (value.typed_val_int.val));
       break;
 
     case CHAR:
     case STRING:
       {
-       char *copy = alloca (value.tsval.length + 1);
+       char *copy = (char *) alloca (value.tsval.length + 1);
 
        memcpy (copy, value.tsval.ptr, value.tsval.length);
        copy[value.tsval.length] = '\0';
 
-       fprintf (file, "tsval<type=%d, %s>", value.tsval.type, copy);
+       parser_fprintf (file, "tsval<type=%d, %s>", value.tsval.type, copy);
       }
       break;
 
     case NSSTRING:
     case VARIABLE:
-      fprintf (file, "sval<%s>", copy_name (value.sval));
+      parser_fprintf (file, "sval<%s>", copy_name (value.sval));
       break;
 
     case TYPENAME:
-      fprintf (file, "tsym<type=%s, name=%s>",
-              TYPE_SAFE_NAME (value.tsym.type),
-              copy_name (value.tsym.stoken));
+      parser_fprintf (file, "tsym<type=%s, name=%s>",
+                     TYPE_SAFE_NAME (value.tsym.type),
+                     copy_name (value.tsym.stoken));
       break;
 
     case NAME:
     case UNKNOWN_CPP_NAME:
     case NAME_OR_INT:
     case BLOCKNAME:
-      fprintf (file, "ssym<name=%s, sym=%s, field_of_this=%d>",
-              copy_name (value.ssym.stoken),
-              (value.ssym.sym == NULL
-               ? "(null)" : SYMBOL_PRINT_NAME (value.ssym.sym)),
-              value.ssym.is_a_field_of_this);
+      parser_fprintf (file, "ssym<name=%s, sym=%s, field_of_this=%d>",
+                      copy_name (value.ssym.stoken),
+                      (value.ssym.sym.symbol == NULL
+                       ? "(null)" : SYMBOL_PRINT_NAME (value.ssym.sym.symbol)),
+                      value.ssym.is_a_field_of_this);
       break;
 
     case FILENAME:
-      fprintf (file, "bval<%s>", host_address_to_string (value.bval));
+      parser_fprintf (file, "bval<%s>", host_address_to_string (value.bval));
       break;
     }
 }
This page took 0.041719 seconds and 4 git commands to generate.