[binutils-gdb] gdb/gdbtypes: replace TYPE_ERROR_NAME macro with method

Simon Marchi via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8d2faef1addd2be1163f179ae7ccb2bdab47a709

commit 8d2faef1addd2be1163f179ae7ccb2bdab47a709
Author: Simon Marchi <[email protected]>
Date:   Tue Feb 17 14:13:57 2026 -0500

    gdb/gdbtypes: replace TYPE_ERROR_NAME macro with method
    
    Replace the TYPE_ERROR_NAME macro with the method type::error_name.
    
    Change-Id: I59afa6a8ced9c3bb53f3961965479a11deb41407
    Approved-By: Tom Tromey <[email protected]>

Diff:
---
 gdb/c-typeprint.c |  2 +-
 gdb/f-typeprint.c |  2 +-
 gdb/gdbtypes.h    | 13 +++++++------
 gdb/p-typeprint.c |  2 +-
 gdb/valprint.c    |  2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 5d78aa3e1a7..76472c23254 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -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:
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 786e26b32f6..f9309066936 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -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:
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 80886e59f67..e9a3c637be2 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -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);
 
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index a7ba45c90e8..c997ac9c091 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -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.  */
diff --git a/gdb/valprint.c b/gdb/valprint.c
index afc7fc0cc76..62b1b33bb66 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -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:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.