diff options
author | Tom Tromey <tromey@redhat.com> | 2012-12-14 20:33:29 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-12-14 20:33:29 +0000 |
commit | 7d27a96df4e297e7329e0e3856c6d6e346478c80 (patch) | |
tree | 577b811b54508d15105168636b95930d432a77da /gdb | |
parent | f8c05d0d192df972af6b1c14aaf9dc8743cfe72e (diff) | |
download | fsf-binutils-gdb-7d27a96df4e297e7329e0e3856c6d6e346478c80.zip fsf-binutils-gdb-7d27a96df4e297e7329e0e3856c6d6e346478c80.tar.gz fsf-binutils-gdb-7d27a96df4e297e7329e0e3856c6d6e346478c80.tar.bz2 |
Partial fix for PR c++/14160:
* c-typeprint.c (c_type_print_base): Use TYPE_FN_FIELD_CONSTRUCTOR.
* dwarf2read.c (dwarf2_is_constructor): New function.
(dwarf2_add_member_fn): Use it.
* gnu-v3-abi.c (gnuv3_pass_by_reference): Use
TYPE_FN_FIELD_CONSTRUCTOR.
* jv-typeprint.c (java_type_print_base): Use
TYPE_FN_FIELD_CONSTRUCTOR.
* gdbtypes.h (struct fn_field) <is_constructor>: New field.
<dummy>: Shrink.
(TYPE_FN_FIELD_CONSTRUCTOR): New macro.
testsuite
* gdb.cp/templates.exp (test_ptype_of_templates): Update kfails.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 14 | ||||
-rw-r--r-- | gdb/c-typeprint.c | 3 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 30 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 7 | ||||
-rw-r--r-- | gdb/gnu-v3-abi.c | 3 | ||||
-rw-r--r-- | gdb/jv-typeprint.c | 3 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/templates.exp | 16 |
8 files changed, 76 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9791be6..8e75bbe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,19 @@ 2012-12-14 Tom Tromey <tromey@redhat.com> + Partial fix for PR c++/14160: + * c-typeprint.c (c_type_print_base): Use TYPE_FN_FIELD_CONSTRUCTOR. + * dwarf2read.c (dwarf2_is_constructor): New function. + (dwarf2_add_member_fn): Use it. + * gnu-v3-abi.c (gnuv3_pass_by_reference): Use + TYPE_FN_FIELD_CONSTRUCTOR. + * jv-typeprint.c (java_type_print_base): Use + TYPE_FN_FIELD_CONSTRUCTOR. + * gdbtypes.h (struct fn_field) <is_constructor>: New field. + <dummy>: Shrink. + (TYPE_FN_FIELD_CONSTRUCTOR): New macro. + +2012-12-14 Tom Tromey <tromey@redhat.com> + * c-exp.y (block, variable, name_not_typename, lex_one_token, classify_name): Update. * c-valprint.c (c_val_print): Update. diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 161b3fe..d3ab4a7 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1143,7 +1143,8 @@ c_type_print_base (struct type *type, struct ui_file *stream, struct cleanup *inner_cleanup; const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); int is_full_physname_constructor = - is_constructor_name (physname) + TYPE_FN_FIELD_CONSTRUCTOR (f, j) + || is_constructor_name (physname) || is_destructor_name (physname) || method_name[0] == '~'; diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 110ade9..4d5323e 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -10778,6 +10778,34 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type, } } +/* Return true if this member function is a constructor, false + otherwise. */ + +static int +dwarf2_is_constructor (struct die_info *die, struct dwarf2_cu *cu) +{ + const char *fieldname; + const char *typename; + int len; + + if (die->parent == NULL) + return 0; + + if (die->parent->tag != DW_TAG_structure_type + && die->parent->tag != DW_TAG_union_type + && die->parent->tag != DW_TAG_class_type) + return 0; + + fieldname = dwarf2_name (die, cu); + typename = dwarf2_name (die->parent, cu); + if (fieldname == NULL || typename == NULL) + return 0; + + len = strlen (fieldname); + return (strncmp (fieldname, typename, len) == 0 + && (typename[len] == '\0' || typename[len] == '<')); +} + /* Add a member function to the proper fieldlist. */ static void @@ -10909,6 +10937,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, if (attr && DW_UNSND (attr) != 0) fnp->is_artificial = 1; + fnp->is_constructor = dwarf2_is_constructor (die, cu); + /* Get index in virtual function table if it is a virtual member function. For older versions of GCC, this is an offset in the appropriate virtual table, as specified by DW_AT_containing_type. diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index fb113d2..b2791cd 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -837,8 +837,12 @@ struct cplus_struct_type to reconstruct the rest of the fields). */ unsigned int is_stub:1; + /* True if this function is a constructor, false + otherwise. */ + unsigned int is_constructor : 1; + /* Unused. */ - unsigned int dummy:4; + unsigned int dummy:3; /* Index into that baseclass's virtual function table, minus 2; else if static: VOFFSET_STATIC; else: 0. */ @@ -1212,6 +1216,7 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial) #define TYPE_FN_FIELD_ABSTRACT(thisfn, n) ((thisfn)[n].is_abstract) #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub) +#define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor) #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext) #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2) #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1) diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index c025a7b..83ee196 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1071,7 +1071,8 @@ gnuv3_pass_by_reference (struct type *type) with the mangled name. We don't have a convenient function to strip off both leading scope qualifiers and trailing template arguments yet. */ - if (!is_constructor_name (TYPE_FN_FIELD_PHYSNAME (fn, fieldelem))) + if (!is_constructor_name (TYPE_FN_FIELD_PHYSNAME (fn, fieldelem)) + && !TYPE_FN_FIELD_CONSTRUCTOR (fn, fieldelem)) continue; /* If this method takes two arguments, and the second argument is diff --git a/gdb/jv-typeprint.c b/gdb/jv-typeprint.c index f0d3448..95b1758 100644 --- a/gdb/jv-typeprint.c +++ b/gdb/jv-typeprint.c @@ -239,7 +239,8 @@ java_type_print_base (struct type *type, struct ui_file *stream, int show, physname[p - real_physname] = '\0'; is_full_physname_constructor - = (is_constructor_name (physname) + = (TYPE_FN_FIELD_CONSTRUCTOR (f, j) + || is_constructor_name (physname) || is_destructor_name (physname)); QUIT; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4de393a..1fccb0b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-12-14 Tom Tromey <tromey@redhat.com> + + * gdb.cp/templates.exp (test_ptype_of_templates): Update kfails. + 2012-12-14 Doug Evans <dje@google.com> * gdb.dwarf2/implptr-optimized-out.S: DIE offset for diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp index 9ebb3bd..45b67e1 100644 --- a/gdb/testsuite/gdb.cp/templates.exp +++ b/gdb/testsuite/gdb.cp/templates.exp @@ -60,6 +60,14 @@ proc test_ptype_of_templates {} { # This also triggers gdb/1113... kfail "gdb/1111" "ptype T5<int>" # Add here a PASS case when PR gdb/1111 gets fixed. + # These are really: + # http://sourceware.org/bugzilla/show_bug.cgi?id=8216 + # http://sourceware.org/bugzilla/show_bug.cgi?id=8218 + } + -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + # http://sourceware.org/bugzilla/show_bug.cgi?id=8218 + # The destructor has an argument type. + kfail "gdb/8218" "ptype T5<int>" } } @@ -89,6 +97,14 @@ proc test_ptype_of_templates {} { # This also triggers gdb/1113... kfail "gdb/1111" "ptype T5<int>" # Add here a PASS case when PR gdb/1111 gets fixed. + # These are really: + # http://sourceware.org/bugzilla/show_bug.cgi?id=8216 + # http://sourceware.org/bugzilla/show_bug.cgi?id=8218 + } + -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + # http://sourceware.org/bugzilla/show_bug.cgi?id=8218 + # The destructor has an argument type. + kfail "gdb/8218" "ptype T5<int>" } } } |