c++: Fix pretty printing pointer to function type [PR98767]
authorPatrick Palka <ppalka@redhat.com>
Fri, 23 Apr 2021 12:47:02 +0000 (08:47 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 23 Apr 2021 12:47:02 +0000 (08:47 -0400)
commit87fc34a461cf362947a430d8a241f653fd83bc7b
tree14ddc556452e0d0c2345ecda011b16cd71b70cc6
parent5f8aed72e76970d2c6fa06fb23fdaa47660555b0
c++: Fix pretty printing pointer to function type [PR98767]

When pretty printing a pointer to function type,
pp_cxx_parameter_declaration_clause ends up always outputting an empty
function parameter list because the loop that outputs the list iterates
over 'args' instead of 'types', and 'args' is empty when a FUNCTION_TYPE
is passed to this routine (as opposed to a FUNCTION_DECL).

This patch fixes this by making the loop iterate over 'types' instead.
This patch also moves the retrofitted chain-of-PARM_DECLs printing from
here to pp_cxx_requires_expr, the only caller that uses it.  Doing so
lets us easily output the trailing '...' in the parameter list of a
variadic function, which this patch also implements.

gcc/cp/ChangeLog:

PR c++/98767
* cxx-pretty-print.c (pp_cxx_parameter_declaration_clause):
Adjust parameter list loop to iterate over 'types' instead of
'args'.  Output the trailing '...' for a variadic function.
Remove PARM_DECL support.
(pp_cxx_requires_expr): Pretty print the parameter list directly
instead of going through pp_cxx_parameter_declaration_clause.

gcc/testsuite/ChangeLog:

PR c++/98767
* g++.dg/concepts/diagnostic17.C: New test.
gcc/cp/cxx-pretty-print.c
gcc/testsuite/g++.dg/concepts/diagnostic17.C [new file with mode: 0644]