This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

"error: static assertion failed: [...]" (was: [GCC Wiki] Update of "DiagnosticsGuidelines" by MartinSebor)


Hi!

I had recently noticed that given:

    #ifndef __cplusplus /* C */
    _Static_assert(0, "foo");
    #else /* C++ */
    static_assert(0, "foo");
    #endif

..., for C we diagnose:

    [...]:2:1: error: static assertion failed: "foo"
     _Static_assert(0, "foo");
     ^~~~~~~~~~~~~~

..., and for C++ we diagnost:

    [...]:4:1: error: static assertion failed: foo
     static_assert(0, "foo");
     ^~~~~~~~~~~~~

("foo" quoted vs. un-quoted.)  Assuming this difference between C and C++
diagnostics is not intentional, which one should we settle on?  I thought
I'd like the un-quoted version better, but judging by Martin's recent
wiki change (see below), "foo" is a string constant, so should be quoted
in diagnostics?  If yes, OK to commit to trunk the obvious changes (plus
any testsuite updates)?

For reference:

On Tue, 12 Jul 2016 22:34:17 -0000, GCC Wiki <noreply@gcc.gnu.org> wrote:
> The "DiagnosticsGuidelines" page has been changed by MartinSebor:
> https://gcc.gnu.org/wiki/DiagnosticsGuidelines?action=diff&rev1=7&rev2=8
> 
> Comment:
> Added a table of contents and a Quoting section.

> + === Quoting ===
> + 
> + The following elements should be quoted in GCC diagnostics, either using the {{{q}}} modifier in a directive such as {{{%qE}}}, or by enclosing the quoted text in a pair of {{{%<}}} and {{{%>}}} directives:
> + 
> +  * Language keywords.
> +  * Tokens.
> +  * Boolean, numerical, character, and string constants that appear in the source code.
> +  * Identifiers, including function, macro, type, and variable names.
> + 
> + Other elements such as numbers that do no refer to numeric constants that appear in the source code should not be quoted.  For example, in the message:
> + {{{#!highlight c++ numbers=disable
> + argument %d of %qE must be a pointer type
> + }}}
> + since the argument number does not refer to a numerical constant in the source code it should not be quoted.


Grüße
 Thomas

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]