Allow integer immediate for VFP vmov instructions.
[deliverable/binutils-gdb.git] / gdb / ada-exp.y
index 0a33e10485a6be6cd41ff49b70f840bbc5fc11b0..ac4c341bfe941a0d7d9188469cb8e626b1487ab4 100644 (file)
@@ -1,5 +1,5 @@
 /* YACC parser for Ada expressions, for GDB.
-   Copyright (C) 1986-2016 Free Software Foundation, Inc.
+   Copyright (C) 1986-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -77,7 +77,7 @@ int yyparse (void);
 
 static int yylex (void);
 
-void yyerror (char *);
+void yyerror (const char *);
 
 static void write_int (struct parser_state *, LONGEST, struct type *);
 
@@ -106,10 +106,6 @@ static struct type *type_long (struct parser_state *);
 
 static struct type *type_long_long (struct parser_state *);
 
-static struct type *type_float (struct parser_state *);
-
-static struct type *type_double (struct parser_state *);
-
 static struct type *type_long_double (struct parser_state *);
 
 static struct type *type_char (struct parser_state *);
@@ -128,7 +124,7 @@ static struct type *type_system_address (struct parser_state *);
       struct type *type;
     } typed_val;
     struct {
-      DOUBLEST dval;
+      gdb_byte val[16];
       struct type *type;
     } typed_val_float;
     struct type *tval;
@@ -553,10 +549,10 @@ primary   :       CHARLIT
        ;
 
 primary        :       FLOAT
-                       { write_exp_elt_opcode (pstate, OP_DOUBLE);
+                       { write_exp_elt_opcode (pstate, OP_FLOAT);
                          write_exp_elt_type (pstate, $1.type);
-                         write_exp_elt_dblcst (pstate, $1.dval);
-                         write_exp_elt_opcode (pstate, OP_DOUBLE);
+                         write_exp_elt_floatcst (pstate, $1.val);
+                         write_exp_elt_opcode (pstate, OP_FLOAT);
                        }
        ;
 
@@ -733,10 +729,8 @@ static struct obstack temp_parse_space;
 int
 ada_parse (struct parser_state *par_state)
 {
-  int result;
-  struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
-
   /* Setting up the parser state.  */
+  scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
 
@@ -745,31 +739,25 @@ ada_parse (struct parser_state *par_state)
   obstack_free (&temp_parse_space, NULL);
   obstack_init (&temp_parse_space);
 
-  result = yyparse ();
-  do_cleanups (c);
-  return result;
+  return yyparse ();
 }
 
 void
-yyerror (char *msg)
+yyerror (const char *msg)
 {
   error (_("Error in expression, near `%s'."), lexptr);
 }
 
 /* Emit expression to access an instance of SYM, in block BLOCK (if
- * non-NULL), and with :: qualification ORIG_LEFT_CONTEXT.  */
+   non-NULL).  */
+
 static void
 write_var_from_sym (struct parser_state *par_state,
-                   const struct block *orig_left_context,
                    const struct block *block,
                    struct symbol *sym)
 {
-  if (orig_left_context == NULL && symbol_read_needs_frame (sym))
-    {
-      if (innermost_block == 0
-         || contained_in (block, innermost_block))
-       innermost_block = block;
-    }
+  if (symbol_read_needs_frame (sym))
+    innermost_block.update (block, INNERMOST_BLOCK_FOR_SYMBOLS);
 
   write_exp_elt_opcode (par_state, OP_VAR_VALUE);
   write_exp_elt_block (par_state, block);
@@ -845,8 +833,7 @@ write_object_renaming (struct parser_state *par_state,
                                &inner_renaming_expr))
       {
       case ADA_NOT_RENAMING:
-       write_var_from_sym (par_state, orig_left_context, sym_info.block,
-                           sym_info.symbol);
+       write_var_from_sym (par_state, sym_info.block, sym_info.symbol);
        break;
       case ADA_OBJECT_RENAMING:
        write_object_renaming (par_state, sym_info.block,
@@ -900,14 +887,14 @@ write_object_renaming (struct parser_state *par_state,
                                        end - renaming_expr);
            renaming_expr = end;
 
-           ada_lookup_encoded_symbol (index_name, NULL, VAR_DOMAIN,
-                                      &index_sym_info);
+           ada_lookup_encoded_symbol (index_name, orig_left_context,
+                                      VAR_DOMAIN, &index_sym_info);
            if (index_sym_info.symbol == NULL)
              error (_("Could not find %s"), index_name);
            else if (SYMBOL_CLASS (index_sym_info.symbol) == LOC_TYPEDEF)
              /* Index is an old-style renaming symbol.  */
              index_sym_info.block = orig_left_context;
-           write_var_from_sym (par_state, NULL, index_sym_info.block,
+           write_var_from_sym (par_state, index_sym_info.block,
                                index_sym_info.symbol);
          }
        if (slice_state == SIMPLE_INDEX)
@@ -966,6 +953,8 @@ block_lookup (const struct block *context, const char *raw_name)
   struct block_symbol *syms;
   int nsyms;
   struct symtab *symtab;
+  struct cleanup *old_chain;
+  const struct block *result = NULL;
 
   if (raw_name[0] == '\'')
     {
@@ -976,6 +965,8 @@ block_lookup (const struct block *context, const char *raw_name)
     name = ada_encode (raw_name);
 
   nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms);
+  old_chain = make_cleanup (xfree, syms);
+
   if (context == NULL
       && (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK))
     symtab = lookup_symtab (name);
@@ -983,7 +974,7 @@ block_lookup (const struct block *context, const char *raw_name)
     symtab = NULL;
 
   if (symtab != NULL)
-    return BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), STATIC_BLOCK);
+    result = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), STATIC_BLOCK);
   else if (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK)
     {
       if (context == NULL)
@@ -995,8 +986,11 @@ block_lookup (const struct block *context, const char *raw_name)
     {
       if (nsyms > 1)
        warning (_("Function name \"%s\" ambiguous here"), raw_name);
-      return SYMBOL_BLOCK_VALUE (syms[0].symbol);
+      result = SYMBOL_BLOCK_VALUE (syms[0].symbol);
     }
+
+  do_cleanups (old_chain);
+  return result;
 }
 
 static struct symbol*
