llvm-project/clang/test/Sema/format-strings-scanf.c

19 lines
761 B
C
Raw Normal View History

// 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{{zero field width in scanf format string is unused}}
scanf("%00d", i); // expected-warning{{zero field width in scanf format string is unused}}
scanf("%d%[asdfasdfd", i, s); // expected-warning{{no closing ']' for '%[' in scanf format string}}
unsigned short s_x;
scanf ("%" "hu" "\n", &s_x); // no-warning
}