1 // RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso -fblocks -std=c++11 %s
3 __attribute__((format(scanf
, 1, 2)))
4 int scanf(const char *, ...);
6 template<typename
... Args
>
7 __attribute__((format(scanf
, 1, 2)))
8 int scan(const char *fmt
, Args
&&...args
) { // expected-warning{{GCC requires a function with the 'format' attribute to be variadic}}
9 return scanf(fmt
, args
...);
22 unsigned long long ull
;
32 // expected-warning@+2 {{format specifies type 'char *' but the argument has type 'bool *'}}
33 // expected-warning@+1 {{format specifies type 'unsigned char *' but the argument has type 'bool *'}}
34 scan("%hhi %hhu %hhi %hhu", &b
.sc
, &b
.uc
, &b
.b
, &b
.b
);
35 scan("%hi %hu", &b
.ss
, &b
.us
);
36 scan("%i %u", &b
.si
, &b
.ui
);
37 scan("%li %lu", &b
.sl
, &b
.ul
);
38 scan("%lli %llu", &b
.sll
, &b
.ull
);
43 // expected-warning@+4{{format specifies type 'short *' but the argument has type 'signed char *'}}
44 // expected-warning@+3{{format specifies type 'unsigned short *' but the argument has type 'unsigned char *'}}
45 // expected-warning@+2{{format specifies type 'short *' but the argument has type 'bool *'}}
46 // expected-warning@+1{{format specifies type 'unsigned short *' but the argument has type 'bool *'}}
47 scan("%hi %hu %hi %hu", &b
.sc
, &b
.uc
, &b
.b
, &b
.b
);
49 // expected-warning@+3{{format specifies type 'long *' but the argument has type 'short *'}}
50 // expected-warning@+2{{format specifies type 'char *' but the argument has type 'short *'}}
51 // expected-warning@+1{{format specifies type 'int *' but the argument has type 'short *'}}
52 scan("%hhi %i %li", &b
.ss
, &b
.ss
, &b
.ss
);
54 // expected-warning@+3{{format specifies type 'float *' but the argument has type '__fp16 *'}}
55 // expected-warning@+2{{format specifies type 'float *' but the argument has type 'double *'}}
56 // expected-warning@+1{{format specifies type 'float *' but the argument has type 'long double *'}}
57 scan("%f %f %f", &b
.f16
, &b
.fd
, &b
.fl
);
59 // expected-warning@+3{{format specifies type 'double *' but the argument has type '__fp16 *'}}
60 // expected-warning@+2{{format specifies type 'double *' but the argument has type 'float *'}}
61 // expected-warning@+1{{format specifies type 'double *' but the argument has type 'long double *'}}
62 scan("%lf %lf %lf", &b
.f16
, &b
.ff
, &b
.fl
);
64 // expected-warning@+3{{format specifies type 'long double *' but the argument has type '__fp16 *'}}
65 // expected-warning@+2{{format specifies type 'long double *' but the argument has type 'float *'}}
66 // expected-warning@+1{{format specifies type 'long double *' but the argument has type 'double *'}}
67 scan("%Lf %Lf %Lf", &b
.f16
, &b
.ff
, &b
.fd
);