1// RUN: %check_clang_tidy -std=c++11-or-later -check-suffix=ALL,DEFAULT %s \
2// RUN: cppcoreguidelines-use-enum-class %t --
3
4// RUN: %check_clang_tidy -std=c++11-or-later -check-suffix=ALL %s \
5// RUN: cppcoreguidelines-use-enum-class %t -- \
6// RUN: -config="{CheckOptions: { \
7// RUN: cppcoreguidelines-use-enum-class.IgnoreUnscopedEnumsInClasses: true \
8// RUN: }}" --
9
10enum E {};
11// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead
12
13enum class EC {};
14
15enum struct ES {};
16
17struct S {
18 enum E {};
19 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
20 enum class EC {};
21};
22
23class C {
24 enum E {};
25 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
26 enum class EC {};
27};
28
29template<class T>
30class TC {
31 enum E {};
32 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
33 enum class EC {};
34};
35
36union U {
37 enum E {};
38 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
39 enum class EC {};
40};
41
42namespace {
43enum E {};
44// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead
45enum class EC {};
46} // namespace
47
48namespace N {
49enum E {};
50// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead
51enum class EC {};
52} // namespace N
53
54template<enum ::EC>
55static void foo();
56
57enum ForwardE : int;
58// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'ForwardE' is unscoped, use 'enum class' instead
59
60enum class ForwardEC : int;
61
62enum struct ForwardES : int;
63

source code of clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/use-enum-class.cpp