1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -Wformat-non-iso -DALLOWED %s
2*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -triple thumbv6-apple-ios4.0 -Wformat-non-iso -DALLOWED %s
3*67e74705SXin Li
4*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-mingw32 -Wformat-non-iso %s
5*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -triple i686-pc-win32 -Wformat-non-iso %s
6*67e74705SXin Li
7*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -Wformat-non-iso %s
8*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd -Wformat-non-iso %s
9*67e74705SXin Li
10*67e74705SXin Li int printf(const char *restrict, ...);
11*67e74705SXin Li int scanf(const char * restrict, ...) ;
12*67e74705SXin Li
test()13*67e74705SXin Li void test() {
14*67e74705SXin Li int justRight = 1;
15*67e74705SXin Li long tooLong = 2;
16*67e74705SXin Li
17*67e74705SXin Li printf("%D", justRight);
18*67e74705SXin Li printf("%D", tooLong);
19*67e74705SXin Li printf("%U", justRight);
20*67e74705SXin Li printf("%U", tooLong);
21*67e74705SXin Li printf("%O", justRight);
22*67e74705SXin Li printf("%O", tooLong);
23*67e74705SXin Li
24*67e74705SXin Li #ifdef ALLOWED
25*67e74705SXin Li // expected-warning@-8 {{'D' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'd'?}}
26*67e74705SXin Li // expected-warning@-8 {{'D' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'd'?}} expected-warning@-8 {{format specifies type 'int' but the argument has type 'long'}}
27*67e74705SXin Li // expected-warning@-8 {{'U' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'u'?}}
28*67e74705SXin Li // expected-warning@-8 {{'U' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'u'?}} expected-warning@-8 {{format specifies type 'unsigned int' but the argument has type 'long'}}
29*67e74705SXin Li // expected-warning@-8 {{'O' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'o'?}}
30*67e74705SXin Li // expected-warning@-8 {{'O' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'o'?}} expected-warning@-8 {{format specifies type 'unsigned int' but the argument has type 'long'}}
31*67e74705SXin Li #else
32*67e74705SXin Li // expected-warning@-15 {{invalid conversion specifier 'D'}}
33*67e74705SXin Li // expected-warning@-15 {{invalid conversion specifier 'D'}}
34*67e74705SXin Li // expected-warning@-15 {{invalid conversion specifier 'U'}}
35*67e74705SXin Li // expected-warning@-15 {{invalid conversion specifier 'U'}}
36*67e74705SXin Li // expected-warning@-15 {{invalid conversion specifier 'O'}}
37*67e74705SXin Li // expected-warning@-15 {{invalid conversion specifier 'O'}}
38*67e74705SXin Li #endif
39*67e74705SXin Li }
40*67e74705SXin Li
41*67e74705SXin Li #ifdef ALLOWED
testPrintf(short x,long y)42*67e74705SXin Li void testPrintf(short x, long y) {
43*67e74705SXin Li printf("%hD", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
44*67e74705SXin Li printf("%lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
45*67e74705SXin Li printf("%hU", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
46*67e74705SXin Li printf("%lU", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
47*67e74705SXin Li printf("%hO", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
48*67e74705SXin Li printf("%lO", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
49*67e74705SXin Li
50*67e74705SXin Li printf("%+'0.5lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
51*67e74705SXin Li printf("% '0.5lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
52*67e74705SXin Li printf("%#0.5lO", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
53*67e74705SXin Li printf("%'0.5lU", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
54*67e74705SXin Li }
55*67e74705SXin Li
testScanf(short * x,long * y)56*67e74705SXin Li void testScanf(short *x, long *y) {
57*67e74705SXin Li scanf("%hD", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
58*67e74705SXin Li scanf("%lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
59*67e74705SXin Li scanf("%hU", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
60*67e74705SXin Li scanf("%lU", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
61*67e74705SXin Li scanf("%hO", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
62*67e74705SXin Li scanf("%lO", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
63*67e74705SXin Li }
64*67e74705SXin Li #endif
65