Blame SOURCES/gdb-rhbz1320945-float128-4of9.patch

a094f6
commit 19f392bc2a93d9e64d063b884cd6eca547c8dad0
a094f6
Author: Ulrich Weigand <ulrich.weigand@de.ibm.com>
a094f6
Date:   Tue Sep 6 17:27:55 2016 +0200
a094f6
a094f6
    Unify init_type and arch_type interface and helpers
a094f6
    
a094f6
    This adds a number of helper routines for creating objfile-owned types;
a094f6
    these correspond 1:1 to the already existing helper routines for creating
a094f6
    gdbarch-owned types, and are intended to be used instead of init_type.
a094f6
    A shared fragment of init_float_type and arch_float_type is extracted into
a094f6
    a separate subroutine verify_subroutine.
a094f6
    
a094f6
    The commit also brings the interface of init_type in line with the one for
a094f6
    arch_type.  In particular, this means removing the FLAGS argument; callers
a094f6
    now set the required flags directly.  (Since most callers use the new
a094f6
    helper routines, very few callers actually need to set any additional
a094f6
    flags directly any more.)
a094f6
    
a094f6
    Note that this means all the TYPE_FLAGS_... defined are no longer needed
a094f6
    anywhere; they will be removed by a follow-on commit.
a094f6
    
a094f6
    All users of init_type are changed to use on of the new helpers where
a094f6
    possible.  No functional change intended.
a094f6
    
a094f6
    gdb/ChangeLog:
a094f6
    
a094f6
            * gdbtypes.h (init_type): Remove FLAGS argument.  Move OBJFILE
a094f6
            argument to first position.
a094f6
            (init_integer_type): New prototype.
a094f6
            (init_character_type): Likewise.
a094f6
            (init_boolean_type): Likewise.
a094f6
            (init_float_type): Likewise.
a094f6
            (init_decfloat_type): Likewise.
a094f6
            (init_complex_type): Likewise.
a094f6
            (init_pointer_type): Likewise.
a094f6
            * gdbtypes.c (verify_floatflormat): New function.
a094f6
            (init_type): Remove FLAGS argument and processing.  Move OBJFILE
a094f6
            argument to first position.
a094f6
            (init_integer_type): New function.
a094f6
            (init_character_type): Likewise.
a094f6
            (init_boolean_type): Likewise.
a094f6
            (init_float_type): Likewise.
a094f6
            (init_decfloat_type): Likewise.
a094f6
            (init_complex_type): Likewise.
a094f6
            (init_pointer_type): Likewise.
a094f6
            (arch_float_type): Use verify_floatflormat.
a094f6
            (objfile_type): Use init_..._type helpers instead of calling
a094f6
            init_type directly.
a094f6
            * dwarf2read.c (fixup_go_packaging): Update to changed init_type
a094f6
            prototype.
a094f6
            (read_namespace_type): Likewise.
a094f6
            (read_module_type): Likewise.
a094f6
            (read_typedef): Likewise.
a094f6
            (read_unspecified_type): Likewise.
a094f6
            (build_error_marker_type): Likewise.
a094f6
            (read_base_type): Use init_..._type helpers.
a094f6
            * mdebugread.c (basic_type): Use init_..._type helpers.
a094f6
            (parse_type): Update to changed init_type prototype.
a094f6
            (cross_ref): Likewise.
a094f6
            * stabsread.c (rs6000_builtin_type): Use init_..._type helpers.
a094f6
            (read_sun_builtin_type): Likewise.
a094f6
            (read_sun_floating_type): Likewise.
a094f6
            (read_range_type): Likewise.  Also update to changed init_type
a094f6
            prototype.
a094f6
    
a094f6
    Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
a094f6
a094f6
### a/gdb/ChangeLog
a094f6
### b/gdb/ChangeLog
a094f6
## -1,5 +1,46 @@
a094f6
 2016-09-05  Ulrich Weigand  <uweigand@de.ibm.com>
a094f6
 
a094f6
+	* gdbtypes.h (init_type): Remove FLAGS argument.  Move OBJFILE
a094f6
+	argument to first position.
a094f6
+	(init_integer_type): New prototype.
a094f6
+	(init_character_type): Likewise.
a094f6
+	(init_boolean_type): Likewise.
a094f6
+	(init_float_type): Likewise.
a094f6
+	(init_decfloat_type): Likewise.
a094f6
+	(init_complex_type): Likewise.
a094f6
+	(init_pointer_type): Likewise.
a094f6
+	* gdbtypes.c (verify_floatflormat): New function.
a094f6
+	(init_type): Remove FLAGS argument and processing.  Move OBJFILE
a094f6
+	argument to first position.
a094f6
+	(init_integer_type): New function.
a094f6
+	(init_character_type): Likewise.
a094f6
+	(init_boolean_type): Likewise.
a094f6
+	(init_float_type): Likewise.
a094f6
+	(init_decfloat_type): Likewise.
a094f6
+	(init_complex_type): Likewise.
a094f6
+	(init_pointer_type): Likewise.
a094f6
+	(arch_float_type): Use verify_floatflormat.
a094f6
+	(objfile_type): Use init_..._type helpers instead of calling
a094f6
+	init_type directly.
a094f6
+	* dwarf2read.c (fixup_go_packaging): Update to changed init_type
a094f6
+	prototype.
a094f6
+	(read_namespace_type): Likewise.
a094f6
+	(read_module_type): Likewise.
a094f6
+	(read_typedef): Likewise.
a094f6
+	(read_unspecified_type): Likewise.
a094f6
+	(build_error_marker_type): Likewise.
a094f6
+	(read_base_type): Use init_..._type helpers.
a094f6
+	* mdebugread.c (basic_type): Use init_..._type helpers.
a094f6
+	(parse_type): Update to changed init_type prototype.
a094f6
+	(cross_ref): Likewise.
a094f6
+	* stabsread.c (rs6000_builtin_type): Use init_..._type helpers.
a094f6
+	(read_sun_builtin_type): Likewise.
a094f6
+	(read_sun_floating_type): Likewise.
a094f6
+	(read_range_type): Likewise.  Also update to changed init_type
a094f6
+	prototype.
a094f6
+
a094f6
+2016-09-05  Ulrich Weigand  <uweigand@de.ibm.com>
a094f6
+
a094f6
 	* gdbtypes.h (arch_decfloat_type): New prototype.
a094f6
 	(arch_pointer_type): Likewise.
a094f6
 	* gdbtypes.c (arch_decfloat_type): New function.
a094f6
Index: gdb-7.6.1/gdb/dwarf2read.c
a094f6
===================================================================
a094f6
--- gdb-7.6.1.orig/gdb/dwarf2read.c	2017-03-11 21:42:28.099262777 +0100
a094f6
+++ gdb-7.6.1/gdb/dwarf2read.c	2017-03-11 21:45:39.098565504 +0100
a094f6
@@ -6901,8 +6901,8 @@
a094f6
       const char *saved_package_name = obstack_copy0 (&objfile->objfile_obstack,
a094f6
 						      package_name,
a094f6
 						      strlen (package_name));
a094f6
-      struct type *type = init_type (TYPE_CODE_MODULE, 0, 0,
a094f6
-				     saved_package_name, objfile);
a094f6
+      struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0,
a094f6
+				     saved_package_name);
a094f6
       struct symbol *sym;
a094f6
 
a094f6
       TYPE_TAG_NAME (type) = TYPE_NAME (type);
a094f6
@@ -12266,9 +12266,7 @@
a094f6
 			    previous_prefix, name, 0, cu);
a094f6
 
a094f6
   /* Create the type.  */
a094f6
-  type = init_type (TYPE_CODE_NAMESPACE, 0, 0, NULL,
a094f6
-		    objfile);
a094f6
-  TYPE_NAME (type) = name;
a094f6
+  type = init_type (objfile, TYPE_CODE_NAMESPACE, 0, name);
a094f6
   TYPE_TAG_NAME (type) = TYPE_NAME (type);
a094f6
 
a094f6
   return set_die_type (die, type, cu);
