strcpy (uns, "unsigned ");
strcpy (uns + 9, name);
- return lookup_typename (language, gdbarch, uns, (struct block *) NULL, 0);
+ return lookup_typename (language, gdbarch, uns, NULL, 0);
}
struct type *
strcpy (uns, "signed ");
strcpy (uns + 7, name);
- t = lookup_typename (language, gdbarch, uns, (struct block *) NULL, 1);
+ t = lookup_typename (language, gdbarch, uns, NULL, 1);
/* If we don't find "signed FOO" just try again with plain "FOO". */
if (t != NULL)
return t;
- return lookup_typename (language, gdbarch, name, (struct block *) NULL, 0);
+ return lookup_typename (language, gdbarch, name, NULL, 0);
}
/* Lookup a structure type named "struct NAME",
return (SYMBOL_TYPE (sym));
}
-/* 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. */
+/* See gdbtypes.h. */
-struct type *
-lookup_struct_elt_type (struct type *type, const char *name, int noerr)
+struct_elt
+lookup_struct_elt (struct type *type, const char *name, int noerr)
{
int i;
type_name.c_str ());
}
-#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. */
- {
- char *type_name;
-
- type_name = TYPE_NAME (type);
- if (type_name != NULL && strcmp (type_name, name) == 0)
- return type;
- }
-#endif
-
for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
{
- return TYPE_FIELD_TYPE (type, i);
+ return {&TYPE_FIELD (type, i), TYPE_FIELD_BITPOS (type, i)};
}
else if (!t_field_name || *t_field_name == '\0')
{
- struct type *subtype
- = lookup_struct_elt_type (TYPE_FIELD_TYPE (type, i), name, 1);
-
- if (subtype != NULL)
- return subtype;
+ struct_elt elt
+ = lookup_struct_elt (TYPE_FIELD_TYPE (type, i), name, 1);
+ if (elt.field != NULL)
+ {
+ elt.offset += TYPE_FIELD_BITPOS (type, i);
+ return elt;
+ }
}
}
/* OK, it's not in this class. Recursively check the baseclasses. */
for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
{
- struct type *t;
-
- t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, 1);
- if (t != NULL)
- {
- return t;
- }
+ struct_elt elt = lookup_struct_elt (TYPE_BASECLASS (type, i), name, 1);
+ if (elt.field != NULL)
+ return elt;
}
if (noerr)
- {
- return NULL;
- }
+ return {nullptr, 0};
std::string type_name = type_to_string (type);
error (_("Type %s has no component named %s."), type_name.c_str (), name);
}
+/* See gdbtypes.h. */
+
+struct type *
+lookup_struct_elt_type (struct type *type, const char *name, int noerr)
+{
+ struct_elt elt = lookup_struct_elt (type, name, noerr);
+ if (elt.field != NULL)
+ return FIELD_TYPE (*elt.field);
+ else
+ return NULL;
+}
+
/* Store in *MAX the largest number representable by unsigned integer type
TYPE. */
gdb_stderr = &null_stream;
/* Call parse_and_eval_type() without fear of longjmp()s. */
- TRY
+ try
{
type = parse_and_eval_type (p, length);
}
- CATCH (except, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &except)
{
type = builtin_type (gdbarch)->builtin_void;
}
- END_CATCH
/* Stop suppressing error messages. */
gdb_stderr = saved_gdb_stderr;
}
}
+/* rank_one_type helper for when PARM's type code is TYPE_CODE_SET. */
+
+static struct rank
+rank_one_type_parm_set (struct type *parm, struct type *arg, struct value *value)
+{
+ switch (TYPE_CODE (arg))
+ {
+ /* Not in C++ */
+ case TYPE_CODE_SET:
+ return rank_one_type (TYPE_FIELD_TYPE (parm, 0),
+ TYPE_FIELD_TYPE (arg, 0), NULL);
+ default:
+ return INCOMPATIBLE_TYPE_BADNESS;
+ }
+}
+
/* Compare one type (PARM) for compatibility with another (ARG).
* PARM is intended to be the parameter type of a function; and
* ARG is the supplied argument's type. This function tests if
return rank_one_type_parm_complex (parm, arg, value);
case TYPE_CODE_STRUCT:
return rank_one_type_parm_struct (parm, arg, value);
- case TYPE_CODE_UNION:
- switch (TYPE_CODE (arg))
- {
- case TYPE_CODE_UNION:
- default:
- return INCOMPATIBLE_TYPE_BADNESS;
- }
- break;
- case TYPE_CODE_MEMBERPTR:
- switch (TYPE_CODE (arg))
- {
- default:
- return INCOMPATIBLE_TYPE_BADNESS;
- }
- break;
- case TYPE_CODE_METHOD:
- switch (TYPE_CODE (arg))
- {
-
- default:
- return INCOMPATIBLE_TYPE_BADNESS;
- }
- break;
- case TYPE_CODE_REF:
- switch (TYPE_CODE (arg))
- {
-
- default:
- return INCOMPATIBLE_TYPE_BADNESS;
- }
-
- break;
case TYPE_CODE_SET:
- switch (TYPE_CODE (arg))
- {
- /* Not in C++ */
- case TYPE_CODE_SET:
- return rank_one_type (TYPE_FIELD_TYPE (parm, 0),
- TYPE_FIELD_TYPE (arg, 0), NULL);
- default:
- return INCOMPATIBLE_TYPE_BADNESS;
- }
- break;
- case TYPE_CODE_VOID:
+ return rank_one_type_parm_set (parm, arg, value);
default:
return INCOMPATIBLE_TYPE_BADNESS;
} /* switch (TYPE_CODE (arg)) */
break;
}
puts_filtered ("\n");
- printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
+ printfi_filtered (spaces, "length %s\n", pulongest (TYPE_LENGTH (type)));
if (TYPE_OBJFILE_OWNED (type))
{
printfi_filtered (spaces, "objfile ");