1// RUN: %check_clang_tidy -std=c++98-or-later %s bugprone-tagged-union-member-count %t \
2// RUN: -config='{CheckOptions: { \
3// RUN: bugprone-tagged-union-member-count.StrictMode: false, \
4// RUN: bugprone-tagged-union-member-count.EnableCountingEnumHeuristic: true, \
5// RUN: bugprone-tagged-union-member-count.CountingEnumPrefixes: "maxsize;last", \
6// RUN: }}' --
7
8union Union4 {
9 short *Shorts;
10 double *Doubles;
11 int *Ints;
12 float *Floats;
13};
14
15// CHECK-MESSAGES: :[[@LINE+1]]:8: warning: tagged union has more data members (4) than tags (3)
16struct TaggedUnionWithMaxsizeAsCounterPrefix {
17 enum {
18 twc1,
19 twc2,
20 twc3,
21 maxsizetwc,
22 } Kind;
23 Union4 Data;
24};
25
26// CHECK-MESSAGES: :[[@LINE+1]]:8: warning: tagged union has more data members (4) than tags (3)
27struct TaggedUnionWithLastAsCounterPrefix {
28 enum {
29 twc11,
30 twc22,
31 twc33,
32 lasttwc,
33 } Kind;
34 Union4 Data;
35};
36

source code of clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count-counting-enum-prefixes.cpp