public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* (!HELP NEEDED) Where is the doc for the format strings in gcc (for example, %q+D, ...)
@ 2021-10-20 15:49 Qing Zhao
  2021-10-20 17:57 ` Marek Polacek
  0 siblings, 1 reply; 4+ messages in thread
From: Qing Zhao @ 2021-10-20 15:49 UTC (permalink / raw)
  To: gcc-patches Nick Alcock via

Hi,

In GCC, there are many utility routines for reporting error, warning, or information, for example:

warning (0, "weak declaration of %q+D not supported", decl);
warning_at (stmtloc, OPT_Wmaybe_uninitialized,  "%qE may be used uninitialized", ptr));
inform (loc, "in a call to %qT declared with " "attribute %<%s%>", fntype, access_str);
error ("%qD is unavailable: %s", node, (const char *) msg);

There are format-strings inside them, “%q+D”, “%qE”, “%qT”, “%qD”, etc, where can I find a doc for the details of
These format-strings? Or which source files I should read to understand the details?

Thanks a lot for your help.

Qing

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: (!HELP NEEDED) Where is the doc for the format strings in gcc (for example, %q+D, ...)
  2021-10-20 15:49 (!HELP NEEDED) Where is the doc for the format strings in gcc (for example, %q+D, ...) Qing Zhao
@ 2021-10-20 17:57 ` Marek Polacek
  2021-10-20 19:25   ` Qing Zhao
  2021-10-24 17:07   ` Eric Gallager
  0 siblings, 2 replies; 4+ messages in thread
From: Marek Polacek @ 2021-10-20 17:57 UTC (permalink / raw)
  To: Qing Zhao; +Cc: gcc-patches Nick Alcock via

On Wed, Oct 20, 2021 at 03:49:09PM +0000, Qing Zhao via Gcc-patches wrote:
> Hi,
> 
> In GCC, there are many utility routines for reporting error, warning, or information, for example:
> 
> warning (0, "weak declaration of %q+D not supported", decl);
> warning_at (stmtloc, OPT_Wmaybe_uninitialized,  "%qE may be used uninitialized", ptr));
> inform (loc, "in a call to %qT declared with " "attribute %<%s%>", fntype, access_str);
> error ("%qD is unavailable: %s", node, (const char *) msg);
> 
> There are format-strings inside them, “%q+D”, “%qE”, “%qT”, “%qD”, etc, where can I find a doc for the details of
> These format-strings? Or which source files I should read to understand the details?

You can take a look at cp/error.c:

/* Called from output_format -- during diagnostic message processing --
   to handle C++ specific format specifier with the following meanings:
   %A   function argument-list.
   %C   tree code.
   %D   declaration.
   %E   expression.
   %F   function declaration.
   %H   type difference (from).
   %I   type difference (to).
   %L   language as used in extern "lang".
   %O   binary operator.
   %P   function parameter whose position is indicated by an integer.
   %Q   assignment operator.
   %S   substitution (template + args)
   %T   type.
   %V   cv-qualifier.
   %X   exception-specification.  */
