Hi, Marek, Thanks a lot for the information.
Really helpful. Qing > On Oct 20, 2021, at 12:57 PM, Marek Polacek <pola...@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 >