1 // RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays %t -- -extra-arg=-Wunused-variable
4 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
7 class B1
{ B1(int i
); };
13 class B2
{ B2(int i
); };
18 class B3
{ B3(int i
); };
25 class B4
{ B4(int i
); };
30 class B5
{ B5(int i
); };
31 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
33 // NOLINTBEGIN(google-explicit-constructor)
34 class C1
{ C1(int i
); };
35 // NOLINTEND(google-explicit-constructor)
38 class C2
{ C2(int i
); };
39 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
43 class C3
{ C3(int i
); };
46 // NOLINTBEGIN(some-other-check)
47 class C4
{ C4(int i
); };
48 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
49 // NOLINTEND(some-other-check)
51 // NOLINTBEGIN(some-other-check, google-explicit-constructor)
52 class C5
{ C5(int i
); };
53 // NOLINTEND(some-other-check, google-explicit-constructor)
55 // NOLINTBEGIN(google-explicit-constructor)
56 // NOLINTBEGIN(some-other-check)
57 class C6
{ C6(int i
); };
58 // NOLINTEND(some-other-check)
59 // NOLINTEND(google-explicit-constructor)
61 // NOLINTBEGIN(google-explicit-constructor)
63 class C7
{ C7(int i
); };
65 // NOLINTEND(google-explicit-constructor)
68 // NOLINTBEGIN(google-explicit-constructor)
69 class C8
{ C8(int i
); };
70 // NOLINTEND(google-explicit-constructor)
73 // NOLINTBEGIN(not-closed-bracket-is-treated-as-skip-all
74 class C9
{ C9(int i
); };
75 // NOLINTEND(not-closed-bracket-is-treated-as-skip-all
77 // NOLINTBEGIN without-brackets-skip-all, another-check
78 class C10
{ C10(int i
); };
79 // NOLINTEND without-brackets-skip-all, another-check
81 #define MACRO(X) class X { X(int i); };
84 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
85 // CHECK-MESSAGES: :[[@LINE-4]]:28: note: expanded from macro 'MACRO
91 #define MACRO_NOARG class E { E(int i); };
98 #define MACRO_WRAPPED_WITH_NO_LINT class I { I(int i); };
101 MACRO_WRAPPED_WITH_NO_LINT
103 #define MACRO_NO_LINT_INSIDE_MACRO \
105 class J { J(int i); }; \
108 MACRO_NO_LINT_INSIDE_MACRO
110 // NOLINTBEGIN(google*)
111 class C11
{ C11(int i
); };
112 // NOLINTEND(google*)
114 // NOLINTBEGIN(*explicit-constructor)
115 class C12
{ C12(int i
); };
116 // NOLINTEND(*explicit-constructor)
118 // NOLINTBEGIN(*explicit*)
119 class C13
{ C13(int i
); };
120 // NOLINTEND(*explicit*)
122 // NOLINTBEGIN(-explicit-constructor)
123 class C14
{ C14(int x
); };
124 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
125 // NOLINTEND(-explicit-constructor)
127 // NOLINTBEGIN(google*,-google*)
128 class C15
{ C15(int x
); };
129 // NOLINTEND(google*,-google*)
131 // NOLINTBEGIN(*,-google*)
132 class C16
{ C16(int x
); };
133 // NOLINTEND(*,-google*)
136 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
138 // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays)
140 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]
141 // NOLINTEND(cppcoreguidelines-avoid-c-arrays)
143 // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
145 // NOLINTEND(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
147 // NOLINTBEGIN(*-avoid-c-arrays)
149 // NOLINTEND(*-avoid-c-arrays)
151 // CHECK-MESSAGES: Suppressed 26 warnings (26 NOLINT).