Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Sema / warn-compare-enum-types-mismatch.c
blob47dd592488e6dce440e0a70442dfb276474a2f90
1 // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s
2 // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s
4 // In C enumerators (i.e enumeration constants) have type int (until C23). In
5 // order to support diagnostics such as -Wenum-compare we pretend they have the
6 // type of their enumeration.
8 typedef enum EnumA {
10 } EnumA;
12 enum EnumB {
14 B1 = 1,
15 // In C++ this comparison doesnt warn as enumerators dont have the type of
16 // their enumeration before the closing brace. We mantain the same behavior
17 // in C.
18 B2 = A == B1
21 enum {
25 void foo(void) {
26 enum EnumA a = A;
27 enum EnumB b = B;
28 A == B;
29 // expected-warning@-1 {{comparison of different enumeration types}}
30 a == (B);
31 // expected-warning@-1 {{comparison of different enumeration types}}
32 a == b;
33 // expected-warning@-1 {{comparison of different enumeration types}}
34 A > B;
35 // expected-warning@-1 {{comparison of different enumeration types}}
36 A >= b;
37 // expected-warning@-1 {{comparison of different enumeration types}}
38 a > b;
39 // expected-warning@-1 {{comparison of different enumeration types}}
40 (A) <= ((B));
41 // expected-warning@-1 {{comparison of different enumeration types}}
42 a < B;
43 // expected-warning@-1 {{comparison of different enumeration types}}
44 a < b;
45 // expected-warning@-1 {{comparison of different enumeration types}}
47 // In the following cases we purposefully differ from GCC and dont warn
48 a == C;
49 A < C;
50 b >= C;