Remove bound_name static from ada-lang.c
authorTom Tromey <tromey@adacore.com>
Tue, 5 May 2020 12:57:04 +0000 (06:57 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 20 May 2020 13:20:05 +0000 (07:20 -0600)
ada-lang.c has a "bound_name" static that is used when finding fields
in a structure in some cases.  This patch removes it in favor of
computing the desired field name at runtime; this avoids an artificial
limit.

I'm checking this in.  Tested on x86-64 Fedora 30, and also on the
internal AdaCore test suite.

gdb/ChangeLog
2020-05-20  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (bound_name, MAX_ADA_DIMENS): Remove.
        (desc_one_bound, desc_index_type): Compute field name.

gdb/ChangeLog
gdb/ada-lang.c

index 6a7cbf38c01bd525668ee490a7f92cd7806bd3b7..bef88d0df6a32fa4c3009e9bfbc2ff5a7c156bab 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-20  Tom Tromey  <tromey@adacore.com>
+
+       * ada-lang.c (bound_name, MAX_ADA_DIMENS): Remove.
+        (desc_one_bound, desc_index_type): Compute field name.
+
 2020-05-20  Tom de Vries  <tdevries@suse.de>
 
        PR symtab/25833
index 825549d86e9b53a713380a962951a05ff3879c72..9f6485e04ab74069b5eff00968f694ab7a1ec794 100644 (file)
@@ -1486,18 +1486,6 @@ ada_fixup_array_indexes_type (struct type *index_desc_type)
    }
 }
 
-/* Names of MAX_ADA_DIMENS bounds in P_BOUNDS fields of array descriptors.  */
-
-static const char *bound_name[] = {
-  "LB0", "UB0", "LB1", "UB1", "LB2", "UB2", "LB3", "UB3",
-  "LB4", "UB4", "LB5", "UB5", "LB6", "UB6", "LB7", "UB7"
-};
-
-/* Maximum number of array dimensions we are prepared to handle.  */
-
-#define MAX_ADA_DIMENS (sizeof(bound_name) / (2*sizeof(char *)))
-
-
 /* The desc_* routines return primitive portions of array descriptors
    (fat pointers).  */
 
@@ -1760,7 +1748,10 @@ fat_pntr_data_bitsize (struct type *type)
 static struct value *
 desc_one_bound (struct value *bounds, int i, int which)
 {
-  return value_struct_elt (&bounds, NULL, bound_name[2 * i + which - 2], NULL,
+  char bound_name[20];
+  xsnprintf (bound_name, sizeof (bound_name), "%cB%d",
+            which ? 'U' : 'L', i - 1);
+  return value_struct_elt (&bounds, NULL, bound_name, NULL,
                            _("Bad GNAT array descriptor bounds"));
 }
 
@@ -1798,7 +1789,11 @@ desc_index_type (struct type *type, int i)
   type = desc_base_type (type);
 
   if (type->code () == TYPE_CODE_STRUCT)
-    return lookup_struct_elt_type (type, bound_name[2 * i - 2], 1);
+    {
+      char bound_name[20];
+      xsnprintf (bound_name, sizeof (bound_name), "LB%d", i - 1);
+      return lookup_struct_elt_type (type, bound_name, 1);
+    }
   else
     return NULL;
 }
This page took 0.064154 seconds and 4 git commands to generate.