[PATCH 1/2] gdb: add type::code / type::set_code

Simon Marchi simon.marchi@efficios.com
Mon May 11 23:48:30 GMT 2020


Add the code and set_code methods on code, in order to remove the
TYPE_CODE macro.  In this patch, the TYPE_CODE macro is changed to use
type::code, so all the call sites that are used to set the type code are
changed to use type::set_code.  The next patch will remove TYPE_CODE
completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <code, set_code>: New methods.
	(TYPE_CODE): Use type::code.  Change all call sites used to set
	the code to use type::set_code instead.
---
 gdb/ada-lang.c    | 10 +++++-----
 gdb/coffread.c    | 10 +++++-----
 gdb/ctfread.c     |  8 ++++----
 gdb/dwarf2/read.c | 14 +++++++-------
 gdb/eval.c        |  2 +-
 gdb/gdbtypes.c    | 30 +++++++++++++++---------------
 gdb/gdbtypes.h    | 19 ++++++++++++++++---
 gdb/mdebugread.c  |  6 +++---
 gdb/rust-lang.c   |  2 +-
 gdb/stabsread.c   | 14 +++++++-------
 gdb/valops.c      |  2 +-
 11 files changed, 65 insertions(+), 52 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index be26231524d..de89410cc7e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8039,7 +8039,7 @@ empty_record (struct type *templ)
 {
   struct type *type = alloc_type_copy (templ);
 
-  TYPE_CODE (type) = TYPE_CODE_STRUCT;
+  type->set_code (TYPE_CODE_STRUCT);
   TYPE_NFIELDS (type) = 0;
   TYPE_FIELDS (type) = NULL;
   INIT_NONE_SPECIFIC (type);
@@ -8095,7 +8095,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
     }
 
   rtype = alloc_type_copy (type);
-  TYPE_CODE (rtype) = TYPE_CODE_STRUCT;
+  rtype->set_code (TYPE_CODE_STRUCT);
   INIT_NONE_SPECIFIC (rtype);
   TYPE_NFIELDS (rtype) = nfields;
   TYPE_FIELDS (rtype) = (struct field *)
