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
8 # define EXTERN_C extern "C"
10 # define EXTERN_C extern
13 EXTERN_C
int printf(const char *,...);
14 EXTERN_C
int scanf(const char *, ...);
16 typedef enum { Constant
= 0 } TestEnum
;
17 // Note that in C, the type of 'Constant' is 'int'. In C++ it is 'TestEnum'.
18 // This is why we don't check for that in the expected output.
20 void test(TestEnum input
) {
21 printf("%d", input
); // no-warning
22 printf("%d", Constant
); // no-warning
24 printf("%lld", input
); // expected-warning-re{{format specifies type 'long long' but the argument has underlying type '{{(unsigned)?}} int'}}
25 printf("%lld", Constant
); // expected-warning{{format specifies type 'long long'}}
29 typedef enum { LongConstant
= ~0UL } LongEnum
;
31 void testLong(LongEnum input
) {
32 printf("%u", input
); // expected-warning{{format specifies type 'unsigned int' but the argument has underlying type}}
33 printf("%u", LongConstant
); // expected-warning{{format specifies type 'unsigned int'}}
36 printf("%lu", LongConstant
);
40 // GNU C allows forward declaring enums.
41 extern enum forward_declared
*fwd
;
43 void forward_enum(void) {
44 printf("%u", fwd
); // expected-warning{{format specifies type 'unsigned int' but the argument has type 'enum forward_declared *}}
47 scanf("%c", fwd
); // expected-warning{{format specifies type 'char *' but the argument has type 'enum forward_declared *}}
49 scanf("%lu", fwd
); // expected-warning{{format specifies type 'unsigned long *' but the argument has type 'enum forward_declared *}}
50 scanf("%p", fwd
); // expected-warning{{format specifies type 'void **' but the argument has type 'enum forward_declared *}}