static bool 
cp_printer (pretty_printer *pp, text_info *text, const char *spec,

or c/c-objc-common.c:

/* Called during diagnostic message formatting process to print a
   source-level entity onto BUFFER.  The meaning of the format specifiers
   is as follows:
   %D: a general decl,
   %E: an identifier or expression,
   %F: a function declaration,
   %T: a type.
   %V: a list of type qualifiers from a tree.
   %v: an explicit list of type qualifiers
   %#v: an explicit list of type qualifiers of a function type.

   Please notice when called, the `%' part was already skipped by the
   diagnostic machinery.  */
static bool
c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,

Marek


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: (!HELP NEEDED) Where is the doc for the format strings in gcc (for example, %q+D, ...)
  2021-10-20 17:57 ` Marek Polacek
@ 2021-10-20 19:25   ` Qing Zhao
  2021-10-24 17:07   ` Eric Gallager
  1 sibling, 0 replies; 4+ messages in thread
From: Qing Zhao @ 2021-10-20 19:25 UTC (permalink / raw)
  To: Marek Polacek; +Cc: gcc-patches Nick Alcock via

Hi, Marek,

Thanks a lot for the information. 

Really helpful.

Qing

> On Oct 20, 2021, at 12:57 PM, Marek Polacek <polacek@redhat.com> wrote:
> 
> On Wed, Oct 20, 2021 at 03:49:09PM +0000, Qing Zhao via Gcc-patches wrote:
>> Hi,
>> 
>> In GCC, there are many utility routines for reporting error, warning, or information, for example:
>> 
>> warning (0, "weak declaration of %q+D not supported", decl);
>> warning_at (stmtloc, OPT_Wmaybe_uninitialized,  "%qE may be used uninitialized", ptr));
>> inform (loc, "in a call to %qT declared with " "attribute %<%s%>", fntype, access_str);
>> error ("%qD is unavailable: %s", node, (const char *) msg);
>> 
>> There are format-strings inside them, “%q+D”, “%qE”, “%qT”, “%qD”, etc, where can I find a doc for the details of
>> These format-strings? Or which source files I should read to understand the details?
> 
> You can take a look at cp/error.c:
> 
> /* Called from output_format -- during diagnostic message processing --
>   to handle C++ specific format specifier with the following meanings:
>   %A   function argument-list.
>   %C   tree code.
>   %D   declaration.
>   %E   expression.
>   %F   function declaration.
>   %H   type difference (from).
>   %I   type difference (to).
>   %L   language as used in extern "lang".
>   %O   binary operator.
>   %P   function parameter whose position is indicated by an integer.
>   %Q   assignment operator.
>   %S   substitution (template + args)
>   %T   type.
>   %V   cv-qualifier.
>   %X   exception-specification.  */
> static bool 
> cp_printer (pretty_printer *pp, text_info *text, const char *spec,
> 
> or c/c-objc-common.c:
> 
> /* Called during diagnostic message formatting process to print a
>   source-level entity onto BUFFER.  The meaning of the format specifiers
>   is as follows:
>   %D: a general decl,
>   %E: an identifier or expression,
>   %F: a function declaration,
>   %T: a type.
>   %V: a list of type qualifiers from a tree.
>   %v: an explicit list of type qualifiers
>   %#v: an explicit list of type qualifiers of a function type.
> 
>   Please notice when called, the `%' part was already skipped by the
>   diagnostic machinery.  */
> static bool
> c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
> 
> Marek
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: (!HELP NEEDED) Where is the doc for the format strings in gcc (for example, %q+D, ...)
  2021-10-20 17:57 ` Marek Polacek
  2021-10-20 19:25   ` Qing Zhao
@ 2021-10-24 17:07   ` Eric Gallager
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Gallager @ 2021-10-24 17:07 UTC (permalink / raw)
  To: Marek Polacek; +Cc: Qing Zhao, gcc-patches Nick Alcock via

On Wed, Oct 20, 2021 at 10:57 AM Marek Polacek via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Wed, Oct 20, 2021 at 03:49:09PM +0000, Qing Zhao via Gcc-patches wrote:
> > Hi,
> >
> > In GCC, there are many utility routines for reporting error, warning, or information, for example:
> >
> > warning (0, "weak declaration of %q+D not supported", decl);
> > warning_at (stmtloc, OPT_Wmaybe_uninitialized,  "%qE may be used uninitialized", ptr));
> > inform (loc, "in a call to %qT declared with " "attribute %<%s%>", fntype, access_str);
> > error ("%qD is unavailable: %s", node, (const char *) msg);
> >
> > There are format-strings inside them, “%q+D”, “%qE”, “%qT”, “%qD”, etc, where can I find a doc for the details of
> > These format-strings? Or which source files I should read to understand the details?
>
> You can take a look at cp/error.c:
>
> /* Called from output_format -- during diagnostic message processing --
>    to handle C++ specific format specifier with the following meanings:
>    %A   function argument-list.
>    %C   tree code.
>    %D   declaration.
>    %E   expression.
>    %F   function declaration.
>    %H   type difference (from).
>    %I   type difference (to).
>    %L   language as used in extern "lang".
>    %O   binary operator.
>    %P   function parameter whose position is indicated by an integer.
>    %Q   assignment operator.
>    %S   substitution (template + args)
>    %T   type.
>    %V   cv-qualifier.
>    %X   exception-specification.  */
> static bool
> cp_printer (pretty_printer *pp, text_info *text, const char *spec,
>
> or c/c-objc-common.c:
>
> /* Called during diagnostic message formatting process to print a
>    source-level entity onto BUFFER.  The meaning of the format specifiers
>    is as follows:
>    %D: a general decl,
>    %E: an identifier or expression,
>    %F: a function declaration,
>    %T: a type.
>    %V: a list of type qualifiers from a tree.
>    %v: an explicit list of type qualifiers
>    %#v: an explicit list of type qualifiers of a function type.
>
>    Please notice when called, the `%' part was already skipped by the
>    diagnostic machinery.  */
> static bool
> c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
>
> Marek
>

Note that this is bug 92435: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92435

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-24 17:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20 15:49 (!HELP NEEDED) Where is the doc for the format strings in gcc (for example, %q+D, ...) Qing Zhao
2021-10-20 17:57 ` Marek Polacek
2021-10-20 19:25   ` Qing Zhao
2021-10-24 17:07   ` Eric Gallager

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).