On 1/11/21 9:30 AM, Matthias Klose wrote:
On 1/10/21 10:18 PM, Martin Sebor wrote:
On 1/10/21 3:29 AM, Matthias Klose wrote:
is the newline intended? It's followed by a debug_rtx call.
To avoid the warning there shouldn't be any trailing punctuation
or whitespace in the message. The GCC quoting directives should
be preferred over the literal characters (as per GCC Coding
Conventions). %qc and %qs are preferable to %<%c%>.
Symbols/identifiers should be formatted using the appropriate
directives or quoted in %< %>. Underscores in words like
emit_insn are taken as indicators that the word is an identifier
and to trigger warnings.
is this?
https://gcc.gnu.org/codingconventions.html#Diagnostics
I think that's a bit terse, and grepping sources for %< shows many more
occurences than %qX.
Agreed, the section could stand to be expanded. I don't know about
the metrics. There are lots of %<xxx%> but only a few %<%[cs]%>:
$ grep " %<%[cs]%> " /src/gcc/master/gcc/po/gcc.pot
"cannot apply %<%s%> to %qD, which has also been marked with an OpenMP "
"incompatible %qs clause when applying %<%s%> to %qD, which has already
been "
"missing %qs clause when applying %<%s%> to %qD, which has already been "
msgid "unbalanced punctuation character %<%c%> in format"
msgid "unterminated quote character %<%c%> in format"
msgid "bad value %<%s%> for %<-mtls-size=%> switch"
msgid "unexpected %<%s%> after %<%s%>"
msgid "invalid argument %<%s%> for %<-mharden-sls=%>"
msgid "invalid argument %<%s%> for %<-mbranch-protection=%>"
msgid "Unexpected %<%c%> for nonderived-type variable %qs at %C"
These should still be changed to %qc and %qs at some point.
../../src/gcc/rtl.c:860:42: warning: unquoted sequence of 2 consecutive
punctuation characters '',' in format [-Wformat-diag]
860 | ("RTL check: expected elt %d type '%c', have '%c' (rtx %s) in %s,
at
%s:%d",
`%c', or some %q quoting?
The purpose of the -Wformat-diag warnings is to improve the consistency
of user-visible messages and make them easier to translate. There was
a discussion some time back about whether internal errors should fall
into this category. I'm not sure if it reached a conclusion one way
or the other but in similar situations elsewhere in GCC we have
suppressed the warning via #pragma GCC diagnostic. If it takes too
much effort to clean them up it might make sense to do the same here
(the downside is that it doesn't help translators). Otherwise,
the messages are not really phrased in a way that's comprehensible
either to users or to tranlators (acronyms like elt or rtx aren't universally
understood).
[...]
again, `' quotes, or some %q option?
The latter: %qs with an argument is best in general (it can reduce
translation effort between repeated messages parameterized on
the quoted string).
if the URL above is the correct place for the conventions, then maybe make it
more explicit there about the preferred choice.
Yes, I can make that change. My hope is that the warning would
make the preferred choice clear in the followup note so if/where
it doesn't please let me know (or open a bug) and I'll adjust it.
(Otherwise, if there's no warning, there's no preference :)
Martin