"error: static assertion failed: [...]" (was: [GCC Wiki] Update of "DiagnosticsGuidelines" by MartinSebor)
Thomas Schwinge
thomas@codesourcery.com
Wed Jul 13 13:27:00 GMT 2016
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20160713/6a334330/attachment.sig>
More information about the Gcc
mailing list