[PATCH] Avoid -Werror=format-security errors in libcpp
Jakub Jelinek
jakub@redhat.com
Fri Jan 16 12:32:00 GMT 2015
On Thu, Jan 15, 2015 at 09:38:19PM +0000, Joseph Myers wrote:
> On Thu, 15 Jan 2015, Jakub Jelinek wrote:
>
> > --- libcpp/expr.c.jj 2015-01-14 11:01:34.000000000 +0100
> > +++ libcpp/expr.c 2015-01-14 14:35:52.851002344 +0100
> > @@ -672,16 +672,17 @@ cpp_classify_number (cpp_reader *pfile,
> > if ((result & CPP_N_WIDTH) == CPP_N_LARGE
> > && CPP_OPTION (pfile, cpp_warn_long_long))
> > {
> > - const char *message = CPP_OPTION (pfile, cplusplus)
> > - ? N_("use of C++11 long long integer constant")
> > - : N_("use of C99 long long integer constant");
> > -
> > if (CPP_OPTION (pfile, c99))
> > cpp_warning_with_line (pfile, CPP_W_LONG_LONG, virtual_location,
> > - 0, message);
> > + 0, CPP_OPTION (pfile, cplusplus)
> > + ? "use of C++11 long long integer constant"
> > + : "use of C99 long long integer constant");
> > else
> > cpp_pedwarning_with_line (pfile, CPP_W_LONG_LONG,
> > - virtual_location, 0, message);
> > + virtual_location, 0,
> > + CPP_OPTION (pfile, cplusplus)
> > + ? "use of C++11 long long integer constant"
> > + : "use of C99 long long integer constant");
>
> I think this sort of thing needs N_() on both messages so that they both
> get extracted for translation.
Apparently it extracts just the first string and not the second, weird, I
thought we handle it well.
Anyway, in that case guess we also need to change unrelated:
--- libcpp/expr.c.jj 2015-01-05 13:07:21.000000000 +0100
+++ libcpp/expr.c 2015-01-16 12:54:56.517522643 +0100
@@ -696,9 +696,9 @@ cpp_classify_number (cpp_reader *pfile,
&& CPP_PEDANTIC (pfile))
cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
CPP_OPTION (pfile, cplusplus)
- ? "binary constants are a C++14 feature "
- "or GCC extension"
- : "binary constants are a GCC extension");
+ ? N_("binary constants are a C++14 feature "
+ "or GCC extension")
+ : N_("binary constants are a GCC extension"));
if (radix == 10)
result |= CPP_N_DECIMAL;
I'll defer this patch until PR64629 is resolved one way or another.
Jakub
More information about the Gcc-patches
mailing list