* 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.
+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,
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] == '~';
}
}
+/* 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
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.
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. */
#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)
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
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;
+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
# 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>"
}
}
# 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>"
}
}
}