| 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 | |
| 10 | enum E {}; |
| 11 | // CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead |
| 12 | |
| 13 | enum class EC {}; |
| 14 | |
| 15 | enum struct ES {}; |
| 16 | |
| 17 | struct 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 | |
| 23 | class 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 | |
| 29 | template<class T> |
| 30 | class 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 | |
| 36 | union 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 | |
| 42 | namespace { |
| 43 | enum E {}; |
| 44 | // CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead |
| 45 | enum class EC {}; |
| 46 | } // namespace |
| 47 | |
| 48 | namespace N { |
| 49 | enum E {}; |
| 50 | // CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead |
| 51 | enum class EC {}; |
| 52 | } // namespace N |
| 53 | |
| 54 | template<enum ::EC> |
| 55 | static void foo(); |
| 56 | |
| 57 | enum ForwardE : int; |
| 58 | // CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'ForwardE' is unscoped, use 'enum class' instead |
| 59 | |
| 60 | enum class ForwardEC : int; |
| 61 | |
| 62 | enum struct ForwardES : int; |
| 63 | |