Jordan Rose | 275b6f5 | 2012-09-13 02:11:03 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -pedantic -DALLOWED %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -verify -triple thumbv6-apple-ios4.0 -pedantic -DALLOWED %s |
| 3 | |
| 4 | // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-mingw32 -pedantic %s |
| 5 | // RUN: %clang_cc1 -fsyntax-only -verify -triple i686-pc-win32 -pedantic %s |
| 6 | |
| 7 | // RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -pedantic %s |
| 8 | // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd -pedantic %s |
| 9 | |
| 10 | int printf(const char *restrict, ...); |
| 11 | int scanf(const char * restrict, ...) ; |
| 12 | |
| 13 | void test() { |
| 14 | int justRight = 1; |
| 15 | long tooLong = 2; |
| 16 | |
| 17 | printf("%D", justRight); |
| 18 | printf("%D", tooLong); |
| 19 | printf("%U", justRight); |
| 20 | printf("%U", tooLong); |
| 21 | printf("%O", justRight); |
| 22 | printf("%O", tooLong); |
| 23 | |
| 24 | #ifdef ALLOWED |
Jordan Rose | 670941c | 2012-09-13 02:11:15 +0000 | [diff] [blame] | 25 | // expected-warning@-8 {{'D' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'd'?}} |
| 26 | // 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 | // expected-warning@-8 {{'U' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'u'?}} |
| 28 | // 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 | // expected-warning@-8 {{'O' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'o'?}} |
| 30 | // 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'}} |
Jordan Rose | 275b6f5 | 2012-09-13 02:11:03 +0000 | [diff] [blame] | 31 | #else |
| 32 | // expected-warning@-15 {{invalid conversion specifier 'D'}} |
| 33 | // expected-warning@-15 {{invalid conversion specifier 'D'}} |
| 34 | // expected-warning@-15 {{invalid conversion specifier 'U'}} |
| 35 | // expected-warning@-15 {{invalid conversion specifier 'U'}} |
| 36 | // expected-warning@-15 {{invalid conversion specifier 'O'}} |
| 37 | // expected-warning@-15 {{invalid conversion specifier 'O'}} |
| 38 | #endif |
| 39 | } |
| 40 | |
| 41 | #ifdef ALLOWED |
| 42 | void testPrintf(short x, long y) { |
Jordan Rose | 670941c | 2012-09-13 02:11:15 +0000 | [diff] [blame] | 43 | printf("%hD", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}} |
| 44 | printf("%lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}} |
| 45 | printf("%hU", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}} |
| 46 | printf("%lU", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}} |
| 47 | printf("%hO", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}} |
| 48 | printf("%lO", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}} |
Jordan Rose | 275b6f5 | 2012-09-13 02:11:03 +0000 | [diff] [blame] | 49 | |
Jordan Rose | 670941c | 2012-09-13 02:11:15 +0000 | [diff] [blame] | 50 | printf("%+'0.5lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}} |
| 51 | printf("% '0.5lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}} |
| 52 | printf("%#0.5lO", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}} |
| 53 | printf("%'0.5lU", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}} |
Jordan Rose | 275b6f5 | 2012-09-13 02:11:03 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | void testScanf(short *x, long *y) { |
Jordan Rose | 670941c | 2012-09-13 02:11:15 +0000 | [diff] [blame] | 57 | scanf("%hD", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}} |
| 58 | scanf("%lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}} |
| 59 | scanf("%hU", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}} |
| 60 | scanf("%lU", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}} |
| 61 | scanf("%hO", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}} |
| 62 | scanf("%lO", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}} |
Jordan Rose | 275b6f5 | 2012-09-13 02:11:03 +0000 | [diff] [blame] | 63 | } |
| 64 | #endif |