]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/gdbtypes: replace TYPE_ERROR_NAME macro with method
authorSimon Marchi <simon.marchi@polymtl.ca>
Tue, 17 Feb 2026 19:13:57 +0000 (14:13 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 9 Mar 2026 20:45:18 +0000 (16:45 -0400)
Replace the TYPE_ERROR_NAME macro with the method type::error_name.

Change-Id: I59afa6a8ced9c3bb53f3961965479a11deb41407
Approved-By: Tom Tromey <tom@tromey.com>
gdb/c-typeprint.c
gdb/f-typeprint.c
gdb/gdbtypes.h
gdb/p-typeprint.c
gdb/valprint.c

index 5d78aa3e1a74090195bece84b9b4659a076a45d4..76472c23254feaeca5ead8608e03727d85d161ca 100644 (file)
@@ -1514,7 +1514,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
       break;
 
     case TYPE_CODE_ERROR:
-      gdb_printf (stream, "%s", TYPE_ERROR_NAME (type));
+      gdb_printf (stream, "%s", type->error_name ());
       break;
 
     case TYPE_CODE_RANGE:
index 786e26b32f68ecb643a94b4383cfa16ad65675fe..f9309066936132e71608b38fe93d78d09f102c32 100644 (file)
@@ -364,7 +364,7 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream,
       break;
 
     case TYPE_CODE_ERROR:
-      gdb_printf (stream, "%*s%s", level, "", TYPE_ERROR_NAME (type));
+      gdb_printf (stream, "%*s%s", level, "", type->error_name ());
       break;
 
     case TYPE_CODE_RANGE:
index 80886e59f672bac6e6bb2772a2bb5f3b09ed44b5..e9a3c637be2f867c030d88e52e6e85a18cfe2530 100644 (file)
@@ -1065,6 +1065,13 @@ struct type
     return this->name () != nullptr ? this->name () : _("<unnamed type>");
   }
 
+  /* Return the name of this type, or "<error type>" if it has no
+     name.  */
+  const char *error_name () const
+  {
+    return this->name () != nullptr ? this->name () : _("<error type>");
+  }
+
   /* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
      But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
      so you only have to call check_typedef once.  Since value::allocate
@@ -2050,12 +2057,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
        || TYPE_NFN_FIELDS (thistype) == 0) \
    && ((thistype)->is_stub () || !(thistype)->stub_is_supported ()))
 
-/* * A helper macro that returns the name of an error type.  If the
-   type has a name, it is used; otherwise, a default is used.  */
-
-#define TYPE_ERROR_NAME(type) \
-  (type->name () ? type->name () : _("<error type>"))
-
 /* Given TYPE, return its floatformat.  */
 const struct floatformat *floatformat_from_type (const struct type *type);
 
index a7ba45c90e8d20fc1923e913ba6e6ed4e1228e05..c997ac9c09156c87cc8f04ecdf18079018bd9944 100644 (file)
@@ -689,7 +689,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
       break;
 
     case TYPE_CODE_ERROR:
-      gdb_printf (stream, "%s", TYPE_ERROR_NAME (type));
+      gdb_printf (stream, "%s", type->error_name ());
       break;
 
       /* this probably does not work for enums.  */
index afc7fc0cc76703eeedc04899fcc1ee91d295d8fb..62b1b33bb66463f3cb27a38aeb078dc8fd37bf3f 100644 (file)
@@ -1038,7 +1038,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_ERROR:
-      gdb_printf (stream, "%s", TYPE_ERROR_NAME (type));
+      gdb_printf (stream, "%s", type->error_name ());
       break;
 
     case TYPE_CODE_UNDEF: