[cfe-commits] [Patch] Warn about non-standard format strings (PR12017)

Hans Wennborg hans at chromium.org
Tue Feb 21 03:39:37 PST 2012


On Mon, Feb 20, 2012 at 19:37, Ted Kremenek <kremenek at apple.com> wrote:
> On Feb 20, 2012, at 11:25 AM, Hans Wennborg <hans at chromium.org> wrote:
>>  Keeping -Wformat-nonstandard out of -Wformat and having it in
>>  -pedantic sounds perfectly fine to me. I expect that lines up with
>>  what gcc does too.
>
> Ok, I think that approach is worth experimenting with.

Cool. I think getting this warning in under -pedantic is a good step
in the right direction.

> I've looked at the patch, and other than the default configuration of the
> warnings, it looks okay to me.

I've updated the patch to make the warning DefaultIgnore and ExtWarn.

I've also changed it to not make a difference between -std=c99 and
-std=gnu99. If the user specifies -pedantic, I think we should warn
for '%ms' even if the user has selected -std=gnu99. This matches gcc
behavior too, and it's extra important because if the user doesn't
specify the -std flag, then gnu99 seems the be the default c mode.

> One nit on wording in the diagnostic: "non-standard" or "non-portable"?  The
> former is more technically accurate, but the latter is the implication the
> user cares about.  What do you think?

I'd prefer "non-standard", but I don't feel strongly about it.

I noticed that this sparks new failures in
"clang-tests/gcc-4_2-testsuite" (excess warning), so I'm attaching a
patch for that too. Please take a look.

 - Hans
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-testsuite.diff
Type: application/octet-stream
Size: 745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120221/1b7ec845/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: non-standard-format-strings-2.diff
Type: application/octet-stream
Size: 14061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120221/1b7ec845/attachment-0001.obj>


More information about the cfe-commits mailing list