* symtab.c (find_pc_symtab): some object file formats, notably mips,
[deliverable/binutils-gdb.git] / gdb / gdbtypes.c
index 525c515def02c298b14b2cbeb76d7c8eaf62ac8b..9bcdec00467a0e30a7f5e73cfcb1096fc84cad58 100644 (file)
@@ -314,8 +314,10 @@ allocate_stub_method (type)
 }
 
 /* Create a range type using either a blank type supplied in RESULT_TYPE,
-   or creating a new type.  Indices will be of type INDEX_TYPE, and will
-   range from LOW_BOUND to HIGH_BOUND, inclusive.
+   or creating a new type, inheriting the objfile from INDEX_TYPE.
+
+   Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
+   HIGH_BOUND, inclusive.
 
    FIXME:  Maybe we should check the TYPE_CODE of RESULT_TYPE to make
    sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
@@ -348,8 +350,10 @@ create_range_type (result_type, index_type, low_bound, high_bound)
 
 
 /* Create an array type using either a blank type supplied in RESULT_TYPE,
-   or creating a new type.  Elements will be of type ELEMENT_TYPE, the
-   indices will be of type RANGE_TYPE.
+   or creating a new type, inheriting the objfile from RANGE_TYPE.
+
+   Elements will be of type ELEMENT_TYPE, the indices will be of type
+   RANGE_TYPE.
 
    FIXME:  Maybe we should check the TYPE_CODE of RESULT_TYPE to make
    sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
@@ -374,7 +378,7 @@ create_array_type (result_type, element_type, range_type)
     }
   if (result_type == NULL)
     {
-      result_type = alloc_type (TYPE_OBJFILE (element_type));
+      result_type = alloc_type (TYPE_OBJFILE (range_type));
     }
   TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
   TYPE_TARGET_TYPE (result_type) = element_type;
@@ -686,9 +690,15 @@ lookup_template_type (name, type, block)
   return (SYMBOL_TYPE (sym));
 }
 
-/* Given a type TYPE, lookup the type of the component of type named
-   NAME.  
-   If NOERR is nonzero, return zero if NAME is not suitably defined.  */
+/* Given a type TYPE, lookup the type of the component of type named NAME.  
+
+   TYPE can be either a struct or union, or a pointer or reference to a struct or
+   union.  If it is a pointer or reference, its target type is automatically used.
+   Thus '.' and '->' are interchangable, as specified for the definitions of the
+   expression element types STRUCTOP_STRUCT and STRUCTOP_PTR.
+
+   If NOERR is nonzero, return zero if NAME is not suitably defined.
+   If NAME is the name of a baseclass type, return that type.  */
 
 struct type *
 lookup_struct_elt_type (type, name, noerr)
@@ -697,6 +707,7 @@ lookup_struct_elt_type (type, name, noerr)
     int noerr;
 {
   int i;
+  char *typename;
 
   if (TYPE_CODE (type) == TYPE_CODE_PTR ||
       TYPE_CODE (type) == TYPE_CODE_REF)
@@ -714,6 +725,16 @@ lookup_struct_elt_type (type, name, noerr)
 
   check_stub_type (type);
 
+#if 0
+  /* FIXME:  This change put in by Michael seems incorrect for the case where
+     the structure tag name is the same as the member name.  I.E. when doing
+     "ptype bell->bar" for "struct foo { int bar; int foo; } bell;"
+     Disabled by fnf. */
+  typename = type_name_no_tag (type);
+  if (typename != NULL && STREQ (typename, name))
+    return type;
+#endif
+
   for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
     {
       char *t_field_name = TYPE_FIELD_NAME (type, i);
@@ -729,7 +750,7 @@ lookup_struct_elt_type (type, name, noerr)
     {
       struct type *t;
 
-      t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, 0);
+      t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, noerr);
       if (t != NULL)
        {
          return t;
@@ -761,7 +782,10 @@ fill_in_vptr_fieldno (type)
   if (TYPE_VPTR_FIELDNO (type) < 0)
     {
       int i;
-      for (i = 1; i < TYPE_N_BASECLASSES (type); i++)
+
+      /* We must start at zero in case the first (and only) baseclass is
+        virtual (and hence we cannot share the table pointer).  */
+      for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
        {
          fill_in_vptr_fieldno (TYPE_BASECLASS (type, i));
          if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i)) >= 0)
This page took 0.024854 seconds and 4 git commands to generate.