This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][aarch64] Fix error calls in aarch64 code so they can be tranlated
On 09/20/2017 05:36 PM, Steve Ellcey wrote:
On Tue, 2017-09-19 at 10:49 -0600, Martin Sebor wrote:
On 09/19/2017 09:54 AM, Steve Ellcey wrote:
On Tue, 2017-09-19 at 09:50 +0200, Frédéric Marchal wrote:
error (is_pragma
? G_("missing name in %<#pragma target\(\"%s=\")%>")
: G_("missing name in %<target(\"%s=\")%>
attribute"),
"arch");
The additional benefit of this approach is that it would also make
the quoting consistent with what seems to be the prevailing style
of these sorts of messages. (It would be nice to eventually
converge on the same style/quoting and phrasing across all back
and front ends.)
Indeed! That's even better as the message uses words the user sees in the
source code whatever his/her locale language is.
So I am looking at redoing the error messages and I am trying to decide
between two forms.
Make pragma/attribute part of the non-translatable string by showing the
pragma and/or attribute syntax ast it would be in the C/C++ code (what about
Fortran or Ada?).
error (is_pragma
? G_("missing architecture name in %<#pragma GCC target (\"arch=string\")%>")
: G_("missing architecture name in %<__attribute__ ((target(\"arch=string\")))
%>"));
Or include them in the part that does get translated and include less of
what is actually in the text of the file being compiled.
error (is_pragma
? G_("missing architecture name in %<target (\"arch=string\")%> pragma")
: G_("missing architecture name in %<target(\"arch=string\")%> attribute"));
Opinions?
There are two distinctly different spellings of the target (and
every other) attribute: besides the one above, the C+++ standard
recommended syntax is [[gnu::target("arch=...")]], so I think
hardcoding one into the message wouldn't be optimal. (The C
standard hasn't adopted the C++ syntax but a proposal to do so
is being considered. There are some questions about the exact
spelling, and some people have proposed adding _Attribute()
instead, analogous to _Pragma, or possibly in addition to the
C++ syntax.)
There are, of course, also two ways to spell a pragma: #pragma
and _Pragma, so the same argument against hardcoding either one
could be made there.
In my view, the ideal message would use the same form as in
the source code. But I suspect that's not easy to determine at
all sites where the message is being formatted, so the next best
thing is to avoid using the keyword and fall back on the general
term.
Martin
PS If possible, I would also suggest adopting a style that is
already in use elsewhere, for consistency. (That would suggest
using %<target(\"arch=\")%> with no spaces and no "string" after
arch=.)