Remove stale -DNO_PROTOTYPES bits from gdb testsuite
[deliverable/binutils-gdb.git] / gdb / ada-lang.c
index 6bfc0256b66700d514ccbb9d4f7f0df1ea8c7d00..98508c168bc127d2c22dde4c6cb326da4ce6dfa4 100644 (file)
@@ -488,23 +488,6 @@ add_angle_brackets (const char *str)
   return string_printf ("<%s>", str);
 }
 
-static const char *
-ada_get_gdb_completer_word_break_characters (void)
-{
-  return ada_completer_word_break_characters;
-}
-
-/* la_watch_location_expression for Ada.  */
-
-static gdb::unique_xmalloc_ptr<char>
-ada_watch_location_expression (struct type *type, CORE_ADDR addr)
-{
-  type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
-  std::string name = type_to_string (type);
-  return gdb::unique_xmalloc_ptr<char>
-    (xstrprintf ("{%s} %s", name.c_str (), core_addr_to_string (addr)));
-}
-
 /* Assuming V points to an array of S objects,  make sure that it contains at
    least M objects, updating V and S as necessary.  */
 
@@ -865,18 +848,11 @@ ada_main_name (void)
 
   if (msym.minsym != NULL)
     {
-      CORE_ADDR main_program_name_addr;
-      int err_code;
-
-      main_program_name_addr = BMSYMBOL_VALUE_ADDRESS (msym);
+      CORE_ADDR main_program_name_addr = BMSYMBOL_VALUE_ADDRESS (msym);
       if (main_program_name_addr == 0)
         error (_("Invalid address for Ada main program name."));
 
-      target_read_string (main_program_name_addr, &main_program_name,
-                          1024, &err_code);
-
-      if (err_code != 0)
-        return NULL;
+      main_program_name = target_read_string (main_program_name_addr, 1024);
       return main_program_name.get ();
     }
 
@@ -1420,8 +1396,8 @@ ada_fixup_array_indexes_type (struct type *index_desc_type)
      If our INDEX_DESC_TYPE was generated using the older encoding,
      the field type should be a meaningless integer type whose name
      is not equal to the field name.  */
-  if (TYPE_FIELD_TYPE (index_desc_type, 0)->name () != NULL
-      && strcmp (TYPE_FIELD_TYPE (index_desc_type, 0)->name (),
+  if (index_desc_type->field (0).type ()->name () != NULL
+      && strcmp (index_desc_type->field (0).type ()->name (),
                  TYPE_FIELD_NAME (index_desc_type, 0)) == 0)
     return;
 
@@ -1432,7 +1408,7 @@ ada_fixup_array_indexes_type (struct type *index_desc_type)
      struct type *raw_type = ada_check_typedef (ada_find_any_type (name));
 
      if (raw_type)
-       TYPE_FIELD_TYPE (index_desc_type, i) = raw_type;
+       index_desc_type->field (i).set_type (raw_type);
    }
 }
 
@@ -1622,7 +1598,7 @@ fat_pntr_bounds_bitsize (struct type *type)
   if (TYPE_FIELD_BITSIZE (type, 1) > 0)
     return TYPE_FIELD_BITSIZE (type, 1);
   else
-    return 8 * TYPE_LENGTH (ada_check_typedef (TYPE_FIELD_TYPE (type, 1)));
+    return 8 * TYPE_LENGTH (ada_check_typedef (type->field (1).type ()));
 }
 
 /* If TYPE is the type of an array descriptor (fat or thin pointer) or a
@@ -1637,7 +1613,7 @@ desc_data_target_type (struct type *type)
 
   /* NOTE: The following is bogus; see comment in desc_bounds.  */
   if (is_thin_pntr (type))
-    return desc_base_type (TYPE_FIELD_TYPE (thin_descriptor_type (type), 1));
+    return desc_base_type (thin_descriptor_type (type)->field (1).type ());
   else if (is_thick_pntr (type))
     {
       struct type *data_type = lookup_struct_elt_type (type, "P_ARRAY", 1);
@@ -1688,7 +1664,7 @@ fat_pntr_data_bitsize (struct type *type)
   if (TYPE_FIELD_BITSIZE (type, 0) > 0)
     return TYPE_FIELD_BITSIZE (type, 0);
   else
-    return TARGET_CHAR_BIT * TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
+    return TARGET_CHAR_BIT * TYPE_LENGTH (type->field (0).type ());
 }
 
 /* If BOUNDS is an array-bounds structure (or pointer to one), return
@@ -1727,7 +1703,7 @@ desc_bound_bitsize (struct type *type, int i, int which)
   if (TYPE_FIELD_BITSIZE (type, 2 * i + which - 2) > 0)
     return TYPE_FIELD_BITSIZE (type, 2 * i + which - 2);
   else
-    return 8 * TYPE_LENGTH (TYPE_FIELD_TYPE (type, 2 * i + which - 2));
+    return 8 * TYPE_LENGTH (type->field (2 * i + which - 2).type ());
 }
 
 /* If TYPE is the type of an array-bounds structure, the type of its
@@ -2078,10 +2054,10 @@ constrained_packed_array_type (struct type *type, long *elt_bits)
 
   index_type_desc = ada_find_parallel_type (type, "___XA");
   if (index_type_desc)
-    index_type = to_fixed_range_type (TYPE_FIELD_TYPE (index_type_desc, 0),
+    index_type = to_fixed_range_type (index_type_desc->field (0).type (),
                                      NULL);
   else
-    index_type = TYPE_INDEX_TYPE (type);
+    index_type = type->index_type ();
 
   new_type = alloc_type_copy (type);
   new_elt_type =
@@ -2235,7 +2211,7 @@ value_subscript_packed (struct value *arr, int arity, struct value **ind)
             "something other than a packed array"));
       else
         {
-          struct type *range_type = TYPE_INDEX_TYPE (elt_type);
+          struct type *range_type = elt_type->index_type ();
           LONGEST lowerbound, upperbound;
           LONGEST idx;
 
@@ -2730,7 +2706,7 @@ ada_value_ptr_subscript (struct value *arr, int arity, struct value **ind)
         error (_("too many subscripts (%d expected)"), k);
       arr = value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
                         value_copy (arr));
-      get_discrete_bounds (TYPE_INDEX_TYPE (type), &lwb, &upb);
+      get_discrete_bounds (type->index_type (), &lwb, &upb);
       arr = value_ptradd (arr, pos_atr (ind[k]) - lwb);
       type = TYPE_TARGET_TYPE (type);
     }
@@ -2747,14 +2723,14 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
                           int low, int high)
 {
   struct type *type0 = ada_check_typedef (type);
-  struct type *base_index_type = TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type0));
+  struct type *base_index_type = TYPE_TARGET_TYPE (type0->index_type ());
   struct type *index_type
     = create_static_range_type (NULL, base_index_type, low, high);
   struct type *slice_type = create_array_type_with_stride
                              (NULL, TYPE_TARGET_TYPE (type0), index_type,
                               type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
                               TYPE_FIELD_BITSIZE (type0, 0));
-  int base_low =  ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type0));
+  int base_low =  ada_discrete_type_low_bound (type0->index_type ());
   LONGEST base_low_pos, low_pos;
   CORE_ADDR base;
 
@@ -2777,9 +2753,9 @@ static struct value *
 ada_value_slice (struct value *array, int low, int high)
 {
   struct type *type = ada_check_typedef (value_type (array));
-  struct type *base_index_type = TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type));
+  struct type *base_index_type = TYPE_TARGET_TYPE (type->index_type ());
   struct type *index_type
-    = create_static_range_type (NULL, TYPE_INDEX_TYPE (type), low, high);
+    = create_static_range_type (NULL, type->index_type (), low, high);
   struct type *slice_type = create_array_type_with_stride
                              (NULL, TYPE_TARGET_TYPE (type), index_type,
                               type->dyn_prop (DYN_PROP_BYTE_STRIDE),
@@ -2892,7 +2868,7 @@ ada_index_type (struct type *type, int n, const char *name)
 
       for (i = 1; i < n; i += 1)
         type = TYPE_TARGET_TYPE (type);
-      result_type = TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type));
+      result_type = TYPE_TARGET_TYPE (type->index_type ());
       /* FIXME: The stabs type r(0,0);bound;bound in an array type
          has a target type of TYPE_CODE_UNDEF.  We compensate here, but
          perhaps stabsread.c would make more sense.  */