a094f6
@@ -12331,7 +12329,7 @@
a094f6
     complaint (&symfile_complaints,
a094f6
 	       _("DW_TAG_module has no name, offset 0x%x"),
a094f6
                die->offset.sect_off);
a094f6
-  type = init_type (TYPE_CODE_MODULE, 0, 0, module_name, objfile);
a094f6
+  type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name);
a094f6
 
a094f6
   /* determine_prefix uses TYPE_TAG_NAME.  */
a094f6
   TYPE_TAG_NAME (type) = TYPE_NAME (type);
a094f6
@@ -12884,9 +12882,8 @@
a094f6
   struct type *this_type, *target_type;
a094f6
 
a094f6
   name = dwarf2_full_name (NULL, die, cu);
a094f6
-  this_type = init_type (TYPE_CODE_TYPEDEF, 0,
a094f6
-			 TYPE_FLAG_TARGET_STUB, NULL, objfile);
a094f6
-  TYPE_NAME (this_type) = name;
a094f6
+  this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, name);
a094f6
+  TYPE_TARGET_STUB (this_type) = 1;
a094f6
   set_die_type (die, this_type, cu);
a094f6
   target_type = die_type (die, cu);
a094f6
   if (target_type != this_type)
a094f6
@@ -12913,11 +12910,8 @@
a094f6
   struct objfile *objfile = cu->objfile;
a094f6
   struct type *type;
a094f6
   struct attribute *attr;
a094f6
-  int encoding = 0, size = 0;
a094f6
+  int encoding = 0, bits = 0;
a094f6
   const char *name;
a094f6
-  enum type_code code = TYPE_CODE_INT;
a094f6
-  int type_flags = 0;
a094f6
-  struct type *target_type = NULL;
a094f6
 
a094f6
   attr = dwarf2_attr (die, DW_AT_encoding, cu);
a094f6
   if (attr)
a094f6
@@ -12927,7 +12921,7 @@
a094f6
   attr = dwarf2_attr (die, DW_AT_byte_size, cu);
a094f6
   if (attr)
a094f6
     {
a094f6
-      size = DW_UNSND (attr);
a094f6
+      bits = DW_UNSND (attr) * TARGET_CHAR_BIT;
a094f6
     }
a094f6
   name = dwarf2_name (die, cu);
a094f6
   if (!name)
a094f6
@@ -12940,61 +12934,63 @@
a094f6
     {
a094f6
       case DW_ATE_address:
a094f6
 	/* Turn DW_ATE_address into a void * pointer.  */
a094f6
-	code = TYPE_CODE_PTR;
a094f6
-	type_flags |= TYPE_FLAG_UNSIGNED;
a094f6
-	target_type = init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
a094f6
+	type = init_type (objfile, TYPE_CODE_VOID, 1, NULL);
a094f6
+	type = init_pointer_type (objfile, bits, name, type);
a094f6
 	break;
a094f6
       case DW_ATE_boolean:
a094f6
-	code = TYPE_CODE_BOOL;
a094f6
-	type_flags |= TYPE_FLAG_UNSIGNED;
a094f6
+	type = init_boolean_type (objfile, bits, 1, name);
a094f6
 	break;
a094f6
       case DW_ATE_complex_float:
a094f6
-	code = TYPE_CODE_COMPLEX;
a094f6
-	target_type = init_type (TYPE_CODE_FLT, size / 2, 0, NULL, objfile);
a094f6
+	type = init_float_type (objfile, bits / 2, NULL, NULL);
a094f6
+	type = init_complex_type (objfile, name, type);
a094f6
 	break;
a094f6
       case DW_ATE_decimal_float:
a094f6
-	code = TYPE_CODE_DECFLOAT;
a094f6
+	type = init_decfloat_type (objfile, bits, name);
a094f6
 	break;
a094f6
       case DW_ATE_float:
a094f6
-	code = TYPE_CODE_FLT;
a094f6
+	type = init_float_type (objfile, bits, name, NULL);
a094f6
 	break;
a094f6
       case DW_ATE_signed:
a094f6
+	type = init_integer_type (objfile, bits, 0, name);
a094f6
 	break;
a094f6
       case DW_ATE_unsigned:
a094f6
-	type_flags |= TYPE_FLAG_UNSIGNED;
a094f6
 	if (cu->language == language_fortran
a094f6
 	    && name
a094f6
 	    && strncmp (name, "character(", sizeof ("character(") - 1) == 0)
a094f6
-	  code = TYPE_CODE_CHAR;
a094f6
+	  type = init_character_type (objfile, bits, 1, name);
a094f6
+	else
a094f6
+	  type = init_integer_type (objfile, bits, 1, name);
a094f6
 	break;
a094f6
       case DW_ATE_signed_char:
a094f6
 	if (cu->language == language_ada || cu->language == language_m2
a094f6
 	    || cu->language == language_pascal
a094f6
 	    || cu->language == language_fortran)
a094f6
-	  code = TYPE_CODE_CHAR;
a094f6
+	  type = init_character_type (objfile, bits, 0, name);
a094f6
+	else
a094f6
+	  type = init_integer_type (objfile, bits, 0, name);
a094f6
 	break;
a094f6
       case DW_ATE_unsigned_char:
a094f6
 	if (cu->language == language_ada || cu->language == language_m2
a094f6
 	    || cu->language == language_pascal
a094f6
 	    || cu->language == language_fortran)
a094f6
-	  code = TYPE_CODE_CHAR;
a094f6
-	type_flags |= TYPE_FLAG_UNSIGNED;
a094f6
+	  type = init_character_type (objfile, bits, 1, name);
a094f6
+	else
a094f6
+	  type = init_integer_type (objfile, bits, 1, name);
a094f6
 	break;
a094f6
       case DW_ATE_UTF:
a094f6
 	/* We just treat this as an integer and then recognize the
a094f6
 	   type by name elsewhere.  */
a094f6
+	type = init_integer_type (objfile, bits, 0, name);
a094f6
 	break;
a094f6
 
a094f6
       default:
a094f6
 	complaint (&symfile_complaints, _("unsupported DW_AT_encoding: '%s'"),
a094f6
 		   dwarf_type_encoding_name (encoding));
a094f6
+	type = init_type (objfile, TYPE_CODE_ERROR,
a094f6
+			  bits / TARGET_CHAR_BIT, name);
a094f6
 	break;
a094f6
     }
a094f6
 
a094f6
-  type = init_type (code, size, type_flags, NULL, objfile);
a094f6
-  TYPE_NAME (type) = name;
a094f6
-  TYPE_TARGET_TYPE (type) = target_type;
a094f6
-
a094f6
   if (name && strcmp (name, "char") == 0)
a094f6
     TYPE_NOSIGN (type) = 1;
a094f6
 
a094f6
@@ -13287,7 +13283,7 @@
a094f6
 
a094f6
   /* For now, we only support the C meaning of an unspecified type: void.  */
a094f6
 
a094f6
-  type = init_type (TYPE_CODE_VOID, 0, 0, NULL, cu->objfile);
a094f6
+  type = init_type (cu->objfile, TYPE_CODE_VOID, 0, NULL);
a094f6
   TYPE_NAME (type) = dwarf2_name (die, cu);
a094f6
 
a094f6
   return set_die_type (die, type, cu);
a094f6
@@ -16913,7 +16909,7 @@
a094f6
 			     message, strlen (message));
a094f6
       xfree (message);
a094f6
 
a094f6
-      this_type = init_type (TYPE_CODE_ERROR, 0, 0, saved, objfile);
a094f6
+      this_type = init_type (objfile, TYPE_CODE_ERROR, 0, saved);
a094f6
     }
a094f6
 
a094f6
   return this_type;
a094f6
Index: gdb-7.6.1/gdb/gdbtypes.c
a094f6
===================================================================
a094f6
--- gdb-7.6.1.orig/gdb/gdbtypes.c	2017-03-11 21:45:27.194484312 +0100
a094f6
+++ gdb-7.6.1/gdb/gdbtypes.c	2017-03-11 21:48:13.551598067 +0100
a094f6
@@ -2107,6 +2107,41 @@
a094f6
     }
a094f6
 }
a094f6
 
