[6/9] Remove TYPE_NOSIGN "char" hack

Message ID 20160825150723.3D7F6C9FB@oc7340732750.ibm.com
State New, archived
Headers

Commit Message

Ulrich Weigand Aug. 25, 2016, 3:07 p.m. UTC
  Hello,

init_type (and arch_integer_type) currently use a special hack to set the
TYPE_NOSIGN flag if the type name is exactly "char".  This patch moves the
hack up to the callers of those routines.

The special case currently can hit only for types created from dwarf2read,
but read_base_type actually implements the "char" check itself, so it is
redundant to do it in init_type as well.  (Note that stabsread.c and the
other type readers always pass NULL as name to init_type, so the special
case can never hit for those.)

A few other cases create pre-definded types with a hard-coded name of "char";
the patch simply moves setting the TYPE_NOSIGN flag to those places.

No functional change intended.

Bye,
Ulrich

ChangeLog:

	* gdbtypes.c (init_type): Remove "char" special case.
	(arch_integer_type): Likewise.
	(gdbtypes_post_init): Set TYPE_NOSIGN for "char" type.
	(objfile_type): Likewise.
	* mdebugread.c (basic_type): Likewise.
	* stabsread.c (rs6000_builtin_type): Likewise.
  

Patch

Index: binutils-gdb/gdb/gdbtypes.c
===================================================================
--- binutils-gdb.orig/gdb/gdbtypes.c	2016-08-25 13:11:50.006839555 +0200
+++ binutils-gdb/gdb/gdbtypes.c	2016-08-25 13:11:50.766842886 +0200
@@ -2748,11 +2748,6 @@  init_type (struct objfile *objfile, enum
   TYPE_LENGTH (type) = length;
   TYPE_NAME (type) = name;
 
-  /* C++ fancies.  */
-
-  if (name && strcmp (name, "char") == 0)
-    TYPE_NOSIGN (type) = 1;
-
   return type;
 }
 
@@ -4780,8 +4775,6 @@  arch_integer_type (struct gdbarch *gdbar
   t = arch_type (gdbarch, TYPE_CODE_INT, bit / TARGET_CHAR_BIT, name);
   if (unsigned_p)
     TYPE_UNSIGNED (t) = 1;
-  if (name && strcmp (name, "char") == 0)
-    TYPE_NOSIGN (t) = 1;
 
   return t;
 }
@@ -5046,6 +5039,7 @@  gdbtypes_post_init (struct gdbarch *gdba
   builtin_type->builtin_char
     = arch_integer_type (gdbarch, TARGET_CHAR_BIT,
 			 !gdbarch_char_signed (gdbarch), "char");
+  TYPE_NOSIGN (builtin_type->builtin_char) = 1;
   builtin_type->builtin_signed_char
     = arch_integer_type (gdbarch, TARGET_CHAR_BIT,
 			 0, "signed char");
@@ -5193,6 +5187,7 @@  objfile_type (struct objfile *objfile)
   objfile_type->builtin_char
     = init_integer_type (objfile, TARGET_CHAR_BIT,
 			 !gdbarch_char_signed (gdbarch), "char");
+  TYPE_NOSIGN (objfile_type->builtin_char) = 1;
   objfile_type->builtin_signed_char
     = init_integer_type (objfile, TARGET_CHAR_BIT,
 			 0, "signed char");
Index: binutils-gdb/gdb/mdebugread.c
===================================================================
--- binutils-gdb.orig/gdb/mdebugread.c	2016-08-25 13:11:49.274836346 +0200
+++ binutils-gdb/gdb/mdebugread.c	2016-08-25 13:11:50.768842894 +0200
@@ -1408,6 +1408,7 @@  basic_type (int bt, struct objfile *objf
 
     case btChar:
       tp = init_integer_type (objfile, 8, 0, "char");
+      TYPE_NOSIGN (tp) = 1;
       break;
 
     case btUChar:
Index: binutils-gdb/gdb/stabsread.c
===================================================================
--- binutils-gdb.orig/gdb/stabsread.c	2016-08-25 13:11:49.280836372 +0200
+++ binutils-gdb/gdb/stabsread.c	2016-08-25 13:11:50.770842904 +0200
@@ -2102,6 +2102,7 @@  rs6000_builtin_type (int typenum, struct
       break;
     case 2:
       rettype = init_integer_type (objfile, 8, 0, "char");
+      TYPE_NOSIGN (rettype) = 1;
       break;
     case 3:
       rettype = init_integer_type (objfile, 16, 0, "short");