1 // RUN: %check_clang_tidy %s bugprone-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: bugprone-suspicious-enum-usage.StrictMode, value: 0}]}" --
2
3 enum Empty {
4 };
5
6 enum A {
7 A = 1,
8 B = 2,
9 C = 4,
10 D = 8,
11 E = 16,
12 F = 32,
13 G = 63
14 };
15
16 enum X {
17 X = 8,
18 Y = 16,
19 Z = 4
20 };
21
22 enum {
23 P = 2,
24 Q = 3,
25 R = 4,
26 S = 8,
27 T = 16
28 };
29
30 enum {
31 H,
32 I,
33 J,
34 K,
35 L
36 };
37
38 enum Days {
39 Monday,
40 Tuesday,
41 Wednesday,
42 Thursday,
43 Friday,
44 Saturday,
45 Sunday
46 };
47
bestDay()48 Days bestDay() {
49 return Friday;
50 }
51
trigger()52 int trigger() {
53 Empty EmptyVal;
54 int emptytest = EmptyVal | B;
55 if (bestDay() | A)
56 return 1;
57 // CHECK-NOTES: :[[@LINE-2]]:17: warning: enum values are from different enum types
58 if (I | Y)
59 return 1;
60 // CHECK-NOTES: :[[@LINE-2]]:9: warning: enum values are from different enum types
61 }
62
dont_trigger()63 int dont_trigger() {
64 unsigned p;
65 p = Q | P;
66
67 if (A + G == E)
68 return 1;
69 else if ((Q | R) == T)
70 return 1;
71 else
72 int k = T | Q;
73
74 Empty EmptyVal;
75 int emptytest = EmptyVal | B;
76
77 int a = 1, b = 5;
78 int c = a + b;
79 int d = c | H, e = b * a;
80 a = B | C;
81 b = X | Z;
82
83 if (Tuesday != Monday + 1 ||
84 Friday - Thursday != 1 ||
85 Sunday + Wednesday == (Sunday | Wednesday))
86 return 1;
87 if (H + I + L == 42)
88 return 1;
89 return 42;
90 }
91
92 namespace PR34400 {
93 enum { E1 = 0 };
94 enum { E2 = -1 };
95 enum { l = E1 | E2 };
96 }
97