[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / warn-conditional-emum-types-mismatch.c
blobc9e2eddc7764bd6b328be2bb0947cfc2210766cb
1 // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wenum-compare-conditional %s
2 // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wenum-compare-conditional %s
4 enum ro { A = 0x10 };
5 enum rw { B = 0xFF };
6 enum { C = 0x1A};
8 enum {
9 STATUS_SUCCESS,
10 STATUS_FAILURE,
11 MAX_BASE_STATUS_CODE
14 enum ExtendedStatusCodes {
15 STATUS_SOMETHING_INTERESTING = MAX_BASE_STATUS_CODE + 1000,
19 int get_flag(int cond) {
20 return cond ? A : B;
21 #ifdef __cplusplus
22 // expected-warning@-2 {{conditional expression between different enumeration types ('ro' and 'rw')}}
23 #else
24 // expected-no-diagnostics
25 #endif
28 // In the following cases we purposefully differ from GCC and dont warn because
29 // this code pattern is quite sensitive and we dont want to produce so many false positives.
31 int get_flag_anon_enum(int cond) {
32 return cond ? A : C;
35 int foo(int c) {
36 return c ? STATUS_SOMETHING_INTERESTING : STATUS_SUCCESS;