a094f6
+// RH
a094f6
+#define FLOATFORMAT_CHAR_BIT 8 // doublest.c
a094f6
+static size_t
a094f6
+floatformat_totalsize_bytes (const struct floatformat *fmt)
a094f6
+{
a094f6
+  return ((fmt->totalsize + FLOATFORMAT_CHAR_BIT - 1)
a094f6
+          / FLOATFORMAT_CHAR_BIT);
a094f6
+}
a094f6
+
a094f6
+/* Helper function to verify floating-point format and size.
a094f6
+   BIT is the type size in bits; if BIT equals -1, the size is
a094f6
+   determined by the floatformat.  Returns size to be used.  */
a094f6
+
a094f6
+static int
a094f6
+verify_floatformat (int bit, const struct floatformat **floatformats)
a094f6
+{
a094f6
+  if (bit == -1)
a094f6
+    {
a094f6
+      gdb_assert (floatformats != NULL);
a094f6
+      gdb_assert (floatformats[0] != NULL && floatformats[1] != NULL);
a094f6
+      bit = floatformats[0]->totalsize;
a094f6
+    }
a094f6
+  gdb_assert (bit >= 0);
a094f6
+
a094f6
+  if (floatformats != NULL)
a094f6
+    {
a094f6
+      size_t len = bit / TARGET_CHAR_BIT;
a094f6
+
a094f6
+      gdb_assert (len >= floatformat_totalsize_bytes (floatformats[0]));
a094f6
+      gdb_assert (len >= floatformat_totalsize_bytes (floatformats[1]));
a094f6
+    }
a094f6
+
a094f6
+  return bit;
a094f6
+}
a094f6
+
a094f6
 /* Helper function to initialize the standard scalar types.
a094f6
 
a094f6
    If NAME is non-NULL, then it is used to initialize the type name.
a094f6
@@ -2114,8 +2149,8 @@
a094f6
    least as long as OBJFILE.  */
a094f6
 
a094f6
 struct type *
a094f6
-init_type (enum type_code code, LONGEST length, int flags,
a094f6
-	   const char *name, struct objfile *objfile)
a094f6
+init_type (struct objfile *objfile, enum type_code code, LONGEST length,
a094f6
+	   const char *name)
a094f6
 {
a094f6
   struct type *type;
a094f6
 
a094f6
@@ -2123,32 +2158,6 @@
a094f6
   set_type_code (type, code);
a094f6
   TYPE_LENGTH (type) = length;
a094f6
 
a094f6
-  gdb_assert (!(flags & (TYPE_FLAG_MIN - 1)));
a094f6
-  if (flags & TYPE_FLAG_UNSIGNED)
a094f6
-    TYPE_UNSIGNED (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_NOSIGN)
a094f6
-    TYPE_NOSIGN (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_STUB)
a094f6
-    TYPE_STUB (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_TARGET_STUB)
a094f6
-    TYPE_TARGET_STUB (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_STATIC)
a094f6
-    TYPE_STATIC (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_PROTOTYPED)
a094f6
-    TYPE_PROTOTYPED (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_INCOMPLETE)
a094f6
-    TYPE_INCOMPLETE (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_VARARGS)
a094f6
-    TYPE_VARARGS (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_VECTOR)
a094f6
-    TYPE_VECTOR (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_STUB_SUPPORTED)
a094f6
-    TYPE_STUB_SUPPORTED (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_FIXED_INSTANCE)
a094f6
-    TYPE_FIXED_INSTANCE (type) = 1;
a094f6
-  if (flags & TYPE_FLAG_GNU_IFUNC)
a094f6
-    TYPE_GNU_IFUNC (type) = 1;
a094f6
-
a094f6
   TYPE_NAME (type) = name;
a094f6
 
a094f6
   /* C++ fancies.  */
a094f6
@@ -2158,6 +2167,121 @@
a094f6
 
a094f6
   return type;
a094f6
 }
a094f6
+
a094f6
+/* Allocate a TYPE_CODE_INT type structure associated with OBJFILE.
a094f6
+   BIT is the type size in bits.  If UNSIGNED_P is non-zero, set
a094f6
+   the type's TYPE_UNSIGNED flag.  NAME is the type name.  */
a094f6
+
a094f6
+struct type *
a094f6
+init_integer_type (struct objfile *objfile,
a094f6
+		   int bit, int unsigned_p, const char *name)
a094f6
+{
a094f6
+  struct type *t;
a094f6
+
a094f6
+  t = init_type (objfile, TYPE_CODE_INT, bit / TARGET_CHAR_BIT, name);
a094f6
+  if (unsigned_p)
a094f6
+    TYPE_UNSIGNED (t) = 1;
a094f6
+
a094f6
+  return t;
a094f6
+}
a094f6
+
a094f6
+/* Allocate a TYPE_CODE_CHAR type structure associated with OBJFILE.
a094f6
+   BIT is the type size in bits.  If UNSIGNED_P is non-zero, set
a094f6
+   the type's TYPE_UNSIGNED flag.  NAME is the type name.  */
a094f6
+
a094f6
+struct type *
a094f6
+init_character_type (struct objfile *objfile,
a094f6
+		     int bit, int unsigned_p, const char *name)
a094f6
+{
a094f6
+  struct type *t;
a094f6
+
a094f6
+  t = init_type (objfile, TYPE_CODE_CHAR, bit / TARGET_CHAR_BIT, name);
a094f6
+  if (unsigned_p)
a094f6
+    TYPE_UNSIGNED (t) = 1;
a094f6
+
a094f6
+  return t;
a094f6
+}
a094f6
+
a094f6
+/* Allocate a TYPE_CODE_BOOL type structure associated with OBJFILE.
a094f6
+   BIT is the type size in bits.  If UNSIGNED_P is non-zero, set
a094f6
+   the type's TYPE_UNSIGNED flag.  NAME is the type name.  */
a094f6
+
a094f6
+struct type *
a094f6
+init_boolean_type (struct objfile *objfile,
a094f6
+		   int bit, int unsigned_p, const char *name)
a094f6
+{
a094f6
+  struct type *t;
a094f6
+
a094f6
+  t = init_type (objfile, TYPE_CODE_BOOL, bit / TARGET_CHAR_BIT, name);
a094f6
+  if (unsigned_p)
a094f6
+    TYPE_UNSIGNED (t) = 1;
a094f6
+
a094f6
+  return t;
a094f6
+}
a094f6
+
a094f6
+/* Allocate a TYPE_CODE_FLT type structure associated with OBJFILE.
a094f6
+   BIT is the type size in bits; if BIT equals -1, the size is
a094f6
+   determined by the floatformat.  NAME is the type name.  Set the
a094f6
+   TYPE_FLOATFORMAT from FLOATFORMATS.  */
a094f6
+
a094f6
+struct type *
a094f6
+init_float_type (struct objfile *objfile,
a094f6
+		 int bit, const char *name,
a094f6
+		 const struct floatformat **floatformats)
a094f6
+{
a094f6
+  struct type *t;
a094f6
+
a094f6
+  bit = verify_floatformat (bit, floatformats);
a094f6
+  t = init_type (objfile, TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, name);
a094f6
+  TYPE_FLOATFORMAT (t) = floatformats;
a094f6
+
a094f6
+  return t;
a094f6
+}
a094f6
+
a094f6
+/* Allocate a TYPE_CODE_DECFLOAT type structure associated with OBJFILE.
a094f6
+   BIT is the type size in bits.  NAME is the type name.  */
a094f6
+
a094f6
+struct type *
a094f6
+init_decfloat_type (struct objfile *objfile, int bit, const char *name)
a094f6
+{
a094f6
+  struct type *t;
a094f6
+
a094f6
+  t = init_type (objfile, TYPE_CODE_DECFLOAT, bit / TARGET_CHAR_BIT, name);
a094f6
+  return t;
a094f6
+}
a094f6
+
a094f6
+/* Allocate a TYPE_CODE_COMPLEX type structure associated with OBJFILE.
a094f6
+   NAME is the type name.  TARGET_TYPE is the component float type.  */
a094f6
+
a094f6
+struct type *
a094f6
+init_complex_type (struct objfile *objfile,
a094f6
+		   const char *name, struct type *target_type)
a094f6
+{
a094f6
+  struct type *t;
a094f6
+
a094f6
+  t = init_type (objfile, TYPE_CODE_COMPLEX,
a094f6
+		 2 * TYPE_LENGTH (target_type), name);
a094f6
+  TYPE_TARGET_TYPE (t) = target_type;
a094f6
+  return t;
a094f6
+}
a094f6
+
a094f6
+/* Allocate a TYPE_CODE_PTR type structure associated with OBJFILE.
a094f6
+   BIT is the pointer type size in bits.  NAME is the type name.
a094f6
+   TARGET_TYPE is the pointer target type.  Always sets the pointer type's
a094f6
+   TYPE_UNSIGNED flag.  */
a094f6
+
a094f6
+struct type *
a094f6
+init_pointer_type (struct objfile *objfile,
a094f6
+		   int bit, const char *name, struct type *target_type)
a094f6
+{
a094f6
+  struct type *t;
a094f6
+
a094f6
+  t = init_type (objfile, TYPE_CODE_PTR, bit / TARGET_CHAR_BIT, name);
a094f6
+  TYPE_TARGET_TYPE (t) = target_type;
a094f6
+  TYPE_UNSIGNED (t) = 1;
a094f6
+  return t;
a094f6
+}
a094f6
+
a094f6
 
