blob: e79f8598ab4734cbc9a8da16d3866acea18f0942 [file] [log] [blame]
Jordan Rose98709982012-06-04 22:48:57 +00001// 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
Jordan Rosebc53ed12014-05-31 04:12:14 +000023 printf("%lld", input); // expected-warning-re{{format specifies type 'long long' but the argument has underlying type '{{(unsigned)?}} int'}}
Jordan Rose98709982012-06-04 22:48:57 +000024 printf("%lld", Constant); // expected-warning{{format specifies type 'long long'}}
25}
26
27
28typedef enum { LongConstant = ~0UL } LongEnum;
29
30void testLong(LongEnum input) {
Jordan Rosebc53ed12014-05-31 04:12:14 +000031 printf("%u", input); // expected-warning{{format specifies type 'unsigned int' but the argument has underlying type}}
Jordan Rose98709982012-06-04 22:48:57 +000032 printf("%u", LongConstant); // expected-warning{{format specifies type 'unsigned int'}}
33
34 printf("%lu", input);
35 printf("%lu", LongConstant);
36}