diff options
author | Keith Seitz <keiths@redhat.com> | 2017-10-16 17:19:29 -0700 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2017-10-16 17:19:29 -0700 |
commit | c191a6875b118fce30e7dc4d9e4bd20eff850270 (patch) | |
tree | 0561f5ba1e0a654aa2cd9f6036090215d2d47175 /gdb/testsuite/gdb.cp/classes.cc | |
parent | 087ce8fa0249fa0167a73f25be51e12fb1a2b336 (diff) | |
download | gdb-c191a6875b118fce30e7dc4d9e4bd20eff850270.zip gdb-c191a6875b118fce30e7dc4d9e4bd20eff850270.tar.gz gdb-c191a6875b118fce30e7dc4d9e4bd20eff850270.tar.bz2 |
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.
Diffstat (limited to 'gdb/testsuite/gdb.cp/classes.cc')
-rw-r--r-- | gdb/testsuite/gdb.cp/classes.cc | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/classes.cc b/gdb/testsuite/gdb.cp/classes.cc index 2a81473..50f0740 100644 --- a/gdb/testsuite/gdb.cp/classes.cc +++ b/gdb/testsuite/gdb.cp/classes.cc @@ -545,6 +545,82 @@ small::method () return x + 5; } +class class_with_typedefs +{ +public: + typedef int public_int; +protected: + typedef int protected_int; +private: + typedef int private_int; + +public: + class_with_typedefs () + : public_int_ (1), protected_int_ (2), private_int_ (3) {} + public_int add_public (public_int a) { return a + public_int_; } + public_int add_all (int a) + { return add_public (a) + add_protected (a) + add_private (a); } + +protected: + protected_int add_protected (protected_int a) { return a + protected_int_; } + +private: + private_int add_private (private_int a) { return a + private_int_; } + +protected: + public_int public_int_; + protected_int protected_int_; + private_int private_int_; +}; + +class class_with_public_typedef +{ + int a; +public: + typedef int INT; + INT b; +}; + +class class_with_protected_typedef +{ + int a; +protected: + typedef int INT; + INT b; +}; + +class class_with_private_typedef +{ + int a; +private: + typedef int INT; + INT b; +}; + +struct struct_with_public_typedef +{ + int a; +public: + typedef int INT; + INT b; +}; + +struct struct_with_protected_typedef +{ + int a; +protected: + typedef int INT; + INT b; +}; + +struct struct_with_private_typedef +{ + int a; +private: + typedef int INT; + INT b; +}; + void marker_reg1 () {} int @@ -624,3 +700,10 @@ protected_class protected_c; default_private_class default_private_c; explicit_private_class explicit_private_c; mixed_protection_class mixed_protection_c; +class_with_typedefs class_with_typedefs_c; +class_with_public_typedef class_with_public_typedef_c; +class_with_protected_typedef class_with_protected_typedef_c; +class_with_private_typedef class_with_private_typedef_c; +struct_with_public_typedef struct_with_public_typedef_s; +struct_with_protected_typedef struct_with_protected_typedef_s; +struct_with_private_typedef struct_with_private_typedef_s; |