diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-02-27 01:41:03 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-02-27 01:41:03 +0000 |
commit | d166819c26a89177cfad7262b0c0e2c52c107945 (patch) | |
tree | 3c719968fefc17f91a29cc808bdd758aeac677a4 /clang/test/Sema/format-strings.c | |
parent | 89a56c561f7ea5970167695e86e2eaf4e0155d55 (diff) | |
download | bcm5719-llvm-d166819c26a89177cfad7262b0c0e2c52c107945.tar.gz bcm5719-llvm-d166819c26a89177cfad7262b0c0e2c52c107945.zip |
For printf format string checking, add support for positional format strings.
Along the way, coelesce some of the diagnostics.
llvm-svn: 97297
Diffstat (limited to 'clang/test/Sema/format-strings.c')
-rw-r--r-- | clang/test/Sema/format-strings.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c index 191996004dd..e92e17da084 100644 --- a/clang/test/Sema/format-strings.c +++ b/clang/test/Sema/format-strings.c @@ -221,3 +221,16 @@ void test_unicode_conversions(wchar_t *s) { printf("%S", "hello"); // expected-warning{{but the argument has type 'char *'}} } +// Mac OS X supports positional arguments in format strings. +// This is an IEEE extension (IEEE Std 1003.1). +// FIXME: This is probably not portable everywhere. +void test_positional_arguments() { + printf("%0$", (int)2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}} + printf("%1$d", (int) 2); // no-warning + printf("%1$d", (int) 2, 2); // expected-warning{{data argument not used by format string}} + printf("%1$d%1$f", (int) 2); // expected-warning{{conversion specifies type 'double' but the argument has type 'int'}} + printf("%1$2.2d", (int) 2); // no-warning + printf("%2$*1$.2d", (int) 2, (int) 3); // no-warning + printf("%2$*8$d", (int) 2, (int) 3); // expected-warning{{specified field width is missing a matching 'int' argument}} +} + |