diff options
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/format-strings-scanf.c | 7 | ||||
-rw-r--r-- | test/Sema/format-strings.c | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c index 5d2a7a7a9b..68552b3e24 100644 --- a/test/Sema/format-strings-scanf.c +++ b/test/Sema/format-strings-scanf.c @@ -16,4 +16,11 @@ void test(const char *s, int *i) { unsigned short s_x; scanf ("%" "hu" "\n", &s_x); // no-warning scanf("%y", i); // expected-warning{{invalid conversion specifier 'y'}} + scanf("%%"); // no-warning + scanf("%%%1$d", i); // no-warning + scanf("%1$d%%", i); // no-warning + scanf("%d", i, i); // expected-warning{{data argument not used by format string}} + scanf("%*d", i); // // expected-warning{{data argument not used by format string}} + scanf("%*d", i); // // expected-warning{{data argument not used by format string}} + scanf("%*d%1$d", i); // no-warning } diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index c6dee6801e..080e4dbeb5 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -239,6 +239,8 @@ void test_positional_arguments() { 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}} + printf("%%%1$d", (int) 2); // no-warning + printf("%1$d%%", (int) 2); // no-warning } // PR 6697 - Handle format strings where the data argument is not adjacent to the format string |