aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2010-02-02 16:47:14 +0000
committerTom Tromey <tromey@redhat.com>2010-02-02 16:47:14 +0000
commit0cc2414c91dfd4d34c43b4e20e3307ab94629333 (patch)
tree4386662a81d909a5ad75cf54a7c98345e0dd0c63 /gdb
parentedf3d5f3f8c5adff55934e57da9cd8c874dc2a55 (diff)
downloadfsf-binutils-gdb-0cc2414c91dfd4d34c43b4e20e3307ab94629333.zip
fsf-binutils-gdb-0cc2414c91dfd4d34c43b4e20e3307ab94629333.tar.gz
fsf-binutils-gdb-0cc2414c91dfd4d34c43b4e20e3307ab94629333.tar.bz2
gdb
* m2-typeprint.c (m2_record_fields): Don't use TYPE_DECLARED_TYPE. * gdbtypes.h (TYPE_DECLARED_CLASS): New macro. (struct main_type) <flag_declared_class>: New field. (struct cplus_struct_type) <declared_type>: Remove. <ntemplate_args>: Move earlier. (DECLARED_TYPE_CLASS, DECLARED_TYPE_UNION, DECLARED_TYPE_STRUCT) (DECLARED_TYPE_TEMPLATE): Remove. (TYPE_DECLARED_TYPE): Remove. * gdbtypes.c (lookup_union): Don't use TYPE_DECLARED_TYPE. * dwarf2read.c (read_structure_type): Set TYPE_DECLARED_CLASS. * c-typeprint.c (c_type_print_base): Use TYPE_DECLARED_CLASS, not TYPE_DECLARED_TYPE. gdb/testsuite * gdb.dwarf2/member-ptr-forwardref.exp: Update expected result for type-printing change.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/c-typeprint.c42
-rw-r--r--gdb/dwarf2read.c5
-rw-r--r--gdb/gdbtypes.c7
-rw-r--r--gdb/gdbtypes.h26
-rw-r--r--gdb/m2-typeprint.c4
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp2
8 files changed, 45 insertions, 62 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 01ce121..8ebad2c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,21 @@
2010-02-02 Tom Tromey <tromey@redhat.com>
+ * m2-typeprint.c (m2_record_fields): Don't use
+ TYPE_DECLARED_TYPE.
+ * gdbtypes.h (TYPE_DECLARED_CLASS): New macro.
+ (struct main_type) <flag_declared_class>: New field.
+ (struct cplus_struct_type) <declared_type>: Remove.
+ <ntemplate_args>: Move earlier.
+ (DECLARED_TYPE_CLASS, DECLARED_TYPE_UNION, DECLARED_TYPE_STRUCT)
+ (DECLARED_TYPE_TEMPLATE): Remove.
+ (TYPE_DECLARED_TYPE): Remove.
+ * gdbtypes.c (lookup_union): Don't use TYPE_DECLARED_TYPE.
+ * dwarf2read.c (read_structure_type): Set TYPE_DECLARED_CLASS.
+ * c-typeprint.c (c_type_print_base): Use TYPE_DECLARED_CLASS, not
+ TYPE_DECLARED_TYPE.
+
+2010-02-02 Tom Tromey <tromey@redhat.com>
+
PR c++/11226, PR c++/9629, PR c++/9688, PR c++/8890:
* valops.c (search_struct_field): Compute nbases after calling
CHECK_TYPEDEF.
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index d1af481..27746d9 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -702,35 +702,10 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
case TYPE_CODE_STRUCT:
c_type_print_modifier (type, stream, 0, 1);
- /* Note TYPE_CODE_STRUCT and TYPE_CODE_CLASS have the same value,
- * so we use another means for distinguishing them.
- */
- if (HAVE_CPLUS_STRUCT (type))
- {
- switch (TYPE_DECLARED_TYPE (type))
- {
- case DECLARED_TYPE_CLASS:
- fprintf_filtered (stream, "class ");
- break;
- case DECLARED_TYPE_UNION:
- fprintf_filtered (stream, "union ");
- break;
- case DECLARED_TYPE_STRUCT:
- fprintf_filtered (stream, "struct ");
- break;
- default:
- /* If there is a CPLUS_STRUCT, assume class if not
- * otherwise specified in the declared_type field.
- */
- fprintf_filtered (stream, "class ");
- break;
- } /* switch */
- }
+ if (TYPE_DECLARED_CLASS (type))
+ fprintf_filtered (stream, "class ");
else
- {
- /* If not CPLUS_STRUCT, then assume it's a C struct */
- fprintf_filtered (stream, "struct ");
- }
+ fprintf_filtered (stream, "struct ");
goto struct_union;
case TYPE_CODE_UNION:
@@ -786,8 +761,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
masquerading as a class, if all members are public, there's
no need for a "public:" label. */
- if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_CLASS)
- || (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_TEMPLATE))
+ if (TYPE_DECLARED_CLASS (type))
{
QUIT;
len = TYPE_NFIELDS (type);
@@ -815,8 +789,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
}
}
}
- else if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_STRUCT)
- || (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_UNION))
+ else
{
QUIT;
len = TYPE_NFIELDS (type);
@@ -863,10 +836,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
|| TYPE_FIELD_ARTIFICIAL (type, i))
continue;
- /* If this is a C++ class we can print the various C++ section
- labels. */
-
- if (HAVE_CPLUS_STRUCT (type) && need_access_label)
+ if (need_access_label)
{
if (TYPE_FIELD_PROTECTED (type, i))
{
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 2f671ca..86bfecb 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -5007,11 +5007,12 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
}
else
{
- /* FIXME: TYPE_CODE_CLASS is currently defined to TYPE_CODE_STRUCT
- in gdbtypes.h. */
TYPE_CODE (type) = TYPE_CODE_CLASS;
}
+ if (cu->language == language_cplus && die->tag == DW_TAG_class_type)
+ TYPE_DECLARED_CLASS (type) = 1;
+
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr)
{
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 2ff8647..46846c4 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1132,13 +1132,6 @@ lookup_union (char *name, struct block *block)
if (TYPE_CODE (t) == TYPE_CODE_UNION)
return t;
- /* C++ unions may come out with TYPE_CODE_CLASS, but we look at
- * a further "declared_type" field to discover it is really a union.
- */
- if (HAVE_CPLUS_STRUCT (t))
- if (TYPE_DECLARED_TYPE (t) == DECLARED_TYPE_UNION)
- return t;
-
/* If we get here, it's not a union. */
error (_("This context has class, struct or enum %s, not a union."),
name);
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 72968a5..643fa03 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -279,6 +279,12 @@ enum type_instance_flag_value
#define TYPE_OWNER(t) TYPE_MAIN_TYPE(t)->owner
#define TYPE_OBJFILE(t) (TYPE_OBJFILE_OWNED(t)? TYPE_OWNER(t).objfile : NULL)
+/* True if this type was declared using the "class" keyword. This is
+ only valid for C++ structure types, and only used for displaying
+ the type. If false, the structure was declared as a "struct". */
+
+#define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class)
+
/* Constant type. If this is set, the corresponding type has a
* const modifier.
*/
@@ -386,6 +392,9 @@ struct main_type
unsigned int flag_nottext : 1;
unsigned int flag_fixed_instance : 1;
unsigned int flag_objfile_owned : 1;
+ /* True if this type was declared with "class" rather than
+ "struct". */
+ unsigned int flag_declared_class : 1;
/* A discriminant telling us which field of the type_specific union
is being used for this type, if any. */
@@ -676,19 +685,10 @@ struct cplus_struct_type
short nfn_fields_total;
- /* The "declared_type" field contains a code saying how the
- user really declared this type, e.g., "class s", "union s",
- "struct s".
- The 3 above things come out from the C++ compiler looking like classes,
- but we keep track of the real declaration so we can give
- the correct information on "ptype". (Note: TEMPLATE may not
- belong in this list...) */
+ /* Number of template arguments, placed here for better struct
+ packing. */
-#define DECLARED_TYPE_CLASS 0
-#define DECLARED_TYPE_UNION 1
-#define DECLARED_TYPE_STRUCT 2
-#define DECLARED_TYPE_TEMPLATE 3
- short declared_type; /* One of the above codes */
+ short ntemplate_args;
/* 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.
@@ -813,7 +813,6 @@ struct cplus_struct_type
* is a name. "type" will typically just point to a "struct type" with
* the placeholder TYPE_CODE_TEMPLATE_ARG type.
*/
- short ntemplate_args;
struct template_arg
{
char *name;
@@ -943,7 +942,6 @@ extern void allocate_gnat_aux_type (struct type *);
#define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
#define TYPE_NFN_FIELDS_TOTAL(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields_total
#define TYPE_NTEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ntemplate_args
-#define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type
#define TYPE_SPECIFIC_FIELD(thistype) \
TYPE_MAIN_TYPE(thistype)->type_specific_field
#define TYPE_TYPE_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index afa9978..46a35bb 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -547,9 +547,9 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show,
wrap_here (" ");
if (show < 0)
{
- if (TYPE_CODE (type) == DECLARED_TYPE_STRUCT)
+ if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
fprintf_filtered (stream, "RECORD ... END ");
- else if (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_UNION)
+ else if (TYPE_CODE (type) == TYPE_CODE_UNION)
fprintf_filtered (stream, "CASE ... END ");
}
else if (show > 0)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index d55d31a..1a78e54 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2010-02-02 Tom Tromey <tromey@redhat.com>
+ * gdb.dwarf2/member-ptr-forwardref.exp: Update expected result for
+ type-printing change.
+
+2010-02-02 Tom Tromey <tromey@redhat.com>
+
PR c++/11226, PR c++/9629, PR c++/9688, PR c++/8890:
* gdb.cp/virtbase.cc: New file.
* gdb.cp/virtbase.exp: New file.
diff --git a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
index 0a54dfe..bb947bc 100644
--- a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
+++ b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
@@ -45,4 +45,4 @@ gdb_test "show cp-abi" {The currently selected C\+\+ ABI is "gnu-v3".*}
gdb_load ${binfile}
-gdb_test "ptype c" "type = class C {\[\r\n \t\]*int \\(C::\\*fp\\)\\(C \\*\\);\[\r\n \t\]*}"
+gdb_test "ptype c" "type = struct C {\[\r\n \t\]*private:\[\r\n \t\]*int \\(C::\\*fp\\)\\(C \\*\\);\[\r\n \t\]*}"