1 // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -triple thumbv6-apple-ios4.0 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-mingw32 -DMS %s
4 // RUN: %clang_cc1 -fsyntax-only -verify -triple i686-pc-win32 -DMS %s
6 // RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -DALLOWED %s
7 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd -DALLOWED %s
9 int printf(const char *restrict
, ...);
10 int scanf(const char * restrict
, ...) ;
13 long notLongEnough
= 1;
14 long long quiteLong
= 2;
16 printf("%Ld", notLongEnough
); // expected-warning {{format specifies type 'long long' but the argument has type 'long'}}
17 printf("%Ld", quiteLong
);
20 // expected-warning@-4 {{length modifier 'L' results in undefined behavior or no effect with 'd' conversion specifier}}
21 // expected-note@-5 {{did you mean to use 'll'?}}
23 // expected-warning@-6 {{length modifier 'L' results in undefined behavior or no effect with 'd' conversion specifier}}
24 // expected-note@-7 {{did you mean to use 'll'?}}
28 printf("%Z\n", quiteLong
); // expected-warning{{invalid conversion specifier 'Z'}}
32 void testAlwaysInvalid(void) {
33 // We should not suggest 'll' here!
34 printf("%Lc", 'a'); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 'c' conversion specifier}}
35 printf("%Ls", "a"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
39 // PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx
40 void printf_longlong(long long x
, unsigned long long y
) {
41 printf("%Ld", y
); // no-warning
42 printf("%Lu", y
); // no-warning
43 printf("%Lx", y
); // no-warning
44 printf("%Ld", x
); // no-warning
45 printf("%Lu", x
); // no-warning
46 printf("%Lx", x
); // no-warning
47 printf("%Ls", "hello"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
50 void scanf_longlong(long long *x
, unsigned long long *y
) {
51 scanf("%Ld", y
); // no-warning
52 scanf("%Lu", y
); // no-warning
53 scanf("%Lx", y
); // no-warning
54 scanf("%Ld", x
); // no-warning
55 scanf("%Lu", x
); // no-warning
56 scanf("%Lx", x
); // no-warning
57 scanf("%Ls", "hello"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}