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&regrtested 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

Reply via email to