mixing warning flags

DJ Delorie dj@redhat.com
Thu May 12 20:55:00 GMT 2005


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");



More information about the Gcc mailing list