a094f6
 /* Queries on types.  */
a094f6
 
a094f6
@@ -4010,14 +4134,7 @@
a094f6
 {
a094f6
   struct type *t;
a094f6
 
a094f6
-  if (bit == -1)
a094f6
-    {
a094f6
-      gdb_assert (floatformats != NULL);
a094f6
-      gdb_assert (floatformats[0] != NULL && floatformats[1] != NULL);
a094f6
-      bit = floatformats[0]->totalsize;
a094f6
-    }
a094f6
-  gdb_assert (bit >= 0);
a094f6
-
a094f6
+  bit = verify_floatformat (bit, floatformats);
a094f6
   t = arch_type (gdbarch, TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, name);
a094f6
   TYPE_FLOATFORMAT (t) = floatformats;
a094f6
   return t;
a094f6
@@ -4350,109 +4467,80 @@
a094f6
 
a094f6
   /* Basic types.  */
a094f6
   objfile_type->builtin_void
a094f6
-    = init_type (TYPE_CODE_VOID, 1,
a094f6
-		 0,
a094f6
-		 "void", objfile);
a094f6
-
a094f6
+    = init_type (objfile, TYPE_CODE_VOID, 1, "void");
a094f6
   objfile_type->builtin_char
a094f6
-    = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
a094f6
-		 (TYPE_FLAG_NOSIGN
a094f6
-		  | (gdbarch_char_signed (gdbarch) ? 0 : TYPE_FLAG_UNSIGNED)),
a094f6
-		 "char", objfile);
a094f6
+    = init_integer_type (objfile, TARGET_CHAR_BIT,
a094f6
+			 !gdbarch_char_signed (gdbarch), "char");
a094f6
   objfile_type->builtin_signed_char
a094f6
-    = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
a094f6
-		 0,
a094f6
-		 "signed char", objfile);
a094f6
+    = init_integer_type (objfile, TARGET_CHAR_BIT,
a094f6
+			 0, "signed char");
a094f6
   objfile_type->builtin_unsigned_char
a094f6
-    = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
a094f6
-		 TYPE_FLAG_UNSIGNED,
a094f6
-		 "unsigned char", objfile);
a094f6
+    = init_integer_type (objfile, TARGET_CHAR_BIT,
a094f6
+			 1, "unsigned char");
a094f6
   objfile_type->builtin_short
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 0, "short", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_short_bit (gdbarch),
a094f6
+			 0, "short");
a094f6
   objfile_type->builtin_unsigned_short
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_short_bit (gdbarch),
a094f6
+			 1, "unsigned short");
a094f6
   objfile_type->builtin_int
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 0, "int", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_int_bit (gdbarch),
a094f6
+			 0, "int");
a094f6
   objfile_type->builtin_unsigned_int
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_int_bit (gdbarch),
a094f6
+			 1, "unsigned int");
a094f6
   objfile_type->builtin_long
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 0, "long", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_long_bit (gdbarch),
a094f6
+			 0, "long");
a094f6
   objfile_type->builtin_unsigned_long
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_long_bit (gdbarch),
a094f6
+			 1, "unsigned long");
a094f6
   objfile_type->builtin_long_long
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 0, "long long", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_long_long_bit (gdbarch),
a094f6
+			 0, "long long");
a094f6
   objfile_type->builtin_unsigned_long_long
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
a094f6
-
a094f6
+    = init_integer_type (objfile, gdbarch_long_long_bit (gdbarch),
a094f6
+			 1, "unsigned long long");
a094f6
   objfile_type->builtin_float
a094f6
-    = init_type (TYPE_CODE_FLT,
a094f6
-		 gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 0, "float", objfile);
a094f6
-  TYPE_FLOATFORMAT (objfile_type->builtin_float)
a094f6
-    = gdbarch_float_format (gdbarch);
a094f6
+    = init_float_type (objfile, gdbarch_float_bit (gdbarch),
a094f6
+		       "float", gdbarch_float_format (gdbarch));
a094f6
   objfile_type->builtin_double
a094f6
-    = init_type (TYPE_CODE_FLT,
a094f6
-		 gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 0, "double", objfile);
a094f6
-  TYPE_FLOATFORMAT (objfile_type->builtin_double)
a094f6
-    = gdbarch_double_format (gdbarch);
a094f6
+    = init_float_type (objfile, gdbarch_double_bit (gdbarch),
a094f6
+		       "double", gdbarch_double_format (gdbarch));
a094f6
   objfile_type->builtin_long_double
a094f6
-    = init_type (TYPE_CODE_FLT,
a094f6
-		 gdbarch_long_double_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
-		 0, "long double", objfile);
a094f6
-  TYPE_FLOATFORMAT (objfile_type->builtin_long_double)
a094f6
-    = gdbarch_long_double_format (gdbarch);
a094f6
+    = init_float_type (objfile, gdbarch_long_double_bit (gdbarch),
a094f6
+		       "long double", gdbarch_long_double_format (gdbarch));
a094f6
 
a094f6
   /* This type represents a type that was unrecognized in symbol read-in.  */
a094f6
   objfile_type->builtin_error
a094f6
-    = init_type (TYPE_CODE_ERROR, 0, 0, "<unknown type>", objfile);
a094f6
+    = init_type (objfile, TYPE_CODE_ERROR, 0, "<unknown type>");
a094f6
 
a094f6
   /* The following set of types is used for symbols with no
a094f6
      debug information.  */
a094f6
   objfile_type->nodebug_text_symbol
a094f6
-    = init_type (TYPE_CODE_FUNC, 1, 0,
a094f6
-		 "<text variable, no debug info>", objfile);
a094f6
+    = init_type (objfile, TYPE_CODE_FUNC, 1,
a094f6
+		 "<text variable, no debug info>");
a094f6
   TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol)
a094f6
     = objfile_type->builtin_int;
a094f6
   objfile_type->nodebug_text_gnu_ifunc_symbol
a094f6
-    = init_type (TYPE_CODE_FUNC, 1, TYPE_FLAG_GNU_IFUNC,
a094f6
-		 "<text gnu-indirect-function variable, no debug info>",
a094f6
-		 objfile);
a094f6
+    = init_type (objfile, TYPE_CODE_FUNC, 1,
a094f6
+		 "<text gnu-indirect-function variable, no debug info>");
a094f6
   TYPE_TARGET_TYPE (objfile_type->nodebug_text_gnu_ifunc_symbol)
a094f6
     = objfile_type->nodebug_text_symbol;
a094f6
+  TYPE_GNU_IFUNC (objfile_type->nodebug_text_gnu_ifunc_symbol) = 1;
a094f6
   objfile_type->nodebug_got_plt_symbol
