This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C/C++: fix quoting of "aka" typedef information (PR 62170)
- From: Marek Polacek <polacek at redhat dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 6 Jun 2017 12:57:54 +0200
- Subject: Re: [PATCH] C/C++: fix quoting of "aka" typedef information (PR 62170)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=polacek at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D9BA380499
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D9BA380499
- References: <1496689294-11629-1-git-send-email-dmalcolm@redhat.com>
On Mon, Jun 05, 2017 at 03:01:34PM -0400, David Malcolm wrote:
> PR 62170 describes a problem with how the quoting in pp_format
> interacts with the "aka" information for typedefs in %qT for
> the C family of frontends, and also now for %qH and %qI in the
> C++ frontend.
>
> Currently for %qT we print e.g.:
>
> ‘Py_ssize_t* {aka int*}’
> ^^^^^^^^^^^^^^^^^^^^^^ colorized as "quote"
>
> i.e.
> ‘[START_COLOR]Py_ssize_t* {aka int*}[END_COLOR]’
>
> when we should print:
>
> ‘Py_ssize_t*’ {aka ‘int*’}
> ^^^^^^^^^^^ ^^^^ colorized as "quote"
>
> i.e.
> ‘[START_COLOR]Py_ssize_t*[END_COLOR]’ {aka ‘[START_COLOR]int*[END_COLOR]’}
>
> where the opening and closing quote characters and colorization are
> currently added by the 'q' handling within pp_format, adding the closing
> quote unconditionally after whatever pp_format_decoder prints for 'T'
> within "%qT".
>
> This patch fixes the quoting by updating the %T handling in C and C++
> and the %H/%I handling in C++ to insert the quoting appropriately.
> It converts the "quote" param of the pp_format_decoder callback from
> bool to bool *, allowing for the %T and %H/%I handlers to write
> false back to it, to avoid printing the closing quote for the cases
> like the above where a final trailing closing quote isn't needed.
>
> It introduces pp_begin_quote/pp_end_quote to simplify this. These
> take a "bool show_color", rather than using "pp_show_color (pp)"
> since cxx_pp's pp_show_color isn't currently initialized (since
> cxx_initialize_diagnostics happens before diagnostic_color_init).
>
> Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.
This sounds good to me.
> OK for trunk?
>
> gcc/c/ChangeLog:
> PR c++/62170
> * c-objc-common.c (c_tree_printer): Convert penultimate param from
> bool to bool *. Within '%T' handling, if showing an "aka", use
> "quoted" param to add appropriate quoting.
This part is obviously OK.
Marek