This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
mixing warning flags
- From: DJ Delorie <dj at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 12 May 2005 15:46:41 -0400
- Subject: mixing warning flags
How to convert this code? There is no single OPT_* that reflects when
the first warning is emitted.
if (params == 0 && (warn_format_nonliteral || warn_format_security))
warning (0, "format not a string literal and no format arguments");
else
warning (OPT_Wformat_nonliteral,
"format not a string literal, argument types not checked");
One option is:
if (params == 0)
warning (OPT_Wformat_security,
"format not a string literal and no format arguments");
warning (OPT_Wformat_nonliteral,
"format not a string literal, argument types not checked");
but a little re-wording might be useful for when you get both
warnings. Alternately:
if (params == 0 && warn_format_security)
warning (OPT_Wformat_security,
"format not a string literal and no format arguments");
else
warning (OPT_Wformat_nonliteral,
"format not a string literal, argument types not checked");
or pedantically:
if (params == 0 && warn_format_security)
warning (OPT_Wformat_security,
"format not a string literal and no format arguments");
els if (params == 0 && warn_format_nonliteral)
warning (OPT_Wformat_nonliteral,
"format not a string literal and no format arguments");
else
warning (OPT_Wformat_nonliteral,
"format not a string literal, argument types not checked");