a094f6
-    = init_type (TYPE_CODE_PTR, gdbarch_addr_bit (gdbarch) / 8, 0,
a094f6
-		 "<text from jump slot in .got.plt, no debug info>",
a094f6
-		 objfile);
a094f6
-  TYPE_TARGET_TYPE (objfile_type->nodebug_got_plt_symbol)
a094f6
-    = objfile_type->nodebug_text_symbol;
a094f6
+    = init_pointer_type (objfile, gdbarch_addr_bit (gdbarch),
a094f6
+			 "<text from jump slot in .got.plt, no debug info>",
a094f6
+			 objfile_type->nodebug_text_symbol);
a094f6
   objfile_type->nodebug_data_symbol
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
a094f6
-		 "<data variable, no debug info>", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_int_bit (gdbarch), 0,
a094f6
+			 "<data variable, no debug info>");
a094f6
   objfile_type->nodebug_unknown_symbol
a094f6
-    = init_type (TYPE_CODE_INT, 1, 0,
a094f6
-		 "<variable (not text or data), no debug info>", objfile);
a094f6
+    = init_integer_type (objfile, TARGET_CHAR_BIT, 0,
a094f6
+			 "<variable (not text or data), no debug info>");
a094f6
   objfile_type->nodebug_tls_symbol
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
a094f6
-		 "<thread local variable, no debug info>", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_int_bit (gdbarch), 0,
a094f6
+			 "<thread local variable, no debug info>");
a094f6
 
a094f6
   /* NOTE: on some targets, addresses and pointers are not necessarily
a094f6
      the same --- for example, on the D10V, pointers are 16 bits long,
a094f6
@@ -4482,9 +4570,8 @@
a094f6
      are indeed in the unified virtual address space.  */
a094f6
 
a094f6
   objfile_type->builtin_core_addr
a094f6
-    = init_type (TYPE_CODE_INT,
a094f6
-		 gdbarch_addr_bit (gdbarch) / 8,
a094f6
-		 TYPE_FLAG_UNSIGNED, "__CORE_ADDR", objfile);
a094f6
+    = init_integer_type (objfile, gdbarch_addr_bit (gdbarch), 1,
a094f6
+			 "__CORE_ADDR");
a094f6
 
a094f6
   set_objfile_data (objfile, objfile_type_data, objfile_type);
a094f6
   return objfile_type;
a094f6
Index: gdb-7.6.1/gdb/gdbtypes.h
a094f6
===================================================================
a094f6
--- gdb-7.6.1.orig/gdb/gdbtypes.h	2017-03-11 21:45:27.194484312 +0100
a094f6
+++ gdb-7.6.1/gdb/gdbtypes.h	2017-03-11 21:45:39.100565518 +0100
a094f6
@@ -1542,8 +1542,21 @@
a094f6
 extern struct gdbarch *get_type_arch (const struct type *);
a094f6
 
a094f6
 /* Helper function to construct objfile-owned types.  */
a094f6
-extern struct type *init_type (enum type_code, LONGEST, int, const char *,
a094f6
-			       struct objfile *);
a094f6
+extern struct type *init_type (struct objfile *, enum type_code, LONGEST,
a094f6
+			       const char *);
a094f6
+extern struct type *init_integer_type (struct objfile *, int, int,
a094f6
+				       const char *);
a094f6
+extern struct type *init_character_type (struct objfile *, int, int,
a094f6
+					 const char *);
a094f6
+extern struct type *init_boolean_type (struct objfile *, int, int,
a094f6
+				       const char *);
a094f6
+extern struct type *init_float_type (struct objfile *, int, const char *,
a094f6
+				     const struct floatformat **);
a094f6
+extern struct type *init_decfloat_type (struct objfile *, int, const char *);
a094f6
+extern struct type *init_complex_type (struct objfile *, const char *,
a094f6
+				       struct type *);
a094f6
+extern struct type *init_pointer_type (struct objfile *, int, const char *,
a094f6
+				       struct type *);
a094f6
 
a094f6
 /* Helper functions to construct architecture-owned types.  */
a094f6
 extern struct type *arch_type (struct gdbarch *, enum type_code, LONGEST,
a094f6
Index: gdb-7.6.1/gdb/mdebugread.c
a094f6
===================================================================
a094f6
--- gdb-7.6.1.orig/gdb/mdebugread.c	2017-03-11 21:42:28.099262777 +0100
a094f6
+++ gdb-7.6.1/gdb/mdebugread.c	2017-03-11 21:45:39.101565525 +0100
a094f6
@@ -1374,97 +1374,80 @@
a094f6
       break;
a094f6
 
a094f6
     case btAdr:
a094f6
-      tp = init_type (TYPE_CODE_PTR, 4, TYPE_FLAG_UNSIGNED,
a094f6
-		      "adr_32", objfile);
a094f6
-      TYPE_TARGET_TYPE (tp) = objfile_type (objfile)->builtin_void;
a094f6
+      tp = init_pointer_type (objfile, 32, "adr_32",
a094f6
+			      objfile_type (objfile)->builtin_void);
a094f6
       break;
a094f6
 
a094f6
     case btChar:
a094f6
-      tp = init_type (TYPE_CODE_INT, 1, 0,
a094f6
-		      "char", objfile);
a094f6
+      tp = init_integer_type (objfile, 8, 0, "char");
a094f6
       break;
a094f6
 
a094f6
     case btUChar:
a094f6
-      tp = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED,
a094f6
-		      "unsigned char", objfile);
a094f6
+      tp = init_integer_type (objfile, 8, 1, "unsigned char");
a094f6
       break;
a094f6
 
a094f6
     case btShort:
a094f6
-      tp = init_type (TYPE_CODE_INT, 2, 0,
a094f6
-		      "short", objfile);
a094f6
+      tp = init_integer_type (objfile, 16, 0, "short");
a094f6
       break;
a094f6
 
a094f6
     case btUShort:
a094f6
-      tp = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED,
a094f6
-		      "unsigned short", objfile);
a094f6
+      tp = init_integer_type (objfile, 16, 1, "unsigned short");
a094f6
       break;
a094f6
 
a094f6
     case btInt:
a094f6
-      tp = init_type (TYPE_CODE_INT, 4, 0,
a094f6
-		      "int", objfile);
a094f6
+      tp = init_integer_type (objfile, 32, 0, "int");
a094f6
       break;
a094f6
 
a094f6
    case btUInt:
a094f6
-      tp = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
a094f6
-		      "unsigned int", objfile);
a094f6
+      tp = init_integer_type (objfile, 32, 1, "unsigned int");
a094f6
       break;
a094f6
 
a094f6
     case btLong:
a094f6
-      tp = init_type (TYPE_CODE_INT, 4, 0,
a094f6
-		      "long", objfile);
a094f6
+      tp = init_integer_type (objfile, 32, 0, "long");
a094f6
       break;
a094f6
 
a094f6
     case btULong:
a094f6
-      tp = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
a094f6
-		      "unsigned long", objfile);
a094f6
+      tp = init_integer_type (objfile, 32, 1, "unsigned long");
a094f6
       break;
a094f6
 
a094f6
     case btFloat:
a094f6
-      tp = init_type (TYPE_CODE_FLT,
a094f6
-		      gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT, 0,
a094f6
-		      "float", objfile);
a094f6
+      tp = init_float_type (objfile, gdbarch_float_bit (gdbarch),
a094f6
+			    "float", NULL);
a094f6
       break;
a094f6
 
a094f6
     case btDouble:
a094f6
-      tp = init_type (TYPE_CODE_FLT,
a094f6
-		      gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT, 0,
a094f6
-		      "double", objfile);
a094f6
+      tp = init_float_type (objfile, gdbarch_double_bit (gdbarch),
a094f6
+			    "double", NULL);
a094f6
       break;
a094f6
 
a094f6
     case btComplex:
a094f6
-      tp = init_type (TYPE_CODE_COMPLEX,
a094f6
-		      2 * gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT, 0,
a094f6
-		      "complex", objfile);
a094f6
-      TYPE_TARGET_TYPE (tp) = basic_type (btFloat, objfile);
a094f6
+      tp = init_complex_type (objfile, "complex",
a094f6
+			      basic_type (btFloat, objfile));
a094f6
       break;
