+2007-05-17  Joel Brobecker  <brobecker@adacore.com>
+
+       * gdbtypes.c (make_reference_type): Preserve the type chain
+       and set the length of all the variants of the pointer type.
+
 2007-05-17  Joel Brobecker  <brobecker@adacore.com>
 
        * gdbtypes.c (make_pointer_type): Preserve the pointer type chain
 
 {
   struct type *ntype;  /* New type */
   struct objfile *objfile;
+  struct type *chain;
 
   ntype = TYPE_REFERENCE_TYPE (type);
 
     {
       ntype = *typeptr;
       objfile = TYPE_OBJFILE (ntype);
+      chain = TYPE_CHAIN (ntype);
       smash_type (ntype);
+      TYPE_CHAIN (ntype) = chain;
       TYPE_OBJFILE (ntype) = objfile;
     }
 
   if (!TYPE_REFERENCE_TYPE (type))     /* Remember it, if don't have one.  */
     TYPE_REFERENCE_TYPE (type) = ntype;
 
+  /* Update the length of all the other variants of this type.  */
+  chain = TYPE_CHAIN (ntype);
+  while (chain != ntype)
+    {
+      TYPE_LENGTH (chain) = TYPE_LENGTH (ntype);
+      chain = TYPE_CHAIN (chain);
+    }
+
   return ntype;
 }