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

Jordan Rose jordan_rose at apple.com
Mon Jul 30 09:46:01 PDT 2012


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*.
> 
> Please take a look!
> 
> Thanks,
> Hans
> <wformat_check_n_argument_type.patch>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list