[cfe-commits] [Patch] Make -Wformat check the argument type for %n

Hans Wennborg hans at chromium.org
Mon Jul 30 10:14:00 PDT 2012


Thanks! Committed in r160966 with the extra test you suggested.

 - Hans

On Mon, Jul 30, 2012 at 5:46 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> Looks good to me. I'd add this second case to test_writeback as well, to make sure that we don't regress on the "keep going" for scanf.
>
> void test_writeback(int *x) {
>   scanf("%n", (void*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'void *'}}
>   scanf("%n %c", x, x); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}}
> }
>
> Thanks, Hans!
>
> On Jul 30, 2012, at 2:00 AM, Hans Wennborg <hans at chromium.org> wrote:
>
>> Hi all,
>>
>> The attached patch makes Clang check that the corresponding argument
>> for "%n" in a format string is int*.



More information about the cfe-commits mailing list