a094f6
 
a094f6
     case btDComplex:
a094f6
-      tp = init_type (TYPE_CODE_COMPLEX,
a094f6
-		      2 * gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT, 0,
a094f6
-		      "double complex", objfile);
a094f6
-      TYPE_TARGET_TYPE (tp) = basic_type (btDouble, objfile);
a094f6
+      tp = init_complex_type (objfile, "double complex",
a094f6
+			      basic_type (btFloat, objfile));
a094f6
       break;
a094f6
 
a094f6
     case btFixedDec:
a094f6
       /* We use TYPE_CODE_INT to print these as integers.  Does this do any
a094f6
 	 good?  Would we be better off with TYPE_CODE_ERROR?  Should
a094f6
 	 TYPE_CODE_ERROR print things in hex if it knows the size?  */
a094f6
-      tp = init_type (TYPE_CODE_INT,
a094f6
-		      gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT, 0,
a094f6
-		      "fixed decimal", objfile);
a094f6
+      tp = init_integer_type (objfile, gdbarch_int_bit (gdbarch), 0,
a094f6
+			      "fixed decimal");
a094f6
       break;
a094f6
 
a094f6
     case btFloatDec:
a094f6
-      tp = init_type (TYPE_CODE_ERROR,
a094f6
-		      gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT, 0,
a094f6
-		      "floating decimal", objfile);
a094f6
+      tp = init_type (objfile, TYPE_CODE_ERROR,
a094f6
+		      gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
a094f6
+		      "floating decimal");
a094f6
       break;
a094f6
 
a094f6
     case btString:
a094f6
       /* Is a "string" the way btString means it the same as TYPE_CODE_STRING?
a094f6
 	 FIXME.  */
a094f6
-      tp = init_type (TYPE_CODE_STRING, 1, 0,
a094f6
-		      "string", objfile);
a094f6
+      tp = init_type (objfile, TYPE_CODE_STRING, 1, "string");
a094f6
       break;
a094f6
 
a094f6
     case btVoid:
a094f6
@@ -1472,39 +1455,32 @@
a094f6
       break;
a094f6
 
a094f6
     case btLong64:
a094f6
-      tp = init_type (TYPE_CODE_INT, 8, 0,
a094f6
-		      "long", objfile);
a094f6
+      tp = init_integer_type (objfile, 64, 0, "long");
a094f6
       break;
a094f6
 
a094f6
     case btULong64:
a094f6
-      tp = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
a094f6
-		      "unsigned long", objfile);
a094f6
+      tp = init_integer_type (objfile, 64, 1, "unsigned long");
a094f6
       break;
a094f6
 
a094f6
     case btLongLong64:
a094f6
-      tp = init_type (TYPE_CODE_INT, 8, 0,
a094f6
-		      "long long", objfile);
a094f6
+      tp = init_integer_type (objfile, 64, 0, "long long");
a094f6
       break;
a094f6
 
a094f6
     case btULongLong64:
a094f6
-      tp = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
a094f6
-		      "unsigned long long", objfile);
a094f6
+      tp = init_integer_type (objfile, 64, 1, "unsigned long long");
a094f6
       break;
a094f6
 
a094f6
     case btAdr64:
a094f6
-      tp = init_type (TYPE_CODE_PTR, 8, TYPE_FLAG_UNSIGNED,
a094f6
-		      "adr_64", objfile);
a094f6
-      TYPE_TARGET_TYPE (tp) = objfile_type (objfile)->builtin_void;
a094f6
+      tp = init_pointer_type (objfile, 64, "adr_64",
a094f6
+			      objfile_type (objfile)->builtin_void);
a094f6
       break;
a094f6
 
a094f6
     case btInt64:
a094f6
-      tp = init_type (TYPE_CODE_INT, 8, 0,
a094f6
-		      "int", objfile);
a094f6
+      tp = init_integer_type (objfile, 64, 0, "int");
a094f6
       break;
a094f6
 
a094f6
     case btUInt64:
a094f6
-      tp = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
a094f6
-		      "unsigned int", objfile);
a094f6
+      tp = init_integer_type (objfile, 64, 1, "unsigned int");
a094f6
       break;
a094f6
 
a094f6
     default:
a094f6
@@ -1656,7 +1632,7 @@
a094f6
       /* Try to cross reference this type, build new type on failure.  */
a094f6
       ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
a094f6
       if (tp == (struct type *) NULL)
a094f6
-	tp = init_type (type_code, 0, 0, (char *) NULL, mdebugread_objfile);
a094f6
+	tp = init_type (mdebugread_objfile, type_code, 0, NULL);
a094f6
 
a094f6
       /* DEC c89 produces cross references to qualified aggregate types,
a094f6
          dereference them.  */
a094f6
@@ -1715,7 +1691,7 @@
a094f6
       /* Try to cross reference this type, build new type on failure.  */
a094f6
       ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
a094f6
       if (tp == (struct type *) NULL)
a094f6
-	tp = init_type (type_code, 0, 0, (char *) NULL, mdebugread_objfile);
a094f6
+	tp = init_type (mdebugread_objfile, type_code, 0, NULL);
a094f6
 
a094f6
       /* Make sure that TYPE_CODE(tp) has an expected type code.
a094f6
          Any type may be returned from cross_ref if file indirect entries
a094f6
@@ -4433,13 +4409,13 @@
a094f6
     }
a094f6
 
a094f6
   /* mips cc uses a rf of -1 for opaque struct definitions.
a094f6
-     Set TYPE_FLAG_STUB for these types so that check_typedef will
a094f6
+     Set TYPE_STUB for these types so that check_typedef will
a094f6
      resolve them if the struct gets defined in another compilation unit.  */
a094f6
   if (rf == -1)
a094f6
     {
a094f6
       *pname = "<undefined>";
a094f6
-      *tpp = init_type (type_code, 0, TYPE_FLAG_STUB,
a094f6
-			(char *) NULL, mdebugread_objfile);
a094f6
+      *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
a094f6
+      TYPE_STUB (*tpp) = 1;
a094f6
       return result;
a094f6
     }
a094f6
 
a094f6
@@ -4525,8 +4501,7 @@
a094f6
 	  switch (tir.bt)
a094f6
 	    {
a094f6
 	    case btVoid:
a094f6
-	      *tpp = init_type (type_code, 0, 0, (char *) NULL,
a094f6
-				mdebugread_objfile);
a094f6
+	      *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
a094f6
 	      *pname = "<undefined>";
a094f6
 	      break;
a094f6
 
a094f6
@@ -4561,8 +4536,7 @@
a094f6
 	      complaint (&symfile_complaints,
a094f6
 			 _("illegal bt %d in forward typedef for %s"), tir.bt,
a094f6
 			 sym_name);
a094f6
-	      *tpp = init_type (type_code, 0, 0, (char *) NULL,
a094f6
-				mdebugread_objfile);
a094f6
+	      *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
a094f6
 	      break;
a094f6
 	    }
a094f6
 	  return result;
a094f6
@@ -4590,7 +4564,7 @@
a094f6
 	     has not been parsed yet.
a094f6
 	     Initialize the type only, it will be filled in when
a094f6
 	     it's definition is parsed.  */
a094f6
-	  *tpp = init_type (type_code, 0, 0, (char *) NULL, mdebugread_objfile);
a094f6
+	  *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
a094f6
 	}
a094f6
       add_pending (fh, esh, *tpp);
a094f6
     }
a094f6
Index: gdb-7.6.1/gdb/stabsread.c
a094f6
===================================================================
a094f6
--- gdb-7.6.1.orig/gdb/stabsread.c	2017-03-11 21:42:28.099262777 +0100
a094f6
+++ gdb-7.6.1/gdb/stabsread.c	2017-03-11 21:45:39.102565532 +0100
a094f6
@@ -2098,130 +2098,115 @@
a094f6
          is other than 32 bits, then it should use a new negative type
a094f6
          number (or avoid negative type numbers for that case).
a094f6
          See stabs.texinfo.  */
a094f6
-      rettype = init_type (TYPE_CODE_INT, 4, 0, "int", objfile);
a094f6
+      rettype = init_integer_type (objfile, 32, 0, "int");
a094f6
       break;
