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