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
13EXTERN_C int printf(const char *,...);
14
15typedef 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
19void test(TestEnum input) {
20    printf("%d", input); // no-warning
21    printf("%d", Constant); // no-warning
22
23    printf("%lld", input); // expected-warning-re{{format specifies type 'long long' but the argument has underlying type '{{(unsigned)?}} int'}}
24    printf("%lld", Constant); // expected-warning{{format specifies type 'long long'}}
25}
26
27
28typedef enum { LongConstant = ~0UL } LongEnum;
29
30void testLong(LongEnum input) {
31  printf("%u", input); // expected-warning{{format specifies type 'unsigned int' but the argument has underlying type}}
32  printf("%u", LongConstant); // expected-warning{{format specifies type 'unsigned int'}}
33
34  printf("%lu", input);
35  printf("%lu", LongConstant);
36}
37