diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Sema/format-strings-scanf.c | 4 | ||||
-rw-r--r-- | clang/test/Sema/format-strings.c | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/Sema/format-strings-scanf.c b/clang/test/Sema/format-strings-scanf.c index d89dbc494b7..c97da3fd921 100644 --- a/clang/test/Sema/format-strings-scanf.c +++ b/clang/test/Sema/format-strings-scanf.c @@ -53,6 +53,10 @@ void pr9751() { const char kFormat2[] = "%["; // expected-note{{format string is defined here}}} scanf(kFormat2, str); // expected-warning{{no closing ']' for '%[' in scanf format string}} scanf("%[", str); // expected-warning{{no closing ']' for '%[' in scanf format string}} + const char kFormat3[] = "%hu"; // expected-note{{format string is defined here}}} + scanf(kFormat3, &i); // expected-warning {{format specifies type 'unsigned short *' but the argument}} + const char kFormat4[] = "%lp"; // expected-note{{format string is defined here}}} + scanf(kFormat4, &i); // expected-warning {{length modifier 'l' results in undefined behavior or no effect with 'p' conversion specifier}} } void test_variants(int *i, const char *s, ...) { diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c index 341fd599080..3a95df5038c 100644 --- a/clang/test/Sema/format-strings.c +++ b/clang/test/Sema/format-strings.c @@ -468,6 +468,9 @@ void pr9751() { // Make sure that the "format string is defined here" note is not emitted // when the original string is within the argument expression. printf(1 ? "yes %d" : "no %d"); // expected-warning 2{{more '%' conversions than data arguments}} + + const char kFormat17[] = "%hu"; // expected-note{{format string is defined here}}} + printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}} } // PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx |