/* Internal type definitions for GDB.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010
+ 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Cygnus Support, using pieces from other GDB modules.
* volatile modifier.
*/
-#define TYPE_VOLATILE(t) (TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_VOLATILE)
+#define TYPE_VOLATILE(t) \
+ (TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_VOLATILE)
/* Instruction-space delimited type. This is for Harvard architectures
which have separate instruction and data address spaces (and perhaps
union field_location
{
/* Position of this field, counting in bits from start of
- containing structure.
- For gdbarch_bits_big_endian=1 targets, it is the bit offset to the MSB.
- For gdbarch_bits_big_endian=0 targets, it is the bit offset to the LSB.
- For a range bound or enum value, this is the value itself. */
+ containing structure. For gdbarch_bits_big_endian=1
+ targets, it is the bit offset to the MSB. For
+ gdbarch_bits_big_endian=0 targets, it is the bit offset to
+ the LSB. For a range bound or enum value, this is the
+ value itself. */
int bitpos;
struct type *chain;
/* Flags specific to this instance of the type, indicating where
- on the ring we are. */
+ on the ring we are.
+
+ For TYPE_CODE_TYPEDEF the flags of the typedef type should be binary
+ or-ed with the target type, with a special case for address class and
+ space class. For example if this typedef does not specify any new
+ qualifiers, TYPE_INSTANCE_FLAGS is 0 and the instance flags are
+ completely inherited from the target type. No qualifiers can be cleared
+ by the typedef. See also check_typedef. */
int instance_flags;
/* Length of storage for a value of this type. This is what
dynamic. Zero if not yet computed. */
int is_dynamic : 2;
- /* For derived classes, the number of base classes is given by n_baseclasses
- and virtual_field_bits is a bit vector containing one bit per base class.
- If the base class is virtual, the corresponding bit will be set.
+ /* For derived classes, the number of base classes is given by
+ n_baseclasses and virtual_field_bits is a bit vector containing
+ one bit per base class. If the base class is virtual, the
+ corresponding bit will be set.
I.E, given:
class A{};
struct vbase *next; /* next in chain */
};
+/* Struct used to store conversion rankings. */
+struct rank
+ {
+ short rank;
+
+ /* When two conversions are of the same type and therefore have the same
+ rank, subrank is used to differentiate the two.
+ Eg: Two derived-class-pointer to base-class-pointer conversions would
+ both have base pointer conversion rank, but the conversion with the
+ shorter distance to the ancestor is preferable. 'subrank' would be used
+ to reflect that. */
+ short subrank;
+ };
+
/* Struct used for ranking a function for overload resolution */
struct badness_vector
{
int length;
- int *rank;
+ struct rank *rank;
};
/* GNAT Ada-specific information for various Ada types. */
#define INIT_CPLUS_SPECIFIC(type) \
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF, \
- TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type*) &cplus_struct_default)
+ TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type*) \
+ &cplus_struct_default)
#define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
#define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
-#define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) || \
- (TYPE_CODE (thistype) == TYPE_CODE_UNION)) && \
- (TYPE_NFIELDS (thistype) == 0) && \
- (!HAVE_CPLUS_STRUCT (thistype) \
- || TYPE_NFN_FIELDS (thistype) == 0) && \
- (TYPE_STUB (thistype) || !TYPE_STUB_SUPPORTED (thistype)))
+#define TYPE_IS_OPAQUE(thistype) \
+ (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) \
+ || (TYPE_CODE (thistype) == TYPE_CODE_UNION)) \
+ && (TYPE_NFIELDS (thistype) == 0) \
+ && (!HAVE_CPLUS_STRUCT (thistype) \
+ || TYPE_NFN_FIELDS (thistype) == 0) \
+ && (TYPE_STUB (thistype) || !TYPE_STUB_SUPPORTED (thistype)))
/* A helper macro that returns the name of an error type. If the type
has a name, it is used; otherwise, a default is used. */
extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *);
+extern int get_array_bounds (struct type *type, LONGEST *low_bound,
+ LONGEST *high_bound);
+
extern int class_types_same_p (const struct type *, const struct type *);
extern int is_ancestor (struct type *, struct type *);
#define LENGTH_MATCH(bv) ((bv)->rank[0])
/* Badness if parameter list length doesn't match arg list length */
-#define LENGTH_MISMATCH_BADNESS 100
+extern const struct rank LENGTH_MISMATCH_BADNESS;
+
/* Dummy badness value for nonexistent parameter positions */
-#define TOO_FEW_PARAMS_BADNESS 100
+extern const struct rank TOO_FEW_PARAMS_BADNESS;
/* Badness if no conversion among types */
-#define INCOMPATIBLE_TYPE_BADNESS 100
+extern const struct rank INCOMPATIBLE_TYPE_BADNESS;
+
+/* Badness of an exact match. */
+extern const struct rank EXACT_MATCH_BADNESS;
/* Badness of integral promotion */
-#define INTEGER_PROMOTION_BADNESS 1
+extern const struct rank INTEGER_PROMOTION_BADNESS;
/* Badness of floating promotion */
-#define FLOAT_PROMOTION_BADNESS 1
+extern const struct rank FLOAT_PROMOTION_BADNESS;
+/* Badness of converting a derived class pointer
+ to a base class pointer. */
+extern const struct rank BASE_PTR_CONVERSION_BADNESS;
/* Badness of integral conversion */
-#define INTEGER_CONVERSION_BADNESS 2
+extern const struct rank INTEGER_CONVERSION_BADNESS;
/* Badness of floating conversion */
-#define FLOAT_CONVERSION_BADNESS 2
+extern const struct rank FLOAT_CONVERSION_BADNESS;
/* Badness of integer<->floating conversions */
-#define INT_FLOAT_CONVERSION_BADNESS 2
-/* Badness of converting to a boolean */
-#define BOOLEAN_CONVERSION_BADNESS 2
-/* Badness of pointer conversion */
-#define POINTER_CONVERSION_BADNESS 2
+extern const struct rank INT_FLOAT_CONVERSION_BADNESS;
/* Badness of conversion of pointer to void pointer */
-#define VOID_PTR_CONVERSION_BADNESS 2
+extern const struct rank VOID_PTR_CONVERSION_BADNESS;
+/* Badness of conversion of pointer to boolean. */
+extern const struct rank BOOL_PTR_CONVERSION_BADNESS;
/* Badness of converting derived to base class */
-#define BASE_CONVERSION_BADNESS 2
+extern const struct rank BASE_CONVERSION_BADNESS;
/* Badness of converting from non-reference to reference */
-#define REFERENCE_CONVERSION_BADNESS 2
+extern const struct rank REFERENCE_CONVERSION_BADNESS;
/* Non-standard conversions allowed by the debugger */
/* Converting a pointer to an int is usually OK */
-#define NS_POINTER_CONVERSION_BADNESS 10
+extern const struct rank NS_POINTER_CONVERSION_BADNESS;
+
+extern struct rank sum_ranks (struct rank a, struct rank b);
+extern int compare_ranks (struct rank a, struct rank b);
extern int compare_badness (struct badness_vector *, struct badness_vector *);
extern struct badness_vector *rank_function (struct type **, int,
struct type **, int);
-extern int rank_one_type (struct type *, struct type *);
+extern struct rank rank_one_type (struct type *, struct type *);
extern void recursive_dump_type (struct type *, int);