a094f6
     case 2:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 1, 0, "char", objfile);
a094f6
+      rettype = init_integer_type (objfile, 8, 0, "char");
a094f6
       break;
a094f6
     case 3:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 2, 0, "short", objfile);
a094f6
+      rettype = init_integer_type (objfile, 16, 0, "short");
a094f6
       break;
a094f6
     case 4:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 4, 0, "long", objfile);
a094f6
+      rettype = init_integer_type (objfile, 32, 0, "long");
a094f6
       break;
a094f6
     case 5:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED,
a094f6
-			   "unsigned char", objfile);
a094f6
+      rettype = init_integer_type (objfile, 8, 1, "unsigned char");
a094f6
       break;
a094f6
     case 6:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", objfile);
a094f6
+      rettype = init_integer_type (objfile, 8, 0, "signed char");
a094f6
       break;
a094f6
     case 7:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED,
a094f6
-			   "unsigned short", objfile);
a094f6
+      rettype = init_integer_type (objfile, 16, 1, "unsigned short");
a094f6
       break;
a094f6
     case 8:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
a094f6
-			   "unsigned int", objfile);
a094f6
+      rettype = init_integer_type (objfile, 32, 1, "unsigned int");
a094f6
       break;
a094f6
     case 9:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
a094f6
-			   "unsigned", objfile);
a094f6
+      rettype = init_integer_type (objfile, 32, 1, "unsigned");
a094f6
       break;
a094f6
     case 10:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
a094f6
-			   "unsigned long", objfile);
a094f6
+      rettype = init_integer_type (objfile, 32, 1, "unsigned long");
a094f6
       break;
a094f6
     case 11:
a094f6
-      rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", objfile);
a094f6
+      rettype = init_type (objfile, TYPE_CODE_VOID, 1, "void");
a094f6
       break;
a094f6
     case 12:
a094f6
       /* IEEE single precision (32 bit).  */
a094f6
-      rettype = init_type (TYPE_CODE_FLT, 4, 0, "float", objfile);
a094f6
+      rettype = init_float_type (objfile, 32, "float", NULL);
a094f6
       break;
a094f6
     case 13:
a094f6
       /* IEEE double precision (64 bit).  */
a094f6
-      rettype = init_type (TYPE_CODE_FLT, 8, 0, "double", objfile);
a094f6
+      rettype = init_float_type (objfile, 64, "double", NULL);
a094f6
       break;
a094f6
     case 14:
a094f6
       /* This is an IEEE double on the RS/6000, and different machines with
a094f6
          different sizes for "long double" should use different negative
a094f6
          type numbers.  See stabs.texinfo.  */
a094f6
-      rettype = init_type (TYPE_CODE_FLT, 8, 0, "long double", objfile);
a094f6
+      rettype = init_float_type (objfile, 64, "long double", NULL);
a094f6
       break;
a094f6
     case 15:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", objfile);
a094f6
+      rettype = init_integer_type (objfile, 32, 0, "integer");
a094f6
       break;
a094f6
     case 16:
a094f6
-      rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
a094f6
-			   "boolean", objfile);
a094f6
+      rettype = init_boolean_type (objfile, 32, 1, "boolean");
a094f6
       break;
a094f6
     case 17:
a094f6
-      rettype = init_type (TYPE_CODE_FLT, 4, 0, "short real", objfile);
a094f6
+      rettype = init_float_type (objfile, 32, "short real", NULL);
a094f6
       break;
a094f6
     case 18:
a094f6
-      rettype = init_type (TYPE_CODE_FLT, 8, 0, "real", objfile);
a094f6
+      rettype = init_float_type (objfile, 64, "real", NULL);
a094f6
       break;
a094f6
     case 19:
a094f6
-      rettype = init_type (TYPE_CODE_ERROR, 0, 0, "stringptr", objfile);
a094f6
+      rettype = init_type (objfile, TYPE_CODE_ERROR, 0, "stringptr");
a094f6
       break;
a094f6
     case 20:
a094f6
-      rettype = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED,
a094f6
-			   "character", objfile);
a094f6
+      rettype = init_character_type (objfile, 8, 1, "character");
a094f6
       break;
a094f6
     case 21:
a094f6
-      rettype = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED,
a094f6
-			   "logical*1", objfile);
a094f6
+      rettype = init_boolean_type (objfile, 8, 1, "logical*1");
a094f6
       break;
a094f6
     case 22:
a094f6
-      rettype = init_type (TYPE_CODE_BOOL, 2, TYPE_FLAG_UNSIGNED,
a094f6
-			   "logical*2", objfile);
a094f6
+      rettype = init_boolean_type (objfile, 16, 1, "logical*2");
a094f6
       break;
a094f6
     case 23:
a094f6
-      rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
a094f6
-			   "logical*4", objfile);
a094f6
+      rettype = init_boolean_type (objfile, 32, 1, "logical*4");
a094f6
       break;
a094f6
     case 24:
a094f6
-      rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
a094f6
-			   "logical", objfile);
a094f6
+      rettype = init_boolean_type (objfile, 32, 1, "logical");
a094f6
       break;
a094f6
     case 25:
a094f6
       /* Complex type consisting of two IEEE single precision values.  */
a094f6
-      rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", objfile);
a094f6
-      TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 4, 0, "float",
a094f6
-					      objfile);
a094f6
+      rettype = init_complex_type (objfile, "complex",
a094f6
+				   rs6000_builtin_type (12, objfile));
a094f6
       break;
a094f6
     case 26:
a094f6
       /* Complex type consisting of two IEEE double precision values.  */
a094f6
-      rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL);
a094f6
-      TYPE_TARGET_TYPE (rettype) = init_type (TYPE_CODE_FLT, 8, 0, "double",
a094f6
-					      objfile);
a094f6
+      rettype = init_complex_type (objfile, "double complex",
a094f6
+				   rs6000_builtin_type (13, objfile));
a094f6
       break;
a094f6
     case 27:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", objfile);
a094f6
+      rettype = init_integer_type (objfile, 8, 0, "integer*1");
a094f6
       break;
a094f6
     case 28:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 2, 0, "integer*2", objfile);
a094f6
+      rettype = init_integer_type (objfile, 16, 0, "integer*2");
a094f6
       break;
a094f6
     case 29:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 4, 0, "integer*4", objfile);
a094f6
+      rettype = init_integer_type (objfile, 32, 0, "integer*4");
a094f6
       break;
a094f6
     case 30:
a094f6
-      rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", objfile);
a094f6
+      rettype = init_character_type (objfile, 16, 0, "wchar");
a094f6
       break;
a094f6
     case 31:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", objfile);
a094f6
+      rettype = init_integer_type (objfile, 64, 0, "long long");
a094f6
       break;
a094f6
     case 32:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
a094f6
-			   "unsigned long long", objfile);
a094f6
+      rettype = init_integer_type (objfile, 64, 1, "unsigned long long");
a094f6
       break;
a094f6
     case 33:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
a094f6
-			   "logical*8", objfile);
a094f6
+      rettype = init_integer_type (objfile, 64, 1, "logical*8");
a094f6
       break;
a094f6
     case 34:
a094f6
-      rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", objfile);
a094f6
+      rettype = init_integer_type (objfile, 64, 0, "integer*8");
a094f6
       break;
a094f6
     }
a094f6
   negative_types[-typenum] = rettype;
