On Sat, 27 Nov 2021, chenglulu wrote:

> +     if (p_arch_native)
> +       fatal_error (UNKNOWN_LOCATION,
> +                    "Unknown FPU type %<0x%x%>, "
> +                    "%<-m" OPTSTR_ARCH "=" STR_CPU_NATIVE "%> failed",

Diagnostics should not start with an uppercase letter (unless the start 
would have a capital letter even in the middle of a sentence - thus, the 
diagnostic you have elsewhere starting "ABI" is fine as-is).

Diagnostics can't use string concatenation with macros, because that means 
only the part up to the first macro name gets extracted into gcc.pot for 
translation - in this case, "Unknown FPU type %<0x%x%>, %<-m" - so the 
translations never match at runtime.  The whole format string for a 
diagnostic function needs to appear directly in the call to the function 
(or to macros such as G_), without any part of that string itself coming 
from macro expansion, for translation to work properly.

> +     inform (UNKNOWN_LOCATION, "Unknown processor ID %<0x%x%>, "
> +             "some tuning parameters will fall back to default",

Diagnostics should not start with an uppercase letter.

> +     inform (UNKNOWN_LOCATION,
> +             "%<-m%s%> overrides %<-m" OPTSTR_ABI_BASE "=%s%>",

Same comment as above about not concatenating with macros in diagnostics.

> +  if (t.cpu_arch == CPU_NATIVE)
> +    fatal_error (UNKNOWN_LOCATION,
> +              "%<-m" OPTSTR_ARCH "=" STR_CPU_NATIVE "%> "
> +              "does not work on a cross compiler");
> +
> +  else if (t.cpu_tune == CPU_NATIVE)
> +    fatal_error (UNKNOWN_LOCATION,
> +              "%<-m" OPTSTR_TUNE "=" STR_CPU_NATIVE "%> "
> +              "does not work on a cross compiler");

Likewise.

> +      warning (0, "%s CPU architecture (%qs) does not support %qs ABI, "
> +            "falling back to %<-m" OPTSTR_ARCH "=%s%>",

Likewise.

> +            (t.cpu_arch == CPU_NATIVE ? "your native" : "default"),

Also, "your native" and "default" look like they are intended as English 
that should be translated, not e.g. literal option arguments that should 
stay as-is.  So they needs to appear directly in the diagnostic sentence 
for proper translation, e.g.

  if (t.cpu_arch == CPU_NATIVE)
    warning (...);
  else
    warning (...);

(if you use a conditional expression in the second argument to warning to 
avoid having separate calls like that, both format strings then need to 
have G_ () around them to ensure they are properly extracted for 
translation).

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to