63 lines · cpp
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' instead12 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' instead20 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' instead26 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' instead33 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' instead39 enum class EC {};40};41 42namespace {43enum E {};44// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead45enum class EC {};46} // namespace47 48namespace N {49enum E {};50// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead51enum class EC {};52} // namespace N53 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' instead59 60enum class ForwardEC : int;61 62enum struct ForwardES : int;63