a094f6
@@ -3757,16 +3742,16 @@
a094f6
 {
a094f6
   int type_bits;
a094f6
   int nbits;
a094f6
-  int signed_type;
a094f6
-  enum type_code code = TYPE_CODE_INT;
a094f6
+  int unsigned_type;
a094f6
+  int boolean_type = 0;
a094f6
 
a094f6
   switch (**pp)
a094f6
     {
a094f6
     case 's':
a094f6
-      signed_type = 1;
a094f6
+      unsigned_type = 0;
a094f6
       break;
a094f6
     case 'u':
a094f6
-      signed_type = 0;
a094f6
+      unsigned_type = 1;
a094f6
       break;
a094f6
     default:
a094f6
       return error_type (pp, objfile);
a094f6
@@ -3783,7 +3768,7 @@
a094f6
     (*pp)++;
a094f6
   else if (**pp == 'b')
a094f6
     {
a094f6
-      code = TYPE_CODE_BOOL;
a094f6
+      boolean_type = 1;
a094f6
       (*pp)++;
a094f6
     }
a094f6
 
a094f6
@@ -3814,14 +3799,17 @@
a094f6
     ++(*pp);
a094f6
 
a094f6
   if (type_bits == 0)
a094f6
-    return init_type (TYPE_CODE_VOID, 1,
a094f6
-		      signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
a094f6
-		      objfile);
a094f6
+    {
a094f6
+      struct type *type = init_type (objfile, TYPE_CODE_VOID, 1, NULL);
a094f6
+      if (unsigned_type)
a094f6
+        TYPE_UNSIGNED (type) = 1;
a094f6
+      return type;
a094f6
+    }
a094f6
+
a094f6
+  if (boolean_type)
a094f6
+    return init_boolean_type (objfile, type_bits, unsigned_type, NULL);
a094f6
   else
a094f6
-    return init_type (code,
a094f6
-		      type_bits / TARGET_CHAR_BIT,
a094f6
-		      signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
a094f6
-		      objfile);
a094f6
+    return init_integer_type (objfile, type_bits, unsigned_type, NULL);
a094f6
 }
a094f6
 
a094f6
 static struct type *
a094f6
@@ -3843,16 +3831,16 @@
a094f6
   if (nbits != 0)
a094f6
     return error_type (pp, objfile);
a094f6
 
a094f6
+  nbits = nbytes * TARGET_CHAR_BIT;
a094f6
+
a094f6
   if (details == NF_COMPLEX || details == NF_COMPLEX16
a094f6
       || details == NF_COMPLEX32)
a094f6
     {
a094f6
-      rettype = init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile);
a094f6
-      TYPE_TARGET_TYPE (rettype)
a094f6
-	= init_type (TYPE_CODE_FLT, nbytes / 2, 0, NULL, objfile);
a094f6
-      return rettype;
a094f6
+      rettype = init_float_type (objfile, nbits / 2, NULL, NULL);
a094f6
+      return init_complex_type (objfile, NULL, rettype);
a094f6
     }
a094f6
 
a094f6
-  return init_type (TYPE_CODE_FLT, nbytes, 0, NULL, objfile);
a094f6
+  return init_float_type (objfile, nbits, NULL, NULL);
a094f6
 }
a094f6
 
a094f6
 /* Read a number from the string pointed to by *PP.
a094f6
@@ -4115,18 +4103,14 @@
a094f6
 	}
a094f6
 
a094f6
       if (got_signed || got_unsigned)
a094f6
-	{
a094f6
-	  return init_type (TYPE_CODE_INT, nbits / TARGET_CHAR_BIT,
a094f6
-			    got_unsigned ? TYPE_FLAG_UNSIGNED : 0, NULL,
a094f6
-			    objfile);
a094f6
-	}
a094f6
+	return init_integer_type (objfile, nbits, got_unsigned, NULL);
a094f6
       else
a094f6
 	return error_type (pp, objfile);
a094f6
     }
a094f6
 
a094f6
   /* A type defined as a subrange of itself, with bounds both 0, is void.  */
a094f6
   if (self_subrange && n2 == 0 && n3 == 0)
a094f6
-    return init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
a094f6
+    return init_type (objfile, TYPE_CODE_VOID, 1, NULL);
a094f6
 
a094f6
   /* If n3 is zero and n2 is positive, we want a floating type, and n2
a094f6
      is the width in bytes.
a094f6
@@ -4143,16 +4127,10 @@
a094f6
   if (n3 == 0 && n2 > 0)
a094f6
     {
a094f6
       struct type *float_type
a094f6
-	= init_type (TYPE_CODE_FLT, n2, 0, NULL, objfile);
a094f6
+	= init_float_type (objfile, n2 * TARGET_CHAR_BIT, NULL, NULL);
a094f6
 
a094f6
       if (self_subrange)
a094f6
-	{
a094f6
-	  struct type *complex_type = 
a094f6
-	    init_type (TYPE_CODE_COMPLEX, 2 * n2, 0, NULL, objfile);
a094f6
-
a094f6
-	  TYPE_TARGET_TYPE (complex_type) = float_type;
a094f6
-	  return complex_type;
a094f6
-	}
a094f6
+	return init_complex_type (objfile, NULL, float_type);
a094f6
       else
a094f6
 	return float_type;
a094f6
     }
a094f6
@@ -4171,15 +4149,17 @@
a094f6
 	  bits = gdbarch_int_bit (gdbarch);
a094f6
 	}
a094f6
 
a094f6
-      return init_type (TYPE_CODE_INT, bits / TARGET_CHAR_BIT,
a094f6
-			TYPE_FLAG_UNSIGNED, NULL, objfile);
a094f6
+      return init_integer_type (objfile, bits, 1, NULL);
a094f6
     }
a094f6
 
a094f6
   /* Special case: char is defined (Who knows why) as a subrange of
a094f6
      itself with range 0-127.  */
a094f6
   else if (self_subrange && n2 == 0 && n3 == 127)
a094f6
-    return init_type (TYPE_CODE_INT, 1, TYPE_FLAG_NOSIGN, NULL, objfile);
a094f6
-
a094f6
+    {
a094f6
+      struct type *type = init_integer_type (objfile, 1, 0, NULL);
a094f6
+      TYPE_NOSIGN (type) = 1;
a094f6
+      return type;
a094f6
+    }
a094f6
   /* We used to do this only for subrange of self or subrange of int.  */
a094f6
   else if (n2 == 0)
a094f6
     {
a094f6
@@ -4189,8 +4169,7 @@
a094f6
 
a094f6
       if (n3 < 0)
a094f6
 	/* n3 actually gives the size.  */
a094f6
-	return init_type (TYPE_CODE_INT, -n3, TYPE_FLAG_UNSIGNED,
a094f6
-			  NULL, objfile);
a094f6
+	return init_integer_type (objfile, -n3 * TARGET_CHAR_BIT, 1, NULL);
a094f6
 
a094f6
       /* Is n3 == 2**(8n)-1 for some integer n?  Then it's an
a094f6
          unsigned n-byte integer.  But do require n to be a power of
a094f6
@@ -4204,8 +4183,7 @@
a094f6
 	  bits >>= 8;
a094f6
 	if (bits == 0
a094f6
 	    && ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */
a094f6
-	  return init_type (TYPE_CODE_INT, bytes, TYPE_FLAG_UNSIGNED, NULL,
a094f6
-			    objfile);
a094f6
+	  return init_integer_type (objfile, bytes * TARGET_CHAR_BIT, 1, NULL);
a094f6
       }
a094f6
     }
a094f6
   /* I think this is for Convex "long long".  Since I don't know whether
a094f6
@@ -4215,15 +4193,15 @@
a094f6
 	   && (self_subrange
a094f6
 	       || n2 == -gdbarch_long_long_bit
a094f6
 			  (gdbarch) / TARGET_CHAR_BIT))
a094f6
-    return init_type (TYPE_CODE_INT, -n2, 0, NULL, objfile);
a094f6
+    return init_integer_type (objfile, -n2 * TARGET_CHAR_BIT, 0, NULL);
a094f6
   else if (n2 == -n3 - 1)
a094f6
     {
a094f6
       if (n3 == 0x7f)
a094f6
-	return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
a094f6
+	return init_integer_type (objfile, 8, 0, NULL);
a094f6
       if (n3 == 0x7fff)
a094f6
-	return init_type (TYPE_CODE_INT, 2, 0, NULL, objfile);
a094f6
+	return init_integer_type (objfile, 16, 0, NULL);
a094f6
       if (n3 == 0x7fffffff)
a094f6
-	return init_type (TYPE_CODE_INT, 4, 0, NULL, objfile);
a094f6
+	return init_integer_type (objfile, 32, 0, NULL);
a094f6
     }
a094f6
 
a094f6
   /* We have a real range type on our hands.  Allocate space and