@@ -8370,7 +8370,7 @@ template_to_static_fixed_type (struct type *type0)
 	  if (type == type0)
 	    {
 	      TYPE_TARGET_TYPE (type0) = type = alloc_type_copy (type0);
-	      TYPE_CODE (type) = TYPE_CODE (type0);
+	      type->set_code (TYPE_CODE(type0));
 	      INIT_NONE_SPECIFIC (type);
 	      TYPE_NFIELDS (type) = nfields;
 	      TYPE_FIELDS (type) = (struct field *)
@@ -8419,7 +8419,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
     dval = dval0;
 
   rtype = alloc_type_copy (type);
-  TYPE_CODE (rtype) = TYPE_CODE_STRUCT;
+  rtype->set_code (TYPE_CODE_STRUCT);
   INIT_NONE_SPECIFIC (rtype);
   TYPE_NFIELDS (rtype) = nfields;
   TYPE_FIELDS (rtype) =
@@ -10388,7 +10388,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
         /* The result type will have code OP_STRING, bashed there from 
            OP_ARRAY.  Bash it back.  */
         if (TYPE_CODE (value_type (result)) == TYPE_CODE_STRING)
-          TYPE_CODE (value_type (result)) = TYPE_CODE_ARRAY;
+          value_type (result)->set_code (TYPE_CODE_ARRAY);
         return result;
       }
 
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 7fbdcc4f68f..4b2993feb76 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1880,7 +1880,7 @@ decode_base_type (struct coff_symbol *cs,
 	{
 	  /* Anonymous structure type.  */
 	  type = coff_alloc_type (cs->c_symnum);
-	  TYPE_CODE (type) = TYPE_CODE_STRUCT;
+	  type->set_code (TYPE_CODE_STRUCT);
 	  TYPE_NAME (type) = NULL;
 	  INIT_CPLUS_SPECIFIC (type);
 	  TYPE_LENGTH (type) = 0;
@@ -1914,7 +1914,7 @@ decode_base_type (struct coff_symbol *cs,
 					aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
 					objfile);
 	}
-      TYPE_CODE (type) = TYPE_CODE_UNION;
+      type->set_code (TYPE_CODE_UNION);
       return type;
 
     case T_ENUM:
@@ -1922,7 +1922,7 @@ decode_base_type (struct coff_symbol *cs,
 	{
 	  /* Anonymous enum type.  */
 	  type = coff_alloc_type (cs->c_symnum);
-	  TYPE_CODE (type) = TYPE_CODE_ENUM;
+	  type->set_code (TYPE_CODE_ENUM);
 	  TYPE_NAME (type) = NULL;
 	  TYPE_LENGTH (type) = 0;
 	  TYPE_FIELDS (type) = 0;
@@ -1990,7 +1990,7 @@ coff_read_struct_type (int index, int length, int lastsym,
   int done = 0;
 
   type = coff_alloc_type (index);
-  TYPE_CODE (type) = TYPE_CODE_STRUCT;
+  type->set_code (TYPE_CODE_STRUCT);
   INIT_CPLUS_SPECIFIC (type);
   TYPE_LENGTH (type) = length;
 
@@ -2121,7 +2121,7 @@ coff_read_enum_type (int index, int length, int lastsym,
     TYPE_LENGTH (type) = length;
   else /* Assume ints.  */
     TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
-  TYPE_CODE (type) = TYPE_CODE_ENUM;
+  type->set_code (TYPE_CODE_ENUM);
   TYPE_NFIELDS (type) = nsyms;
   TYPE_FIELDS (type) = (struct field *)
     TYPE_ALLOC (type, sizeof (struct field) * nsyms);
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 8cc7271c075..06c036df10a 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -600,9 +600,9 @@ read_structure_type (struct ctf_context *ccp, ctf_id_t tid)
 
   kind = ctf_type_kind (fp, tid);
   if (kind == CTF_K_UNION)
-    TYPE_CODE (type) = TYPE_CODE_UNION;
+    type->set_code (TYPE_CODE_UNION);
   else
-    TYPE_CODE (type) = TYPE_CODE_STRUCT;
+    type->set_code (TYPE_CODE_STRUCT);
 
   TYPE_LENGTH (type) = ctf_type_size (fp, tid);
   set_type_align (type, ctf_type_align (fp, tid));
@@ -656,7 +656,7 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid)
   if (name != NULL && strlen (name.get ()) != 0)
     TYPE_NAME (type) = obstack_strdup (&of->objfile_obstack, name.get ());
 
-  TYPE_CODE (type) = TYPE_CODE_FUNC;
+  type->set_code (TYPE_CODE_FUNC);
   ctf_func_type_info (fp, tid, &cfi);
   rettype = get_tid_type (of, cfi.ctc_return);
   TYPE_TARGET_TYPE (type) = rettype;
@@ -682,7 +682,7 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid)
   if (name != NULL && strlen (name.get ()) != 0)
     TYPE_NAME (type) = obstack_strdup (&of->objfile_obstack, name.get ());
 
-  TYPE_CODE (type) = TYPE_CODE_ENUM;
+  type->set_code (TYPE_CODE_ENUM);
   TYPE_LENGTH (type) = ctf_type_size (fp, tid);
   ctf_func_type_info (fp, tid, &fi);
   target_type = get_tid_type (of, fi.ctc_return);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 27bf40a898d..4809202c903 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9325,7 +9325,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 
       /* Smash this type to be a structure type.  We have to do this
 	 because the type has already been recorded.  */
-      TYPE_CODE (type) = TYPE_CODE_STRUCT;
+      type->set_code (TYPE_CODE_STRUCT);
       TYPE_NFIELDS (type) = 3;
       /* Save the field we care about.  */
       struct field saved_field = TYPE_FIELD (type, 0);
@@ -9368,7 +9368,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
     {
       /* Smash this type to be a structure type.  We have to do this
 	 because the type has already been recorded.  */
-      TYPE_CODE (type) = TYPE_CODE_STRUCT;
+      type->set_code (TYPE_CODE_STRUCT);
 
       struct type *field_type = TYPE_FIELD_TYPE (type, 0);
       const char *variant_name
@@ -9415,7 +9415,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 
       /* Smash this type to be a structure type.  We have to do this
 	 because the type has already been recorded.  */
-      TYPE_CODE (type) = TYPE_CODE_STRUCT;
+      type->set_code (TYPE_CODE_STRUCT);
 
       /* Make space for the discriminant field.  */
       struct field *disr_field = &TYPE_FIELD (disr_type, 0);
@@ -15369,15 +15369,15 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
 
   if (die->tag == DW_TAG_structure_type)
     {
-      TYPE_CODE (type) = TYPE_CODE_STRUCT;
+      type->set_code (TYPE_CODE_STRUCT);
     }
   else if (die->tag == DW_TAG_union_type)
     {
-      TYPE_CODE (type) = TYPE_CODE_UNION;
+      type->set_code (TYPE_CODE_UNION);
     }
   else
     {
-      TYPE_CODE (type) = TYPE_CODE_STRUCT;
+      type->set_code (TYPE_CODE_STRUCT);
     }
 
   if (cu->language == language_cplus && die->tag == DW_TAG_class_type)
@@ -15937,7 +15937,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
 
   type = alloc_type (objfile);
 
-  TYPE_CODE (type) = TYPE_CODE_ENUM;
+  type->set_code (TYPE_CODE_ENUM);
   name = dwarf2_full_name (NULL, die, cu);
   if (name != NULL)
     TYPE_NAME (type) = name;
diff --git a/gdb/eval.c b/gdb/eval.c
index 3b1f4943b43..f1cfb930c97 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -658,7 +658,7 @@ fake_method::fake_method (type_instance_flags flags,
 
   TYPE_MAIN_TYPE (type) = &m_main_type;
   TYPE_LENGTH (type) = 1;
-  TYPE_CODE (type) = TYPE_CODE_METHOD;
+  type->set_code (TYPE_CODE_METHOD);
   TYPE_CHAIN (type) = type;
   TYPE_INSTANCE_FLAGS (type) = flags;
   if (num_types > 0)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 3f829241f05..671ee528917 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -182,7 +182,7 @@ alloc_type (struct objfile *objfile)
 
   /* Initialize the fields that might not be zero.  */
 
-  TYPE_CODE (type) = TYPE_CODE_UNDEF;
+  type->set_code (TYPE_CODE_UNDEF);
   TYPE_CHAIN (type) = type;	/* Chain back to itself.  */
 
   return type;
@@ -209,7 +209,7 @@ alloc_type_arch (struct gdbarch *gdbarch)
 
   /* Initialize the fields that might not be zero.  */
 
-  TYPE_CODE (type) = TYPE_CODE_UNDEF;
+  type->set_code (TYPE_CODE_UNDEF);
   TYPE_CHAIN (type) = type;	/* Chain back to itself.  */
 
   return type;
@@ -366,7 +366,7 @@ make_pointer_type (struct type *type, struct type **typeptr)
 
   TYPE_LENGTH (ntype)
     = gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT;
-  TYPE_CODE (ntype) = TYPE_CODE_PTR;
+  ntype->set_code (TYPE_CODE_PTR);
 
   /* Mark pointers as unsigned.  The target converts between pointers
      and addresses (CORE_ADDRs) using gdbarch_pointer_to_address and
@@ -450,7 +450,7 @@ make_reference_type (struct type *type, struct type **typeptr,
 
   TYPE_LENGTH (ntype) =
     gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT;
-  TYPE_CODE (ntype) = refcode;
+  ntype->set_code (refcode);
 
   *reftype = ntype;
 
@@ -515,7 +515,7 @@ make_function_type (struct type *type, struct type **typeptr)
   TYPE_TARGET_TYPE (ntype) = type;
 
   TYPE_LENGTH (ntype) = 1;
-  TYPE_CODE (ntype) = TYPE_CODE_FUNC;
+  ntype->set_code (TYPE_CODE_FUNC);
 
   INIT_FUNC_SPECIFIC (ntype);
 
@@ -861,7 +861,7 @@ allocate_stub_method (struct type *type)
   struct type *mtype;
 
   mtype = alloc_type_copy (type);
-  TYPE_CODE (mtype) = TYPE_CODE_METHOD;
+  mtype->set_code (TYPE_CODE_METHOD);
   TYPE_LENGTH (mtype) = 1;
   TYPE_STUB (mtype) = 1;
   TYPE_TARGET_TYPE (mtype) = type;
@@ -928,7 +928,7 @@ create_range_type (struct type *result_type, struct type *index_type,
 
   if (result_type == NULL)
     result_type = alloc_type_copy (index_type);
-  TYPE_CODE (result_type) = TYPE_CODE_RANGE;
+  result_type->set_code (TYPE_CODE_RANGE);
   TYPE_TARGET_TYPE (result_type) = index_type;
   if (TYPE_STUB (index_type))
     TYPE_TARGET_STUB (result_type) = 1;
@@ -1278,7 +1278,7 @@ create_array_type_with_stride (struct type *result_type,
   if (result_type == NULL)
     result_type = alloc_type_copy (range_type);
 
-  TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
+  result_type->set_code (TYPE_CODE_ARRAY);
   TYPE_TARGET_TYPE (result_type) = element_type;
 
   TYPE_NFIELDS (result_type) = 1;
@@ -1357,7 +1357,7 @@ create_string_type (struct type *result_type,
   result_type = create_array_type (result_type,
 				   string_char_type,
 				   range_type);
-  TYPE_CODE (result_type) = TYPE_CODE_STRING;
+  result_type->set_code (TYPE_CODE_STRING);
   return result_type;
 }
 
@@ -1369,7 +1369,7 @@ lookup_string_range_type (struct type *string_char_type,
 
   result_type = lookup_array_range_type (string_char_type,
 					 low_bound, high_bound);
-  TYPE_CODE (result_type) = TYPE_CODE_STRING;
+  result_type->set_code (TYPE_CODE_STRING);
   return result_type;
 }
 
@@ -1379,7 +1379,7 @@ create_set_type (struct type *result_type, struct type *domain_type)
   if (result_type == NULL)
     result_type = alloc_type_copy (domain_type);
 
-  TYPE_CODE (result_type) = TYPE_CODE_SET;
+  result_type->set_code (TYPE_CODE_SET);
   TYPE_NFIELDS (result_type) = 1;
   TYPE_FIELDS (result_type)
     = (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
@@ -1508,7 +1508,7 @@ smash_to_memberptr_type (struct type *type, struct type *self_type,
 			 struct type *to_type)
 {
   smash_type (type);
-  TYPE_CODE (type) = TYPE_CODE_MEMBERPTR;
+  type->set_code (TYPE_CODE_MEMBERPTR);
   TYPE_TARGET_TYPE (type) = to_type;
   set_type_self_type (type, self_type);
   /* Assume that a data member pointer is the same size as a normal
@@ -1527,7 +1527,7 @@ void
 smash_to_methodptr_type (struct type *type, struct type *to_type)
 {
   smash_type (type);
-  TYPE_CODE (type) = TYPE_CODE_METHODPTR;
+  type->set_code (TYPE_CODE_METHODPTR);
   TYPE_TARGET_TYPE (type) = to_type;
   set_type_self_type (type, TYPE_SELF_TYPE (to_type));
   TYPE_LENGTH (type) = cplus_method_ptr_size (to_type);
@@ -1546,7 +1546,7 @@ smash_to_method_type (struct type *type, struct type *self_type,
 		      int nargs, int varargs)
 {
   smash_type (type);
-  TYPE_CODE (type) = TYPE_CODE_METHOD;
+  type->set_code (TYPE_CODE_METHOD);
   TYPE_TARGET_TYPE (type) = to_type;
   set_type_self_type (type, self_type);
   TYPE_FIELDS (type) = args;
@@ -3111,7 +3111,7 @@ allocate_gnat_aux_type (struct type *type)
 static void
 set_type_code (struct type *type, enum type_code code)
 {
-  TYPE_CODE (type) = code;
+  type->set_code (code);
 
   switch (code)
     {
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 7514bd27f7c..9f4924e9404 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -874,6 +874,21 @@ struct main_type
 
 struct type
 {
+  /* Get the type code of this type. 
+
+     Note that the code can be TYPE_CODE_TYPEDEF, so if you want the real
+     type, you need to do `check_typedef (type)->code ()`.  */
+  type_code code () const
+  {
+    return this->main_type->code;
+  }
+
+  /* Set the type code of this type.  */
+  void set_code (type_code code)
+  {
+    this->main_type->code = code;
+  }
+
   /* * Return the dynamic property of the requested KIND from this type's
      list of dynamic properties.  */
   dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
@@ -1420,9 +1435,7 @@ extern unsigned type_align (struct type *);
    space in struct type.  */
 extern bool set_type_align (struct type *, ULONGEST);
 
-/* * Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real
-   type, you need to do TYPE_CODE (check_type (this_type)).  */
-#define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code
+#define TYPE_CODE(thistype) ((thistype)->code ())
 #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields
 #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 5c4158cd6fb..621069ec20d 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1015,7 +1015,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	  TYPE_NAME (t) = obconcat (&mdebugread_objfile->objfile_obstack,
 				    name, (char *) NULL);
 
-	TYPE_CODE (t) = type_code;
+	t->set_code (type_code);
 	TYPE_LENGTH (t) = sh->value;
 	TYPE_NFIELDS (t) = nfields;
 	TYPE_FIELDS (t) = f = ((struct field *)
@@ -1668,7 +1668,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
 
 	  if (TYPE_CODE (tp) != type_code)
 	    {
-	      TYPE_CODE (tp) = type_code;
+	      tp->set_code (type_code);
 	    }
 
 	  /* Do not set the tag name if it is a compiler generated tag name
@@ -1709,7 +1709,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
 	  if (TYPE_CODE (tp) != type_code)
 	    {
 	      bad_tag_guess_complaint (sym_name);
-	      TYPE_CODE (tp) = type_code;
+	      tp->set_code (type_code);
 	    }
 	  if (TYPE_NAME (tp) == NULL
 	      || strcmp (TYPE_NAME (tp), name) != 0)
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index f2fb0119b00..eb0ea1bfc83 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -981,7 +981,7 @@ rust_composite_type (struct type *original,
   if (field2 != NULL)
     ++nfields;
 
-  TYPE_CODE (result) = TYPE_CODE_STRUCT;
+  result->set_code (TYPE_CODE_STRUCT);
   TYPE_NAME (result) = name;
 
   TYPE_NFIELDS (result) = nfields;
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index eac47407105..5601c8012e4 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1687,7 +1687,7 @@ read_type (const char **pp, struct objfile *objfile)
 	   fill in the rest of the fields when we get the full
 	   type.  */
 	type = dbx_alloc_type (typenums, objfile);
-	TYPE_CODE (type) = code;
+	type->set_code (code);
 	TYPE_NAME (type) = type_name;
 	INIT_CPLUS_SPECIFIC (type);
 	TYPE_STUB (type) = 1;
@@ -1716,14 +1716,14 @@ read_type (const char **pp, struct objfile *objfile)
       /* Allocate and enter the typedef type first.
          This handles recursive types.  */
       type = dbx_alloc_type (typenums, objfile);
-      TYPE_CODE (type) = TYPE_CODE_TYPEDEF;
+      type->set_code (TYPE_CODE_TYPEDEF);
       {
 	struct type *xtype = read_type (pp, objfile);
 
 	if (type == xtype)
 	  {
 	    /* It's being defined as itself.  That means it is "void".  */
-	    TYPE_CODE (type) = TYPE_CODE_VOID;
+	    type->set_code (TYPE_CODE_VOID);
 	    TYPE_LENGTH (type) = 1;
 	  }
 	else if (type_size >= 0 || is_string)
@@ -2022,7 +2022,7 @@ read_type (const char **pp, struct objfile *objfile)
       type = dbx_alloc_type (typenums, objfile);
       type = read_array_type (pp, type, objfile);
       if (is_string)
-	TYPE_CODE (type) = TYPE_CODE_STRING;
+	type->set_code (TYPE_CODE_STRING);
       if (is_vector)
 	make_vector_type (type);
       break;
@@ -2370,7 +2370,7 @@ read_member_functions (struct stab_field_info *fip, const char **pp,
 
 	  /* These are methods, not functions.  */
 	  if (TYPE_CODE (new_sublist->fn_field.type) == TYPE_CODE_FUNC)
-	    TYPE_CODE (new_sublist->fn_field.type) = TYPE_CODE_METHOD;
+	    new_sublist->fn_field.type->set_code (TYPE_CODE_METHOD);
 	  else
 	    gdb_assert (TYPE_CODE (new_sublist->fn_field.type)
 			== TYPE_CODE_METHOD);
@@ -3477,7 +3477,7 @@ read_struct_type (const char **pp, struct type *type, enum type_code type_code,
     }
 
   INIT_CPLUS_SPECIFIC (type);
-  TYPE_CODE (type) = type_code;
+  type->set_code (type_code);
   TYPE_STUB (type) = 0;
 
   /* First comes the total size in bytes.  */
@@ -3652,7 +3652,7 @@ read_enum_type (const char **pp, struct type *type,
 
   TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT;
   set_length_in_type_chain (type);
-  TYPE_CODE (type) = TYPE_CODE_ENUM;
+  type->set_code (TYPE_CODE_ENUM);
   TYPE_STUB (type) = 0;
   if (unsigned_enum)
     TYPE_UNSIGNED (type) = 1;
diff --git a/gdb/valops.c b/gdb/valops.c
index aa995e6eecd..2e7abf5b599 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3792,7 +3792,7 @@ value_slice (struct value *array, int lowbound, int length)
     slice_type = create_array_type (NULL,
 				    element_type,
 				    slice_range_type);
-    TYPE_CODE (slice_type) = TYPE_CODE (array_type);
+    slice_type->set_code (TYPE_CODE (array_type));
 
     if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
       slice = allocate_value_lazy (slice_type);
-- 
2.26.2



More information about the Gdb-patches mailing list