diff options
-rw-r--r-- | test/Sema/format-strings-scanf.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c new file mode 100644 index 0000000000..cd68410693 --- /dev/null +++ b/test/Sema/format-strings-scanf.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s + +typedef __typeof(sizeof(int)) size_t; +typedef struct _FILE FILE; + +int fscanf(FILE * restrict, const char * restrict, ...) ; +int scanf(const char * restrict, ...) ; +int sscanf(const char * restrict, const char * restrict, ...) ; + +void test(const char *s, int *i) { + scanf(s, i); // expected-warning{{ormat string is not a string literal}} + scanf("%0d", i); // expected-warning{{conversion specifies 0 input characters for field width}} + scanf("%00d", i); // expected-warning{{conversion specifies 0 input characters for field width}} +} |