Jordan Rose | ee0259d | 2012-06-04 22:48:57 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -verify %s |
| 2 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x c++ -verify %s |
| 3 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x c++ -std=c++11 -verify %s |
| 4 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c -verify %s |
| 5 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c++ -std=c++11 -verify %s |
| 6 | |
| 7 | #ifdef __cplusplus |
| 8 | # define EXTERN_C extern "C" |
| 9 | #else |
| 10 | # define EXTERN_C extern |
| 11 | #endif |
| 12 | |
| 13 | EXTERN_C int printf(const char *,...); |
| 14 | |
| 15 | typedef enum { Constant = 0 } TestEnum; |
| 16 | // Note that in C, the type of 'Constant' is 'int'. In C++ it is 'TestEnum'. |
| 17 | // This is why we don't check for that in the expected output. |
| 18 | |
| 19 | void test(TestEnum input) { |
| 20 | printf("%d", input); // no-warning |
| 21 | printf("%d", Constant); // no-warning |
| 22 | |
| 23 | printf("%lld", input); // expected-warning{{format specifies type 'long long' but the argument has type 'TestEnum'}} |
| 24 | printf("%lld", Constant); // expected-warning{{format specifies type 'long long'}} |
| 25 | } |
| 26 | |
| 27 | |
| 28 | typedef enum { LongConstant = ~0UL } LongEnum; |
| 29 | |
| 30 | void testLong(LongEnum input) { |
| 31 | printf("%u", input); // expected-warning{{format specifies type 'unsigned int' but the argument has type 'LongEnum'}} |
| 32 | printf("%u", LongConstant); // expected-warning{{format specifies type 'unsigned int'}} |
| 33 | |
| 34 | printf("%lu", input); |
| 35 | printf("%lu", LongConstant); |
| 36 | } |