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.
This commit is contained in:
Tom Tromey 2012-12-14 20:33:29 +00:00
parent f8c05d0d19
commit 7d27a96df4
8 changed files with 76 additions and 4 deletions

View File

@ -1,3 +1,17 @@
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,

View File

@ -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] == '~';

View File

@ -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.

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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>"
}
}
}