c++/8218: Destructors w/arguments.

For a long time now, c++/8218 has noted that GDB is printing argument types
for destructors:

(gdb) ptype A
type = class A {
  public:
    ~A(int);
}

This happens because cp_type_print_method_args doesn't ignore artificial
arguments.  [It ignores the first `this' pointer because it simply skips
the first argument for any non-static function.]

This patch fixes this:

(gdb) ptype  A
type = class A {
  public:
    ~A();
}

I've adjusted gdb.cp/templates.exp to account for this and added a new
passing regexp.

gdb/ChangeLog

	PR c++/8218
	* c-typeprint.c (cp_type_print_method_args): Skip artificial arguments.

gdb/testsuite/ChangeLog

	PR c++/8128
	* gdb.cp/templates.exp (test_ptype_of_templates): Remove argument
	type from destructor regexps.
	Add a branch which actually passes the test.
	Adjust "ptype t5i" test names.
This commit is contained in:
Keith Seitz
2017-03-10 10:32:09 -08:00
parent 7b5d48229b
commit 5f4d108508
4 changed files with 38 additions and 11 deletions

View File

@@ -226,13 +226,21 @@ cp_type_print_method_args (struct type *mtype, const char *prefix,
language_cplus, DMGL_ANSI);
fputs_filtered ("(", stream);
/* Skip the class variable. */
/* Skip the class variable. We keep this here to accommodate older
compilers and debug formats which may not support artificial
parameters. */
i = staticp ? 0 : 1;
if (nargs > i)
{
while (i < nargs)
{
c_print_type (args[i++].type, "", stream, 0, 0, flags);
struct field arg = args[i++];
/* Skip any artificial arguments. */
if (FIELD_ARTIFICIAL (arg))
continue;
c_print_type (arg.type, "", stream, 0, 0, flags);
if (i == nargs && varargs)
fprintf_filtered (stream, ", ...");