diff mbox

PR35503 - warn for restrict pointer

Message ID b21cb9a4-0233-166a-a293-878b0ebda9c9@gmail.com
State New
Headers show

Commit Message

Martin Sebor Sept. 20, 2016, 3:27 a.m. UTC
> and used
> pp_format for formatting arg_positions by adding specifier %I (name
> chosen arbitrarily).
> Does that look OK ?

Comments

Joseph Myers Sept. 20, 2016, 1 p.m. UTC | #1
On Tue, 20 Sep 2016, Martin Sebor wrote:

> That said, since this specifier formats a vec<int>, it seems that
> it might be useful to be able to format vectors of other elements,
> such as short and long.  With that in mind, would adding a new V
> length modifier instead be a more regular way to extend the pretty
> printer to these types?  The V length modifier would have to be
> accepted in conjunction with other length modifiers (h, l, etc
> and type specifiers (d, i, o, etc.).  E.g, "%hVu" would accept

That's much harder to support in format checking (which expects one length 
modifier, not a combination like that).
Martin Sebor Sept. 20, 2016, 2:16 p.m. UTC | #2
On 09/20/2016 07:00 AM, Joseph Myers wrote:
> On Tue, 20 Sep 2016, Martin Sebor wrote:
>
>> That said, since this specifier formats a vec<int>, it seems that
>> it might be useful to be able to format vectors of other elements,
>> such as short and long.  With that in mind, would adding a new V
>> length modifier instead be a more regular way to extend the pretty
>> printer to these types?  The V length modifier would have to be
>> accepted in conjunction with other length modifiers (h, l, etc
>> and type specifiers (d, i, o, etc.).  E.g, "%hVu" would accept
>
> That's much harder to support in format checking (which expects one length
> modifier, not a combination like that).

I haven't looked into it detail but since the format checker supports
one-to-two character sequences of length modifiers (h or hh, etc) it
should be possible to extend it to handle one-to-three character
sequences (h, hV, or hhV, etc.)  The V character would not be a new
length modifier on its own but instead be recognized as part of
a longer length modifier sequence.  Do you see a problem with that?

Martin
Joseph Myers Sept. 20, 2016, 2:25 p.m. UTC | #3
On Tue, 20 Sep 2016, Martin Sebor wrote:

> > That's much harder to support in format checking (which expects one length
> > modifier, not a combination like that).
> 
> I haven't looked into it detail but since the format checker supports
> one-to-two character sequences of length modifiers (h or hh, etc) it
> should be possible to extend it to handle one-to-three character
> sequences (h, hV, or hhV, etc.)  The V character would not be a new
> length modifier on its own but instead be recognized as part of
> a longer length modifier sequence.  Do you see a problem with that?

You could arrange for length modifiers to have extra variants like that 
(at present they have single and double variants listed), but it's clearly 
more complicated than a modifier that's used on its own.
diff mbox

Patch

diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index a39815e..e8bd1ef 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -610,6 +610,23 @@  pp_format (pretty_printer *pp, text_info *text)
  	      (pp, *text->args_ptr, precision, unsigned, "u");
  	  break;

+	case 'I':

The comment just above pp_format that lists the format specifiers
understood by the function should be updated.  There probably (I
hope) is more formal documentation of the format specifiers
somewhere else that should be updated as well.

That said, since this specifier formats a vec<int>, it seems that
it might be useful to be able to format vectors of other elements,
such as short and long.  With that in mind, would adding a new V
length modifier instead be a more regular way to extend the pretty
printer to these types?  The V length modifier would have to be
accepted in conjunction with other length modifiers (h, l, etc
and type specifiers (d, i, o, etc.).  E.g, "%hVu" would accept
a vec<unsigned short>*  as an argument and format it as a sequence
of decimal numbers, and "%lVx" would do the same for vec<long>*
formatting them in hex.

Martin