@@ -1210,6 +1204,7 @@ write_var_or_type (struct parser_state *par_state,
   int depth;
   char *encoded_name;
   int name_len;
+  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
 
   if (block == NULL)
     block = expression_context_block;
@@ -1237,6 +1232,7 @@ write_var_or_type (struct parser_state *par_state,
          encoded_name[tail_index] = '\0';
          nsyms = ada_lookup_symbol_list (encoded_name, block,
                                          VAR_DOMAIN, &syms);
+          make_cleanup (xfree, syms);
          encoded_name[tail_index] = terminator;
 
          /* A single symbol may rename a package or object. */
@@ -1283,6 +1279,7 @@ write_var_or_type (struct parser_state *par_state,
              write_object_renaming (par_state, block, renaming, renaming_len,
                                     renaming_expr, MAX_RENAMING_CHAIN_LENGTH);
              write_selectors (par_state, encoded_name + tail_index);
+              do_cleanups (old_chain);
              return NULL;
            default:
              internal_error (__FILE__, __LINE__,
@@ -1294,7 +1291,10 @@ write_var_or_type (struct parser_state *par_state,
               struct type *field_type;
               
               if (tail_index == name_len)
-                return SYMBOL_TYPE (type_sym);
+                {
+                  do_cleanups (old_chain);
+                 return SYMBOL_TYPE (type_sym);
+                }
 
               /* We have some extraneous characters after the type name.
                  If this is an expression "TYPE_NAME.FIELD0.[...].FIELDN",
@@ -1302,7 +1302,10 @@ write_var_or_type (struct parser_state *par_state,
               field_type
                 = get_symbol_field_type (type_sym, encoded_name + tail_index);
               if (field_type != NULL)
-                return field_type;
+               {
+                 do_cleanups (old_chain);
+                 return field_type;
+               }
              else 
                error (_("Invalid attempt to select from type: \"%s\"."),
                        name0.ptr);
@@ -1313,14 +1316,17 @@ write_var_or_type (struct parser_state *par_state,
                                                       encoded_name);
 
              if (type != NULL)
-               return type;
+               {
+                 do_cleanups (old_chain);
+                 return type;
+               }
            }
 
          if (nsyms == 1)
            {
-             write_var_from_sym (par_state, block, syms[0].block,
-                                 syms[0].symbol);
+             write_var_from_sym (par_state, syms[0].block, syms[0].symbol);
              write_selectors (par_state, encoded_name + tail_index);
+             do_cleanups (old_chain);
              return NULL;
            }
          else if (nsyms == 0) 
@@ -1332,6 +1338,7 @@ write_var_or_type (struct parser_state *par_state,
                  write_exp_msymbol (par_state, msym);
                  /* Maybe cause error here rather than later? FIXME? */
                  write_selectors (par_state, encoded_name + tail_index);
+                 do_cleanups (old_chain);
                  return NULL;
                }
 
@@ -1347,6 +1354,7 @@ write_var_or_type (struct parser_state *par_state,
              write_ambiguous_var (par_state, block, encoded_name,
                                   tail_index);
              write_selectors (par_state, encoded_name + tail_index);
+             do_cleanups (old_chain);
              return NULL;
            }
        }
@@ -1388,11 +1396,14 @@ write_name_assoc (struct parser_state *par_state, struct stoken name)
       struct block_symbol *syms;
       int nsyms = ada_lookup_symbol_list (name.ptr, expression_context_block,
                                          VAR_DOMAIN, &syms);
+      struct cleanup *old_chain = make_cleanup (xfree, syms);
 
       if (nsyms != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
        write_exp_op_with_string (par_state, OP_NAME, name);
       else
-       write_var_from_sym (par_state, NULL, syms[0].block, syms[0].symbol);
+       write_var_from_sym (par_state, syms[0].block, syms[0].symbol);
+
+      do_cleanups (old_chain);
     }
   else
     if (write_var_or_type (par_state, NULL, name) != NULL)
@@ -1443,18 +1454,6 @@ type_long_long (struct parser_state *par_state)
   return parse_type (par_state)->builtin_long_long;
 }
 
-static struct type *
-type_float (struct parser_state *par_state)
-{
-  return parse_type (par_state)->builtin_float;
-}
-
-static struct type *
-type_double (struct parser_state *par_state)
-{
-  return parse_type (par_state)->builtin_double;
-}
-
 static struct type *
 type_long_double (struct parser_state *par_state)
 {
@@ -1484,9 +1483,6 @@ type_system_address (struct parser_state *par_state)
   return  type != NULL ? type : parse_type (par_state)->builtin_data_ptr;
 }
 
-/* Provide a prototype to silence -Wmissing-prototypes.  */
-extern initialize_file_ftype _initialize_ada_exp;
-
 void
 _initialize_ada_exp (void)
 {
This page took 0.030483 seconds and 4 git commands to generate.