@@ -2948,7 +2924,7 @@ ada_array_bound_from_type (struct type *arr_type, int n, int which)
     }
 
   if (index_type_desc != NULL)
-    index_type = to_fixed_range_type (TYPE_FIELD_TYPE (index_type_desc, n - 1),
+    index_type = to_fixed_range_type (index_type_desc->field (n - 1).type (),
                                      NULL);
   else
     {
@@ -2957,7 +2933,7 @@ ada_array_bound_from_type (struct type *arr_type, int n, int which)
       for (i = 1; i < n; i++)
        elt_type = check_typedef (TYPE_TARGET_TYPE (elt_type));
 
-      index_type = TYPE_INDEX_TYPE (elt_type);
+      index_type = elt_type->index_type ();
     }
 
   return
@@ -3044,7 +3020,7 @@ empty_array (struct type *arr_type, int low, int high)
   struct type *arr_type0 = ada_check_typedef (arr_type);
   struct type *index_type
     = create_static_range_type
-        (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (arr_type0)), low,
+        (NULL, TYPE_TARGET_TYPE (arr_type0->index_type ()), low,
         high < low ? low - 1 : high);
   struct type *elt_type = ada_array_element_type (arr_type0, 1);
 
@@ -3163,7 +3139,7 @@ ada_print_symbol_signature (struct ui_file *stream, struct symbol *sym,
        {
          if (i > 0)
            fprintf_filtered (stream, "; ");
-         ada_print_type (TYPE_FIELD_TYPE (type, i), NULL, stream, -1, 0,
+         ada_print_type (type->field (i).type (), NULL, stream, -1, 0,
                          flags);
        }
       fprintf_filtered (stream, ")");
@@ -3384,28 +3360,6 @@ See set/show multiple-symbol."));
   return n_chosen;
 }
 
-/* Same as evaluate_type (*EXP), but resolves ambiguous symbol
-   references (marked by OP_VAR_VALUE nodes in which the symbol has an
-   undefined namespace) and converts operators that are
-   user-defined into appropriate function calls.  If CONTEXT_TYPE is
-   non-null, it provides a preferred result type [at the moment, only
-   type void has any effect---causing procedures to be preferred over
-   functions in calls].  A null CONTEXT_TYPE indicates that a non-void
-   return type is preferred.  May change (expand) *EXP.  */
-
-static void
-resolve (expression_up *expp, int void_context_p, int parse_completion,
-        innermost_block_tracker *tracker)
-{
-  struct type *context_type = NULL;
-  int pc = 0;
-
-  if (void_context_p)
-    context_type = builtin_type ((*expp)->gdbarch)->builtin_void;
-
-  resolve_subexp (expp, &pc, 1, context_type, parse_completion, tracker);
-}
-
 /* Resolve the operator of the subexpression beginning at
    position *POS of *EXPP.  "Resolving" consists of replacing
    the symbols that have undefined namespaces in OP_VAR_VALUE nodes
@@ -3854,8 +3808,7 @@ ada_args_match (struct symbol *func, struct value **actuals, int n_actuals)
         return 0;
       else
         {
-          struct type *ftype = ada_check_typedef (TYPE_FIELD_TYPE (func_type,
-                                                                  i));
+          struct type *ftype = ada_check_typedef (func_type->field (i).type ());
           struct type *atype = ada_check_typedef (value_type (actuals[i]));
 
           if (!ada_type_match (ftype, atype, 1))
@@ -4505,14 +4458,14 @@ make_array_descriptor (struct type *type, struct value *arr)
   modify_field (value_type (descriptor),
                value_contents_writeable (descriptor),
                value_pointer (ensure_lval (arr),
-                              TYPE_FIELD_TYPE (desc_type, 0)),
+                              desc_type->field (0).type ()),
                fat_pntr_data_bitpos (desc_type),
                fat_pntr_data_bitsize (desc_type));
 
   modify_field (value_type (descriptor),
                value_contents_writeable (descriptor),
                value_pointer (bounds,
-                              TYPE_FIELD_TYPE (desc_type, 1)),
+                              desc_type->field (1).type ()),
                fat_pntr_bounds_bitpos (desc_type),
                fat_pntr_bounds_bitsize (desc_type));
 
@@ -5789,46 +5742,6 @@ ada_lookup_symbol (const char *name, const struct block *block0,
   return info;
 }
 
-static struct block_symbol
-ada_lookup_symbol_nonlocal (const struct language_defn *langdef,
-                           const char *name,
-                            const struct block *block,
-                            const domain_enum domain)
-{
-  struct block_symbol sym;
-
-  sym = ada_lookup_symbol (name, block_static_block (block), domain);
-  if (sym.symbol != NULL)
-    return sym;
-
-  /* If we haven't found a match at this point, try the primitive
-     types.  In other languages, this search is performed before
-     searching for global symbols in order to short-circuit that
-     global-symbol search if it happens that the name corresponds
-     to a primitive type.  But we cannot do the same in Ada, because
-     it is perfectly legitimate for a program to declare a type which
-     has the same name as a standard type.  If looking up a type in
-     that situation, we have traditionally ignored the primitive type
-     in favor of user-defined types.  This is why, unlike most other
-     languages, we search the primitive types this late and only after
-     having searched the global symbols without success.  */
-
-  if (domain == VAR_DOMAIN)
-    {
-      struct gdbarch *gdbarch;
-
-      if (block == NULL)
-       gdbarch = target_gdbarch ();
-      else
-       gdbarch = block_gdbarch (block);
-      sym.symbol = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name);
-      if (sym.symbol != NULL)
-       return sym;
-    }
-
-  return {};
-}
-
 
 /* True iff STR is a possible encoded suffix of a normal Ada name
    that is to be ignored for matching purposes.  Suffixes of parallel
@@ -6286,134 +6199,6 @@ ada_lookup_name_info::matches
   return true;
 }
 
-/* Add the list of possible symbol names completing TEXT to TRACKER.
-   WORD is the entire command on which completion is made.  */
-
-static void
-ada_collect_symbol_completion_matches (completion_tracker &tracker,
-                                      complete_symbol_mode mode,
-                                      symbol_name_match_type name_match_type,
-                                      const char *text, const char *word,
-                                      enum type_code code)
-{
-  struct symbol *sym;
-  const struct block *b, *surrounding_static_block = 0;
-  struct block_iterator iter;
-
-  gdb_assert (code == TYPE_CODE_UNDEF);
-
-  lookup_name_info lookup_name (text, name_match_type, true);
-
-  /* First, look at the partial symtab symbols.  */
-  expand_symtabs_matching (NULL,
-                          lookup_name,
-                          NULL,
-                          NULL,
-                          ALL_DOMAIN);
-
-  /* At this point scan through the misc symbol vectors and add each
-     symbol you find to the list.  Eventually we want to ignore
-     anything that isn't a text symbol (everything else will be
-     handled by the psymtab code above).  */
-
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      for (minimal_symbol *msymbol : objfile->msymbols ())
-       {
-         QUIT;
-
-         if (completion_skip_symbol (mode, msymbol))
-           continue;
-
-         language symbol_language = msymbol->language ();
-
-         /* Ada minimal symbols won't have their language set to Ada.  If
-            we let completion_list_add_name compare using the
-            default/C-like matcher, then when completing e.g., symbols in a
-            package named "pck", we'd match internal Ada symbols like
-            "pckS", which are invalid in an Ada expression, unless you wrap
-            them in '<' '>' to request a verbatim match.
-
-            Unfortunately, some Ada encoded names successfully demangle as
-            C++ symbols (using an old mangling scheme), such as "name__2Xn"
-            -> "Xn::name(void)" and thus some Ada minimal symbols end up
-            with the wrong language set.  Paper over that issue here.  */
-         if (symbol_language == language_auto
-             || symbol_language == language_cplus)
-           symbol_language = language_ada;
-
-         completion_list_add_name (tracker,
-                                   symbol_language,
-                                   msymbol->linkage_name (),
-                                   lookup_name, text, word);
-       }
-    }
-
-  /* Search upwards from currently selected frame (so that we can
-     complete on local vars.  */
-
-  for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
-    {
-      if (!BLOCK_SUPERBLOCK (b))
-        surrounding_static_block = b;   /* For elmin of dups */
-
-      ALL_BLOCK_SYMBOLS (b, iter, sym)
-      {
-       if (completion_skip_symbol (mode, sym))
-         continue;
-
-       completion_list_add_name (tracker,
-                                 sym->language (),
-                                 sym->linkage_name (),
-                                 lookup_name, text, word);
-      }
-    }
-
-  /* Go through the symtabs and check the externs and statics for
-     symbols which match.  */
-
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      for (compunit_symtab *s : objfile->compunits ())
-       {
-         QUIT;
-         b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
-         ALL_BLOCK_SYMBOLS (b, iter, sym)
-           {
-             if (completion_skip_symbol (mode, sym))
-               continue;
-
-             completion_list_add_name (tracker,
-                                       sym->language (),
-                                       sym->linkage_name (),
-                                       lookup_name, text, word);
-           }
-       }
-    }
-
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      for (compunit_symtab *s : objfile->compunits ())
-       {
-         QUIT;
-         b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
-         /* Don't do this block twice.  */
-         if (b == surrounding_static_block)
-           continue;
-         ALL_BLOCK_SYMBOLS (b, iter, sym)
-           {
-             if (completion_skip_symbol (mode, sym))
-               continue;
-
-             completion_list_add_name (tracker,
-                                       sym->language (),
-                                       sym->linkage_name (),
-                                       lookup_name, text, word);
-           }
-       }
-    }
-}
-
                                 /* Field Access */
 
 /* Return non-zero if TYPE is a pointer to the GNAT dispatch table used
@@ -6480,8 +6265,8 @@ ada_is_ignored_field (struct type *type, int field_num)
   /* If this is the dispatch table of a tagged type or an interface tag,
      then ignore.  */
   if (ada_is_tagged_type (type, 1)
-      && (ada_is_dispatch_table_ptr_type (TYPE_FIELD_TYPE (type, field_num))
-         || ada_is_interface_tag (TYPE_FIELD_TYPE (type, field_num))))
+      && (ada_is_dispatch_table_ptr_type (type->field (field_num).type ())
+         || ada_is_interface_tag (type->field (field_num).type ())))
     return 1;
 
   /* Not a special field, so it should not be ignored.  */
