forked from Imagelibrary/binutils-gdb
Record and output access specifiers for nested typedefs
We currently do not record access information for typedefs defined inside
classes. Consider:
struct foo
{
typedef int PUBLIC;
private:
typedef int PRIVATE;
PRIVATE b;
};
(gdb) ptype foo
type = struct foo {
private:
PRIVATE b;
typedef int PRIVATE;
typedef int PUBLIC;
}
This patch fixes this:
(gdb) ptype foo
type = struct foo {
private:
PRIVATE b;
typedef int PRIVATE;
public:
typedef int PUBLIC;
}
gdb/ChangeLog:
* c-typeprint.c (enum access_specifier): Moved here from
c_type_print_base.
(output_access_specifier): New function.
(c_type_print_base): Consider typedefs when assessing
whether access labels are needed.
Use output_access_specifier as needed.
Output access specifier for typedefs, if needed.
* dwarf2read.c (dwarf2_add_typedef): Record DW_AT_accessibility.
* gdbtypes.h (struct typedef_field) <is_protected, is_private>: New
fields.
(TYPE_TYPEDEF_FIELD_PROTECTED, TYPE_TYPEDEF_FIELD_PRIVATE): New
accessor macros.
gdb/testsuite/ChangeLog:
* gdb.cp/classes.cc (class_with_typedefs, class_with_public_typedef)
(class_with_protected_typedef, class_with_private_typedef)
(struct_with_public_typedef, struct_with_protected_typedef)
(struct_with_private_typedef): New classes/structs.
* gdb.cp/classes.exp (test_ptype_class_objects): Add tests for
typedefs and access specifiers.
This commit is contained in:
@@ -873,6 +873,12 @@ struct typedef_field
|
||||
/* * Type this typedef named NAME represents. */
|
||||
|
||||
struct type *type;
|
||||
|
||||
/* * True if this field was declared protected, false otherwise. */
|
||||
unsigned int is_protected : 1;
|
||||
|
||||
/* * True if this field was declared private, false otherwise. */
|
||||
unsigned int is_private : 1;
|
||||
};
|
||||
|
||||
/* * C++ language-specific information for TYPE_CODE_STRUCT and
|
||||
@@ -1402,6 +1408,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
|
||||
#define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
|
||||
#define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
|
||||
|
||||
/* Accessors for typedefs defined by a class. */
|
||||
#define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \
|
||||
TYPE_CPLUS_SPECIFIC (thistype)->typedef_field
|
||||
#define TYPE_TYPEDEF_FIELD(thistype, n) \
|
||||
@@ -1412,6 +1419,10 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
|
||||
TYPE_TYPEDEF_FIELD (thistype, n).type
|
||||
#define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
|
||||
TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
|
||||
#define TYPE_TYPEDEF_FIELD_PROTECTED(thistype, n) \
|
||||
TYPE_TYPEDEF_FIELD (thistype, n).is_protected
|
||||
#define TYPE_TYPEDEF_FIELD_PRIVATE(thistype, n) \
|
||||
TYPE_TYPEDEF_FIELD (thistype, n).is_private
|
||||
|
||||
#define TYPE_IS_OPAQUE(thistype) \
|
||||
(((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) \
|
||||
|
||||
Reference in New Issue
Block a user