diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 3a611cdac5d..e17a4ccfa1e 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -273,35 +273,46 @@ cp_type_print_method_args (struct type *mtype, const char *prefix, language_cplus, DMGL_ANSI); gdb_puts ("(", stream); - /* 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) + int printed_args = 0; + for (i = 0; i < nargs; ++i) { - while (i < nargs) + if (i == 0 && !staticp) { - struct field arg = args[i++]; - - /* Skip any artificial arguments. */ - if (FIELD_ARTIFICIAL (arg)) - continue; + /* Skip the class variable. We keep this here to accommodate older + compilers and debug formats which may not support artificial + parameters. */ + continue; + } - c_print_type (arg.type (), "", stream, 0, 0, language, flags); + struct field arg = args[i]; + /* Skip any artificial arguments. */ + if (FIELD_ARTIFICIAL (arg)) + continue; - if (i == nargs && varargs) - gdb_printf (stream, ", ..."); - else if (i < nargs) - { - gdb_printf (stream, ", "); - stream->wrap_here (8); - } + if (printed_args > 0) + { + gdb_printf (stream, ", "); + stream->wrap_here (8); } + + c_print_type (arg.type (), "", stream, 0, 0, language, flags); + printed_args++; + } + + if (varargs) + { + if (printed_args == 0) + gdb_printf (stream, "..."); + else + /* Note: no wrapping done here. Is that intended? */ + gdb_printf (stream, ", ..."); + } + else if (printed_args == 0) + { + /* Why do we do this differently for non-c++? */ + if (language == language_cplus && staticp) + gdb_printf (stream, "void"); } - else if (varargs) - gdb_printf (stream, "..."); - else if (language == language_cplus) - gdb_printf (stream, "void"); gdb_printf (stream, ")"); diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp index 7b8b315ac1f..7c214a57100 100644 --- a/gdb/testsuite/gdb.cp/classes.exp +++ b/gdb/testsuite/gdb.cp/classes.exp @@ -328,7 +328,7 @@ proc test_ptype_class_objects {} { "class_with_typedefs::protected_int protected_int_;" } { field protected \ "class_with_typedefs::private_int private_int_;" } - { method public "class_with_typedefs(void);" } + { method public "class_with_typedefs();" } { method public "class_with_typedefs::public_int add_public(class_with_typedefs::public_int);" } { method public \ "class_with_typedefs::public_int add_all(int);" } diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-overload.exp b/gdb/testsuite/gdb.cp/rvalue-ref-overload.exp index 36342673aad..b0c555a8fa9 100644 --- a/gdb/testsuite/gdb.cp/rvalue-ref-overload.exp +++ b/gdb/testsuite/gdb.cp/rvalue-ref-overload.exp @@ -43,7 +43,7 @@ gdb_test "up" ".*main.*" "up from marker1" # Print the monster class type. cp_test_ptype_class "foo_rr_instance1" "" "class" "foo" \ { - { method public "foo(void);" } + { method public "foo();" } { method public "foo(foo_lval_ref);" } { method public "foo(foo_rval_ref);" } { method public "~foo();" }