@@ -6568,10 +6353,10 @@ value_tag_from_contents_and_address (struct type *type,
 static struct type *
 type_from_tag (struct value *tag)
 {
-  const char *type_name = ada_tag_name (tag);
+  gdb::unique_xmalloc_ptr<char> type_name = ada_tag_name (tag);
 
   if (type_name != NULL)
-    return ada_find_any_type (ada_encode (type_name));
+    return ada_find_any_type (ada_encode (type_name.get ()));
   return NULL;
 }
 
@@ -6719,37 +6504,41 @@ ada_get_tsd_from_tag (struct value *tag)
 /* Given the TSD of a tag (type-specific data), return a string
    containing the name of the associated type.
 
-   The returned value is good until the next call.  May return NULL
-   if we are unable to determine the tag name.  */
+   May return NULL if we are unable to determine the tag name.  */
 
-static char *
+static gdb::unique_xmalloc_ptr<char>
 ada_tag_name_from_tsd (struct value *tsd)
 {
-  static char name[1024];
   char *p;
   struct value *val;
 
   val = ada_value_struct_elt (tsd, "expanded_name", 1);
   if (val == NULL)
     return NULL;
-  read_memory_string (value_as_address (val), name, sizeof (name) - 1);
-  for (p = name; *p != '\0'; p += 1)
-    if (isalpha (*p))
-      *p = tolower (*p);
-  return name;
+  gdb::unique_xmalloc_ptr<char> buffer
+    = target_read_string (value_as_address (val), INT_MAX);
+  if (buffer == nullptr)
+    return nullptr;
+
+  for (p = buffer.get (); *p != '\0'; ++p)
+    {
+      if (isalpha (*p))
+       *p = tolower (*p);
+    }
+
+  return buffer;
 }
 
 /* The type name of the dynamic type denoted by the 'tag value TAG, as
    a C string.
 
    Return NULL if the TAG is not an Ada tag, or if we were unable to
-   determine the name of that tag.  The result is good until the next
-   call.  */
+   determine the name of that tag.  */
 
-const char *
+gdb::unique_xmalloc_ptr<char>
 ada_tag_name (struct value *tag)
 {
-  char *name = NULL;
+  gdb::unique_xmalloc_ptr<char> name;
 
   if (!ada_is_tag_type (value_type (tag)))
     return NULL;
@@ -6792,7 +6581,7 @@ ada_parent_type (struct type *type)
   for (i = 0; i < type->num_fields (); i += 1)
     if (ada_is_parent_field (type, i))
       {
-        struct type *parent_type = TYPE_FIELD_TYPE (type, i);
+        struct type *parent_type = type->field (i).type ();
 
         /* If the _parent field is a pointer, then dereference it.  */
         if (parent_type->code () == TYPE_CODE_PTR)
@@ -6860,7 +6649,7 @@ ada_is_variant_part (struct type *type, int field_num)
   if (!ADA_TYPE_P (type))
     return 0;
 
-  struct type *field_type = TYPE_FIELD_TYPE (type, field_num);
+  struct type *field_type = type->field (field_num).type ();
 
   return (field_type->code () == TYPE_CODE_UNION
          || (is_dynamic_field (type, field_num)
@@ -7049,7 +6838,7 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno,
   struct type *type;
 
   arg_type = ada_check_typedef (arg_type);
-  type = TYPE_FIELD_TYPE (arg_type, fieldno);
+  type = arg_type->field (fieldno).type ();
 
   /* Handle packed fields.  It might be that the field is not packed
      relative to its containing structure, but the structure itself is
@@ -7180,7 +6969,7 @@ find_struct_field (const char *name, struct type *type, int offset,
           int bit_size = TYPE_FIELD_BITSIZE (type, i);
 
          if (field_type_p != NULL)
-           *field_type_p = TYPE_FIELD_TYPE (type, i);
+           *field_type_p = type->field (i).type ();
          if (byte_offset_p != NULL)
            *byte_offset_p = fld_offset;
          if (bit_offset_p != NULL)
@@ -7191,7 +6980,7 @@ find_struct_field (const char *name, struct type *type, int offset,
         }
       else if (ada_is_wrapper_field (type, i))
         {
-         if (find_struct_field (name, TYPE_FIELD_TYPE (type, i), fld_offset,
+         if (find_struct_field (name, type->field (i).type (), fld_offset,
                                 field_type_p, byte_offset_p, bit_offset_p,
                                 bit_size_p, index_p))
             return 1;
@@ -7202,11 +6991,11 @@ find_struct_field (const char *name, struct type *type, int offset,
             fixed type?? */
           int j;
           struct type *field_type
-           = ada_check_typedef (TYPE_FIELD_TYPE (type, i));
+           = ada_check_typedef (type->field (i).type ());
 
           for (j = 0; j < field_type->num_fields (); j += 1)
             {
-              if (find_struct_field (name, TYPE_FIELD_TYPE (field_type, j),
+              if (find_struct_field (name, field_type->field (j).type (),
                                      fld_offset
                                      + TYPE_FIELD_BITPOS (field_type, j) / 8,
                                      field_type_p, byte_offset_p,
@@ -7226,7 +7015,7 @@ find_struct_field (const char *name, struct type *type, int offset,
       int bit_pos = TYPE_FIELD_BITPOS (type, parent_offset);
       int fld_offset = offset + bit_pos / 8;
 
-      if (find_struct_field (name, TYPE_FIELD_TYPE (type, parent_offset),
+      if (find_struct_field (name, type->field (parent_offset).type (),
                              fld_offset, field_type_p, byte_offset_p,
                              bit_offset_p, bit_size_p, index_p))
         return 1;
@@ -7293,7 +7082,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
           struct value *v =     /* Do not let indent join lines here.  */
             ada_search_struct_field (name, arg,
                                      offset + TYPE_FIELD_BITPOS (type, i) / 8,
-                                     TYPE_FIELD_TYPE (type, i));
+                                     type->field (i).type ());
 
           if (v != NULL)
             return v;
@@ -7303,8 +7092,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
         {
          /* PNH: Do we ever get here?  See find_struct_field.  */
           int j;
-          struct type *field_type = ada_check_typedef (TYPE_FIELD_TYPE (type,
-                                                                       i));
+          struct type *field_type = ada_check_typedef (type->field (i).type ());
           int var_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
 
           for (j = 0; j < field_type->num_fields (); j += 1)
@@ -7313,7 +7101,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
                                                           break.  */
                 (name, arg,
                  var_offset + TYPE_FIELD_BITPOS (field_type, j) / 8,
-                 TYPE_FIELD_TYPE (field_type, j));
+                 field_type->field (j).type ());
 
               if (v != NULL)
                 return v;
@@ -7328,7 +7116,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
     {
       struct value *v = ada_search_struct_field (
        name, arg, offset + TYPE_FIELD_BITPOS (type, parent_offset) / 8,
-       TYPE_FIELD_TYPE (type, parent_offset));
+       type->field (parent_offset).type ());
 
       if (v != NULL)
         return v;
@@ -7374,7 +7162,7 @@ ada_index_struct_field_1 (int *index_p, struct value *arg, int offset,
           struct value *v =     /* Do not let indent join lines here.  */
             ada_index_struct_field_1 (index_p, arg,
                                      offset + TYPE_FIELD_BITPOS (type, i) / 8,
-                                     TYPE_FIELD_TYPE (type, i));
+                                     type->field (i).type ());
 
           if (v != NULL)
             return v;
@@ -7481,11 +7269,11 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok,
         }
 
       else if (field_name_match (t_field_name, name))
-       return TYPE_FIELD_TYPE (type, i);
+       return type->field (i).type ();
 
       else if (ada_is_wrapper_field (type, i))
         {
-          t = ada_lookup_struct_elt_type (TYPE_FIELD_TYPE (type, i), name,
+          t = ada_lookup_struct_elt_type (type->field (i).type (), name,
                                           0, 1);
           if (t != NULL)
            return t;
@@ -7494,8 +7282,7 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok,
       else if (ada_is_variant_part (type, i))
         {
           int j;
-          struct type *field_type = ada_check_typedef (TYPE_FIELD_TYPE (type,
-                                                                       i));
+          struct type *field_type = ada_check_typedef (type->field (i).type ());
 
           for (j = field_type->num_fields () - 1; j >= 0; j -= 1)
             {
@@ -7507,10 +7294,9 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok,
 
              if (v_field_name != NULL 
                  && field_name_match (v_field_name, name))
-               t = TYPE_FIELD_TYPE (field_type, j);
+               t = field_type->field (j).type ();
              else
-               t = ada_lookup_struct_elt_type (TYPE_FIELD_TYPE (field_type,
-                                                                j),
+               t = ada_lookup_struct_elt_type (field_type->field (j).type (),
                                                name, 0, 1);
 
               if (t != NULL)
@@ -7527,7 +7313,7 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok,
       {
         struct type *t;
 
-        t = ada_lookup_struct_elt_type (TYPE_FIELD_TYPE (type, parent_offset),
+        t = ada_lookup_struct_elt_type (type->field (parent_offset).type (),
                                         name, 0, 1);
         if (t != NULL)
          return t;
@@ -7916,7 +7702,7 @@ is_dynamic_field (struct type *templ_type, int field_num)
   const char *name = TYPE_FIELD_NAME (templ_type, field_num);
 
   return name != NULL
-    && TYPE_FIELD_TYPE (templ_type, field_num)->code () == TYPE_CODE_PTR
+    && templ_type->field (field_num).type ()->code () == TYPE_CODE_PTR
     && strstr (name, "___XVL") != NULL;
 }
 
@@ -8029,7 +7815,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
          const gdb_byte *field_valaddr = valaddr;
          CORE_ADDR field_address = address;
          struct type *field_type =
-           TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, f));
+           TYPE_TARGET_TYPE (type->field (f).type ());
 
           if (dval0 == NULL)
            {
@@ -8088,7 +7874,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
             record size.  */
          ada_ensure_varsize_limit (field_type);
 
-         TYPE_FIELD_TYPE (rtype, f) = field_type;
+         rtype->field (f).set_type (field_type);
           TYPE_FIELD_NAME (rtype, f) = TYPE_FIELD_NAME (type, f);
          /* The multiplication can potentially overflow.  But because
             the field length has been size-checked just above, and
@@ -8097,7 +7883,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
             adding overflow recovery code to this already complex code,
             we just assume that it's not going to happen.  */
           fld_bit_len =
-            TYPE_LENGTH (TYPE_FIELD_TYPE (rtype, f)) * TARGET_CHAR_BIT;
+            TYPE_LENGTH (rtype->field (f).type ()) * TARGET_CHAR_BIT;
         }
       else
         {
@@ -8111,14 +7897,14 @@ ada_template_to_fixed_record_type_1 (struct type *type,
             structure, the typedef is the only clue which allows us
             to distinguish between the two options.  Stripping it
             would prevent us from printing this field appropriately.  */
-          TYPE_FIELD_TYPE (rtype, f) = TYPE_FIELD_TYPE (type, f);
+          rtype->field (f).set_type (type->field (f).type ());
           TYPE_FIELD_NAME (rtype, f) = TYPE_FIELD_NAME (type, f);
           if (TYPE_FIELD_BITSIZE (type, f) > 0)
             fld_bit_len =
               TYPE_FIELD_BITSIZE (rtype, f) = TYPE_FIELD_BITSIZE (type, f);
           else
            {
-             struct type *field_type = TYPE_FIELD_TYPE (type, f);
+             struct type *field_type = type->field (f).type ();
 
              /* We need to be careful of typedefs when computing
                 the length of our field.  If this is a typedef,
@@ -8162,7 +7948,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 
       branch_type =
         to_fixed_variant_branch_type
-        (TYPE_FIELD_TYPE (type, variant_field),
+        (type->field (variant_field).type (),
          cond_offset_host (valaddr, off / TARGET_CHAR_BIT),
          cond_offset_target (address, off / TARGET_CHAR_BIT), dval);
       if (branch_type == NULL)
@@ -8173,10 +7959,10 @@ ada_template_to_fixed_record_type_1 (struct type *type,
         }
       else
         {
-          TYPE_FIELD_TYPE (rtype, variant_field) = branch_type;
+          rtype->field (variant_field).set_type (branch_type);
           TYPE_FIELD_NAME (rtype, variant_field) = "S";
           fld_bit_len =
-            TYPE_LENGTH (TYPE_FIELD_TYPE (rtype, variant_field)) *
+            TYPE_LENGTH (rtype->field (variant_field).type ()) *
             TARGET_CHAR_BIT;
           if (off + fld_bit_len > bit_len)
             bit_len = off + fld_bit_len;
@@ -8257,7 +8043,7 @@ template_to_static_fixed_type (struct type *type0)
 
   for (f = 0; f < nfields; f += 1)
     {
-      struct type *field_type = TYPE_FIELD_TYPE (type0, f);
+      struct type *field_type = type0->field (f).type ();
       struct type *new_type;
 
       if (is_dynamic_field (type0, f))
@@ -8289,7 +8075,7 @@ template_to_static_fixed_type (struct type *type0)
              TYPE_FIXED_INSTANCE (type) = 1;
              TYPE_LENGTH (type) = 0;
            }
-         TYPE_FIELD_TYPE (type, f) = new_type;
+         type->field (f).set_type (new_type);
          TYPE_FIELD_NAME (type, f) = TYPE_FIELD_NAME (type0, f);
        }
     }
@@ -8341,7 +8127,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
   TYPE_LENGTH (rtype) = TYPE_LENGTH (type);
 
   branch_type = to_fixed_variant_branch_type
-    (TYPE_FIELD_TYPE (type, variant_field),
+    (type->field (variant_field).type (),
      cond_offset_host (valaddr,
                        TYPE_FIELD_BITPOS (type, variant_field)
                        / TARGET_CHAR_BIT),
@@ -8358,12 +8144,12 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
     }
   else
     {
-      TYPE_FIELD_TYPE (rtype, variant_field) = branch_type;
+      rtype->field (variant_field).set_type (branch_type);
       TYPE_FIELD_NAME (rtype, variant_field) = "S";
       TYPE_FIELD_BITSIZE (rtype, variant_field) = 0;
       TYPE_LENGTH (rtype) += TYPE_LENGTH (branch_type);
     }
-  TYPE_LENGTH (rtype) -= TYPE_LENGTH (TYPE_FIELD_TYPE (type, variant_field));
+  TYPE_LENGTH (rtype) -= TYPE_LENGTH (type->field (variant_field).type ());
 
   value_free_to_mark (mark);
   return rtype;
@@ -8449,14 +8235,14 @@ to_fixed_variant_branch_type (struct type *var_type0, const gdb_byte *valaddr,
     return empty_record (var_type);
   else if (is_dynamic_field (var_type, which))
     return to_fixed_record_type
-      (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (var_type, which)),
+      (TYPE_TARGET_TYPE (var_type->field (which).type ()),
        valaddr, address, dval);
-  else if (variant_field_index (TYPE_FIELD_TYPE (var_type, which)) >= 0)
+  else if (variant_field_index (var_type->field (which).type ()) >= 0)
     return
       to_fixed_record_type
-      (TYPE_FIELD_TYPE (var_type, which), valaddr, address, dval);
+      (var_type->field (which).type (), valaddr, address, dval);
   else
-    return TYPE_FIELD_TYPE (var_type, which);
+    return var_type->field (which).type ();
 }
 
 /* Assuming RANGE_TYPE is a TYPE_CODE_RANGE, return nonzero if
@@ -8522,8 +8308,8 @@ ada_is_redundant_index_type_desc (struct type *array_type,
 
   for (i = 0; i < desc_type->num_fields (); i++)
     {
-      if (!ada_is_redundant_range_encoding (TYPE_INDEX_TYPE (this_layer),
-                                           TYPE_FIELD_TYPE (desc_type, i)))
+      if (!ada_is_redundant_range_encoding (this_layer->index_type (),
+                                           desc_type->field (i).type ()))
        return 0;
       this_layer = check_typedef (TYPE_TARGET_TYPE (this_layer));
     }
@@ -8616,7 +8402,7 @@ to_fixed_array_type (struct type *type0, struct value *dval,
         result = type0;
       else
         result = create_array_type (alloc_type_copy (type0),
-                                    elt_type, TYPE_INDEX_TYPE (type0));
+                                    elt_type, type0->index_type ());
     }
   else
     {
@@ -8645,7 +8431,7 @@ to_fixed_array_type (struct type *type0, struct value *dval,
       for (i = index_type_desc->num_fields () - 1; i >= 0; i -= 1)
         {
           struct type *range_type =
-            to_fixed_range_type (TYPE_FIELD_TYPE (index_type_desc, i), dval);
+            to_fixed_range_type (index_type_desc->field (i).type (), dval);
 
           result = create_array_type (alloc_type_copy (elt_type0),
                                       result, range_type);
@@ -8900,7 +8686,7 @@ static_unwrap_type (struct type *type)
 {
   if (ada_is_aligner_type (type))
     {
-      struct type *type1 = TYPE_FIELD_TYPE (ada_check_typedef (type), 0);
+      struct type *type1 = ada_check_typedef (type)->field (0).type ();
       if (ada_type_name (type1) == NULL)
        type1->set_name (ada_type_name (type));
 
@@ -9202,7 +8988,7 @@ ada_get_base_type (struct type *raw_type)
       || real_type_namer->num_fields () != 1)
     return raw_type;
 
-  if (TYPE_FIELD_TYPE (real_type_namer, 0)->code () != TYPE_CODE_REF)
+  if (real_type_namer->field (0).type ()->code () != TYPE_CODE_REF)
     {
       /* This is an older encoding form where the base type needs to be
         looked up by name.  We prefer the newer encoding because it is
@@ -9215,7 +9001,7 @@ ada_get_base_type (struct type *raw_type)
     }
 
   /* The field in our XVS type is a reference to the base type.  */
-  return TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (real_type_namer, 0));
+  return TYPE_TARGET_TYPE (real_type_namer->field (0).type ());
 }
 
 /* The type of value designated by TYPE, with all aligners removed.  */
@@ -9224,7 +9010,7 @@ struct type *
 ada_aligned_type (struct type *type)
 {
   if (ada_is_aligner_type (type))
-    return ada_aligned_type (TYPE_FIELD_TYPE (type, 0));
+    return ada_aligned_type (type->field (0).type ());
   else
     return ada_get_base_type (type);
 }
@@ -9237,7 +9023,7 @@ const gdb_byte *
 ada_aligned_value_addr (struct type *type, const gdb_byte *valaddr)
 {
   if (ada_is_aligner_type (type))
-    return ada_aligned_value_addr (TYPE_FIELD_TYPE (type, 0),
+    return ada_aligned_value_addr (type->field (0).type (),
                                    valaddr +
                                    TYPE_FIELD_BITPOS (type,
                                                       0) / TARGET_CHAR_BIT);
@@ -12108,11 +11894,7 @@ ada_exception_message_1 (void)
   if (e_msg_len <= 0)
     return NULL;
 
-  gdb::unique_xmalloc_ptr<char> e_msg ((char *) xmalloc (e_msg_len + 1));
-  read_memory_string (value_address (e_msg_val), e_msg.get (), e_msg_len + 1);
-  e_msg.get ()[e_msg_len] = '\0';
-
-  return e_msg;
+  return target_read_string (value_address (e_msg_val), INT_MAX);
 }
 
 /* Same as ada_exception_message_1, except that all exceptions are
@@ -13722,21 +13504,6 @@ enum ada_primitive_types {
 \f
                                /* Language vector */
 
-/* Not really used, but needed in the ada_language_defn.  */
-
-static void
-emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
-{
-  ada_emit_char (c, type, stream, quoter, 1);
-}
-
-static int
-parse (struct parser_state *ps)
-{
-  warnings_issued = 0;
-  return ada_parse (ps);
-}
-
 static const struct exp_descriptor ada_exp_descriptor = {
   ada_print_subexp,
   ada_operator_length,
@@ -13786,10 +13553,10 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
     {
       if (user_name.back () == '>')
        m_encoded_name
-         = user_name.substr (1, user_name.size () - 2).to_string ();
+         = gdb::to_string (user_name.substr (1, user_name.size () - 2));
       else
        m_encoded_name
-         = user_name.substr (1, user_name.size () - 1).to_string ();
+         = gdb::to_string (user_name.substr (1, user_name.size () - 1));
       m_encoded_p = true;
       m_verbatim_p = true;
       m_wild_match_p = false;
@@ -13808,10 +13575,10 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
          if (encoded != NULL)
            m_encoded_name = encoded;
          else
-           m_encoded_name = user_name.to_string ();
+           m_encoded_name = gdb::to_string (user_name);
        }
       else
-       m_encoded_name = user_name.to_string ();
+       m_encoded_name = gdb::to_string (user_name);
 
       /* Handle the 'package Standard' special case.  See description
         of m_standard_p.  */
@@ -13873,7 +13640,7 @@ literal_symbol_name_matcher (const char *symbol_search_name,
     return false;
 }
 
-/* Implement the "la_get_symbol_name_matcher" language_defn method for
+/* Implement the "get_symbol_name_matcher" language_defn method for
    Ada.  */
 
 static symbol_name_matcher_ftype *
@@ -13914,32 +13681,12 @@ extern const struct language_data ada_language_data =
   macro_expansion_no,
   ada_extensions,
   &ada_exp_descriptor,
-  parse,
-  resolve,
-  ada_printchar,                /* Print a character constant */
-  ada_printstr,                 /* Function to print string constant */
-  emit_char,                    /* Function to print single char (not used) */
-  ada_print_type,               /* Print a type using appropriate syntax */
-  ada_print_typedef,            /* Print a typedef using appropriate syntax */
-  ada_value_print_inner,       /* la_value_print_inner */
-  ada_value_print,              /* Print a top-level value */
-  NULL,                         /* Language specific skip_trampoline */
   NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
-  ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
-  ada_la_decode,                /* Language specific symbol demangler */
-  NULL,                         /* Language specific
-                                  class_name_from_physname */
   ada_op_print_tab,             /* expression operators for printing */
   0,                            /* c-style arrays */
   1,                            /* String lower bound */
-  ada_get_gdb_completer_word_break_characters,
-  ada_collect_symbol_completion_matches,
-  ada_watch_location_expression,
-  ada_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
   &ada_varobj_ops,
-  NULL,
-  ada_is_string_type,
   "(...)"                      /* la_struct_too_deep_ellipsis */
 };
 
@@ -14106,6 +13853,307 @@ public:
 
     return false;
   }
+
+  /* See language.h.  */
+
+  char *demangle (const char *mangled, int options) const override
+  {
+    return ada_la_decode (mangled, options);
+  }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    ada_print_type (type, varstring, stream, show, level, flags);
+  }
+
+  /* See language.h.  */
+
+  const char *word_break_characters (void) const override
+  {
+    return ada_completer_word_break_characters;
+  }
+
+  /* See language.h.  */
+
+  void collect_symbol_completion_matches (completion_tracker &tracker,
+                                         complete_symbol_mode mode,
+                                         symbol_name_match_type name_match_type,
+                                         const char *text, const char *word,
+                                         enum type_code code) const override
+  {
+    struct symbol *sym;
+    const struct block *b, *surrounding_static_block = 0;
+    struct block_iterator iter;
+
+    gdb_assert (code == TYPE_CODE_UNDEF);
+
+    lookup_name_info lookup_name (text, name_match_type, true);
+
+    /* First, look at the partial symtab symbols.  */
+    expand_symtabs_matching (NULL,
+                            lookup_name,
+                            NULL,
+                            NULL,
+                            ALL_DOMAIN);
+
+    /* At this point scan through the misc symbol vectors and add each
+       symbol you find to the list.  Eventually we want to ignore
+       anything that isn't a text symbol (everything else will be
+       handled by the psymtab code above).  */
+
+    for (objfile *objfile : current_program_space->objfiles ())
+      {
+       for (minimal_symbol *msymbol : objfile->msymbols ())
+         {
+           QUIT;
+
+           if (completion_skip_symbol (mode, msymbol))
+             continue;
+
+           language symbol_language = msymbol->language ();
+
+           /* Ada minimal symbols won't have their language set to Ada.  If
+              we let completion_list_add_name compare using the
+              default/C-like matcher, then when completing e.g., symbols in a
+              package named "pck", we'd match internal Ada symbols like
+              "pckS", which are invalid in an Ada expression, unless you wrap
+              them in '<' '>' to request a verbatim match.
+
+              Unfortunately, some Ada encoded names successfully demangle as
+              C++ symbols (using an old mangling scheme), such as "name__2Xn"
+              -> "Xn::name(void)" and thus some Ada minimal symbols end up
+              with the wrong language set.  Paper over that issue here.  */
+           if (symbol_language == language_auto
+               || symbol_language == language_cplus)
+             symbol_language = language_ada;
+
+           completion_list_add_name (tracker,
+                                     symbol_language,
+                                     msymbol->linkage_name (),
+                                     lookup_name, text, word);
+         }
+      }
+
+    /* Search upwards from currently selected frame (so that we can
+       complete on local vars.  */
+
+    for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b))
+      {
+       if (!BLOCK_SUPERBLOCK (b))
+         surrounding_static_block = b;   /* For elmin of dups */
+
+       ALL_BLOCK_SYMBOLS (b, iter, sym)
+         {
+           if (completion_skip_symbol (mode, sym))
+             continue;
+
+           completion_list_add_name (tracker,
+                                     sym->language (),
+                                     sym->linkage_name (),
+                                     lookup_name, text, word);
+         }
+      }
+
+    /* Go through the symtabs and check the externs and statics for
+       symbols which match.  */
+
+    for (objfile *objfile : current_program_space->objfiles ())
+      {
+       for (compunit_symtab *s : objfile->compunits ())
+         {
+           QUIT;
+           b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
+           ALL_BLOCK_SYMBOLS (b, iter, sym)
+             {
+               if (completion_skip_symbol (mode, sym))
+                 continue;
+
+               completion_list_add_name (tracker,
+                                         sym->language (),
+                                         sym->linkage_name (),
+                                         lookup_name, text, word);
+             }
+         }
+      }
+
+    for (objfile *objfile : current_program_space->objfiles ())
+      {
+       for (compunit_symtab *s : objfile->compunits ())
+         {
+           QUIT;
+           b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
+           /* Don't do this block twice.  */
+           if (b == surrounding_static_block)
+             continue;
+           ALL_BLOCK_SYMBOLS (b, iter, sym)
+             {
+               if (completion_skip_symbol (mode, sym))
+                 continue;
+
+               completion_list_add_name (tracker,
+                                         sym->language (),
+                                         sym->linkage_name (),
+                                         lookup_name, text, word);
+             }
+         }
+      }
+  }
+
+  /* See language.h.  */
+
+  gdb::unique_xmalloc_ptr<char> watch_location_expression
+       (struct type *type, CORE_ADDR addr) const override
+  {
+    type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+    std::string name = type_to_string (type);
+    return gdb::unique_xmalloc_ptr<char>
+      (xstrprintf ("{%s} %s", name.c_str (), core_addr_to_string (addr)));
+  }
+
+  /* See language.h.  */
+
+  void value_print (struct value *val, struct ui_file *stream,
+                   const struct value_print_options *options) const override
+  {
+    return ada_value_print (val, stream, options);
+  }
+
+  /* See language.h.  */
+
+  void value_print_inner
+       (struct value *val, struct ui_file *stream, int recurse,
+        const struct value_print_options *options) const override
+  {
+    return ada_value_print_inner (val, stream, recurse, options);
+  }
+
+  /* See language.h.  */
+
+  struct block_symbol lookup_symbol_nonlocal
+       (const char *name, const struct block *block,
+        const domain_enum domain) const override
+  {
+    struct block_symbol sym;
+
+    sym = ada_lookup_symbol (name, block_static_block (block), domain);
+    if (sym.symbol != NULL)
+      return sym;
+
+    /* If we haven't found a match at this point, try the primitive
+       types.  In other languages, this search is performed before
+       searching for global symbols in order to short-circuit that
+       global-symbol search if it happens that the name corresponds
+       to a primitive type.  But we cannot do the same in Ada, because
+       it is perfectly legitimate for a program to declare a type which
+       has the same name as a standard type.  If looking up a type in
+       that situation, we have traditionally ignored the primitive type
+       in favor of user-defined types.  This is why, unlike most other
+       languages, we search the primitive types this late and only after
+       having searched the global symbols without success.  */
+
+    if (domain == VAR_DOMAIN)
+      {
+       struct gdbarch *gdbarch;
+
+       if (block == NULL)
+         gdbarch = target_gdbarch ();
+       else
+         gdbarch = block_gdbarch (block);
+       sym.symbol
+         = language_lookup_primitive_type_as_symbol (this, gdbarch, name);
+       if (sym.symbol != NULL)
+         return sym;
+      }
+
+    return {};
+  }
+
+  /* See language.h.  */
+
+  int parser (struct parser_state *ps) const override
+  {
+    warnings_issued = 0;
+    return ada_parse (ps);
+  }
+
+  /* See language.h.
+
+     Same as evaluate_type (*EXP), but resolves ambiguous symbol references
+     (marked by OP_VAR_VALUE nodes in which the symbol has an undefined
+     namespace) and converts operators that are user-defined into
+     appropriate function calls.  If CONTEXT_TYPE is non-null, it provides
+     a preferred result type [at the moment, only type void has any
+     effect---causing procedures to be preferred over functions in calls].
+     A null CONTEXT_TYPE indicates that a non-void return type is
+     preferred.  May change (expand) *EXP.  */
+
+  void post_parser (expression_up *expp, int void_context_p, int completing,
+                   innermost_block_tracker *tracker) const override
+  {
+    struct type *context_type = NULL;
+    int pc = 0;
+
+    if (void_context_p)
+      context_type = builtin_type ((*expp)->gdbarch)->builtin_void;
+
+    resolve_subexp (expp, &pc, 1, context_type, completing, tracker);
+  }
+
+  /* See language.h.  */
+
+  void emitchar (int ch, struct type *chtype,
+                struct ui_file *stream, int quoter) const override
+  {
+    ada_emit_char (ch, chtype, stream, quoter, 1);
+  }
+
+  /* See language.h.  */
+
+  void printchar (int ch, struct type *chtype,
+                 struct ui_file *stream) const override
+  {
+    ada_printchar (ch, chtype, stream);
+  }
+
+  /* See language.h.  */
+
+  void printstr (struct ui_file *stream, struct type *elttype,
+                const gdb_byte *string, unsigned int length,
+                const char *encoding, int force_ellipses,
+                const struct value_print_options *options) const override
+  {
+    ada_printstr (stream, elttype, string, length, encoding,
+                 force_ellipses, options);
+  }
+
+  /* See language.h.  */
+
+  void print_typedef (struct type *type, struct symbol *new_symbol,
+                     struct ui_file *stream) const override
+  {
+    ada_print_typedef (type, new_symbol, stream);
+  }
+
+  /* See language.h.  */
+
+  bool is_string_type_p (struct type *type) const override
+  {
+    return ada_is_string_type (type);
+  }
+
+
+protected:
+  /* See language.h.  */
+
+  symbol_name_matcher_ftype *get_symbol_name_matcher_inner
+       (const lookup_name_info &lookup_name) const override
+  {
+    return ada_get_symbol_name_matcher (lookup_name);
+  }
 };
 
 /* Single instance of the Ada language class.  */
This page took 0.046598 seconds and 4 git commands to generate.