1 // RUN: %check_clang_tidy %s modernize-redundant-void-arg %t
2 
3 #define NULL 0
4 
5 int foo();
6 
7 void bar();
8 
9 void bar2();
10 
11 extern "C" void ecfoo(void);
12 
ecfoo(void)13 extern "C" void ecfoo(void) {
14 }
15 
16 extern int i;
17 
18 int j = 1;
19 
foo(void)20 int foo(void) {
21 // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
22 // CHECK-FIXES: {{^}}int foo() {{{$}}
23     return 0;
24 }
25 
26 typedef unsigned int my_uint;
27 
28 typedef void my_void;
29 
30 // A function taking void and returning a pointer to function taking void
31 // and returning int.
32 int (*returns_fn_void_int(void))(void);
33 // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} in function declaration
34 // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: {{.*}} in function declaration
35 // CHECK-FIXES: {{^}}int (*returns_fn_void_int())();{{$}}
36 
37 typedef int (*returns_fn_void_int_t(void))(void);
38 // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: {{.*}} in typedef
39 // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: {{.*}} in typedef
40 // CHECK-FIXES: {{^}}typedef int (*returns_fn_void_int_t())();{{$}}
41 
42 // Should work for type aliases as well as typedef.
43 using returns_fn_void_int_t2 = int (*(void))(void);
44 // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: {{.*}} in type alias
45 // CHECK-MESSAGES: :[[@LINE-2]]:46: warning: {{.*}} in type alias
46 // CHECK-FIXES: {{^}}using returns_fn_void_int_t2 = int (*())();{{$}}
47 
returns_fn_void_int(void)48 int (*returns_fn_void_int(void))(void) {
49 // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} in function definition
50 // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: {{.*}} in function definition
51 // CHECK-FIXES: {{^}}int (*returns_fn_void_int())() {{{$}}
52   return nullptr;
53 }
54 
55 // A function taking void and returning a pointer to a function taking void
56 // and returning a pointer to a function taking void and returning void.
57 void (*(*returns_fn_returns_fn_void_void(void))(void))(void);
58 // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: {{.*}} in function declaration
59 // CHECK-MESSAGES: :[[@LINE-2]]:49: warning: {{.*}} in function declaration
60 // CHECK-MESSAGES: :[[@LINE-3]]:56: warning: {{.*}} in function declaration
61 // CHECK-FIXES: {{^}}void (*(*returns_fn_returns_fn_void_void())())();{{$}}
62 
63 typedef void (*(*returns_fn_returns_fn_void_void_t(void))(void))(void);
64 // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: {{.*}} in typedef
65 // CHECK-MESSAGES: :[[@LINE-2]]:59: warning: {{.*}} in typedef
66 // CHECK-MESSAGES: :[[@LINE-3]]:66: warning: {{.*}} in typedef
67 // CHECK-FIXES: {{^}}typedef void (*(*returns_fn_returns_fn_void_void_t())())();{{$}}
68 
returns_fn_returns_fn_void_void(void)69 void (*(*returns_fn_returns_fn_void_void(void))(void))(void) {
70 // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: {{.*}} in function definition
71 // CHECK-MESSAGES: :[[@LINE-2]]:49: warning: {{.*}} in function definition
72 // CHECK-MESSAGES: :[[@LINE-3]]:56: warning: {{.*}} in function definition
73 // CHECK-FIXES: {{^}}void (*(*returns_fn_returns_fn_void_void())())() {{{$}}
74     return nullptr;
75 }
76 
bar(void)77 void bar(void) {
78 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: {{.*}} in function definition
79 // CHECK-FIXES: {{^}}void bar() {{{$}}
80 }
81 
op_fn(int i)82 void op_fn(int i) {
83 }
84 
85 class gronk {
86 public:
87   gronk();
88   ~gronk();
89 
90     void foo();
91     void bar();
92     void bar2
93         ();
operation(int i)94     void operation(int i) { }
95 
96 private:
97     int m_i;
98     int *m_pi;
99     float m_f;
100     float *m_pf;
101     double m_d;
102     double *m_pd;
103 
104     void (*f1)(void);
105     // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*}} in field declaration
106     // CHECK-FIXES: {{^    }}void (*f1)();{{$}}
107 
108   void (*op)(int i);
109 
110   void (gronk::*p1)(void);
111   // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in field declaration
112   // CHECK-FIXES: {{^  }}void (gronk::*p1)();{{$}}
113 
114   int (gronk::*p_mi);
115 
116   void (gronk::*p2)(int);
117 
118   void (*(*returns_fn_returns_fn_void_void(void))(void))(void);
119   // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: {{.*}} in function declaration
120   // CHECK-MESSAGES: :[[@LINE-2]]:51: warning: {{.*}} in function declaration
121   // CHECK-MESSAGES: :[[@LINE-3]]:58: warning: {{.*}} in function declaration
122   // CHECK-FIXES: {{^}}  void (*(*returns_fn_returns_fn_void_void())())();{{$}}
123 
124   void (*(*(gronk::*returns_fn_returns_fn_void_void_mem)(void))(void))(void);
125   // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: {{.*}} in field declaration
126   // CHECK-MESSAGES: :[[@LINE-2]]:65: warning: {{.*}} in field declaration
127   // CHECK-MESSAGES: :[[@LINE-3]]:72: warning: {{.*}} in field declaration
128   // CHECK-FIXES: {{^}}  void (*(*(gronk::*returns_fn_returns_fn_void_void_mem)())())();{{$}}
129 };
130 
131 int i;
132 int *pi;
133 void *pv = (void *) pi;
134 float f;
135 float *fi;
136 double d;
137 double *pd;
138 
139 void (*f1)(void);
140 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}} in variable declaration
141 // CHECK-FIXES: {{^}}void (*f1)();{{$}}
142 
143 void (*f2)(void) = nullptr;
144 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}} in variable declaration with initializer
145 // CHECK-FIXES: {{^}}void (*f2)() = nullptr;{{$}}
146 
147 void (*f2b)(void)(nullptr);
148 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
149 // CHECK-FIXES: {{^}}void (*f2b)()(nullptr);{{$}}
150 
151 void (*f2c)(void){nullptr};
152 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
153 // CHECK-FIXES: {{^}}void (*f2c)(){nullptr};{{$}}
154 
155 void (*f2d)(void) = NULL;
156 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
157 // CHECK-FIXES: {{^}}void (*f2d)() = NULL;{{$}}
158 
159 void (*f2e)(void)(NULL);
160 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
161 // CHECK-FIXES: {{^}}void (*f2e)()(NULL);{{$}}
162 
163 void (*f2f)(void){NULL};
164 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
165 // CHECK-FIXES: {{^}}void (*f2f)(){NULL};{{$}}
166 
167 void (*f3)(void) = bar;
168 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}} in variable declaration with initializer
169 // CHECK-FIXES: {{^}}void (*f3)() = bar;{{$}}
170 
171 void (*o1)(int i);
172 void (*o2)(int i) = nullptr;
173 void (*o3)(int i)(nullptr);
174 void (*o4)(int i){nullptr};
175 void (*o5)(int i) = NULL;
176 void (*o6)(int i)(NULL);
177 void (*o7)(int i){NULL};
178 void (*o8)(int i) = op_fn;
179 
180 void (*fa)();
181 
182 void (*fb)() = nullptr;
183 
184 void (*fc)() = bar;
185 
186 typedef void (function_ptr)(void);
187 // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: {{.*}} in typedef
188 // CHECK-FIXES: {{^}}typedef void (function_ptr)();{{$}}
189 
190 // intentionally not LLVM style to check preservation of whitesapce
191 typedef void (function_ptr2)
192     (
193         void
194     );
195 // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: {{.*}} in typedef
196 // CHECK-FIXES:      {{^typedef void \(function_ptr2\)$}}
197 // CHECK-FIXES-NEXT: {{^    \($}}
198 // CHECK-FIXES-NEXT: {{^        $}}
199 // CHECK-FIXES-NEXT: {{^    \);$}}
200 
201 // intentionally not LLVM style to check preservation of whitesapce
202 typedef
203 void
204 (
205 *
206 (
207 *
208 returns_fn_returns_fn_void_void_t2
209 (
210 void
211 )
212 )
213 (
214 void
215 )
216 )
217 (
218 void
219 )
220 ;
221 // CHECK-MESSAGES: :[[@LINE-11]]:1: warning: {{.*}} in typedef
222 // CHECK-MESSAGES: :[[@LINE-8]]:1: warning: {{.*}} in typedef
223 // CHECK-MESSAGES: :[[@LINE-5]]:1: warning: {{.*}} in typedef
224 // CHECK-FIXES:      {{^typedef$}}
225 // CHECK-FIXES-NEXT: {{^void$}}
226 // CHECK-FIXES-NEXT: {{^\($}}
227 // CHECK-FIXES-NEXT: {{^\*$}}
228 // CHECK-FIXES-NEXT: {{^\($}}
229 // CHECK-FIXES-NEXT: {{^\*$}}
230 // CHECK-FIXES-NEXT: {{^returns_fn_returns_fn_void_void_t2$}}
231 // CHECK-FIXES-NEXT: {{^\($}}
232 // CHECK-FIXES-NOT:  {{[^ ]}}
233 // CHECK-FIXES:      {{^\)$}}
234 // CHECK-FIXES-NEXT: {{^\)$}}
235 // CHECK-FIXES-NEXT: {{^\($}}
236 // CHECK-FIXES-NOT:  {{[^ ]}}
237 // CHECK-FIXES:      {{^\)$}}
238 // CHECK-FIXES-NEXT: {{^\)$}}
239 // CHECK-FIXES-NEXT: {{^\($}}
240 // CHECK-FIXES-NOT:  {{[^ ]}}
241 // CHECK-FIXES:      {{^\)$}}
242 // CHECK-FIXES-NEXT: {{^;$}}
243 
244 
245 void (gronk::*p1)(void);
246 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}} in variable declaration
247 // CHECK-FIXES: {{^}}void (gronk::*p1)();{{$}}
248 
249 void (gronk::*p2)(void) = &gronk::foo;
250 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}} in variable declaration with initializer
251 // CHECK-FIXES: {{^}}void (gronk::*p2)() = &gronk::foo;{{$}}
252 
253 typedef void (gronk::*member_function_ptr)(void);
254 // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: {{.*}} in typedef
255 // CHECK-FIXES: {{^}}typedef void (gronk::*member_function_ptr)();{{$}}
256 
257 // intentionally not LLVM style to check preservation of whitesapce
258 typedef void (gronk::*member_function_ptr2)
259     (
260         void
261     );
262 // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: {{.*}} in typedef
263 // CHECK-FIXES:      {{^typedef void \(gronk::\*member_function_ptr2\)$}}
264 // CHECK-FIXES-NEXT: {{^    \($}}
265 // CHECK-FIXES-NEXT: {{^        $}}
266 // CHECK-FIXES-NEXT: {{^    \);$}}
267 
foo()268 void gronk::foo() {
269   void (*f1)(void) = &::bar;
270   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration with initializer
271   // CHECK-FIXES: {{^  }}void (*f1)() = &::bar;{{$}}
272 
273   void (*f2)(void);
274   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration
275   // CHECK-FIXES: {{^  }}void (*f2)();{{$}}
276 
277   // intentionally not LLVM style to check preservation of whitesapce
278   void (*f3)
279       (
280           void
281       );
282   // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: {{.*}} in variable declaration
283   // CHECK-FIXES:      {{^  }}void (*f3){{$}}
284   // CHECK-FIXES-NEXT: {{^      \($}}
285   // CHECK-FIXES-NEXT: {{^          $}}
286   // CHECK-FIXES-NEXT: {{^      \);$}}
287 }
288 
bar(void)289 void gronk::bar(void) {
290 // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: {{.*}} in function definition
291 // CHECK-FIXES: {{^}}void gronk::bar() {{{$}}
292   void (gronk::*p3)(void) = &gronk::foo;
293   // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in variable declaration with initializer
294   // CHECK-FIXES: {{^  }}void (gronk::*p3)() = &gronk::foo;{{$}}
295 
296   void (gronk::*p4)(void);
297   // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in variable declaration
298   // CHECK-FIXES: {{^  }}void (gronk::*p4)();{{$}}
299 
300   // intentionally not LLVM style to check preservation of whitesapce
301   void (gronk::*p5)
302       (
303           void
304       );
305   // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: {{.*}} in variable declaration
306   // CHECK-FIXES:      {{^  }}void (gronk::*p5){{$}}
307   // CHECK-FIXES-NEXT: {{^      \($}}
308   // CHECK-FIXES-NExT: {{^          $}}
309   // CHECK-FIXES-NExT: {{^      \);$}}
310 }
311 
312 // intentionally not LLVM style to check preservation of whitesapce
bar2(void)313 void gronk::bar2
314   (
315   void
316   )
317 // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: {{.*}} in function definition
318 // CHECK-FIXES:      {{^void gronk::bar2$}}
319 // CHECK-FIXES-NEXT: {{^  \($}}
320 // CHECK-FIXES-NEXT: {{^  $}}
321 // CHECK-FIXES-NEXT: {{^  \)$}}
322 {
323 }
324 
gronk(void)325 gronk::gronk(void)
326 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in function definition
327 // CHECK-FIXES: {{^}}gronk::gronk(){{$}}
328   : f1(nullptr),
329   p1(nullptr) {
330 }
331 
~gronk(void)332 gronk::~gronk(void) {
333 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} in function definition
334 // CHECK-FIXES: {{^}}gronk::~gronk() {{{$}}
335 }
336 
337 class nutter {
338 public:
339   nutter();
340 };
341 
nutter(void)342 nutter::nutter(void) {
343 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*}} in function definition
344 // CHECK-FIXES: {{^}}nutter::nutter() {{{$}}
345   void (*f3)(void) = static_cast<void (*)(void)>(0);
346   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration with initializer
347   // CHECK-MESSAGES: :[[@LINE-2]]:43: warning: {{.*}} in named cast
348   // CHECK-FIXES: void (*f3)() = static_cast<void (*)()>(0);{{$}}
349 
350   void (*f4)(void) = (void (*)(void)) 0;
351   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration with initializer
352   // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: {{.*}} in cast expression
353   // CHECK-FIXES: void (*f4)() = (void (*)()) 0;{{$}}
354 
355   void (*f5)(void) = reinterpret_cast<void (*)(void)>(0);
356   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration with initializer
357   // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: {{.*}} in named cast
358   // CHECK-FIXES: void (*f5)() = reinterpret_cast<void (*)()>(0);{{$}}
359 
360   // intentionally not LLVM style to check preservation of whitesapce
361   void (*f6)(void) = static_cast<void (*)
362       (
363           void
364       )>(0);
365   // CHECK-MESSAGES: :[[@LINE-4]]:14: warning: {{.*}} in variable declaration with initializer
366   // CHECK-MESSAGES: :[[@LINE-3]]:11: warning: {{.*}} in named cast
367   // CHECK-FIXES:      {{^  }}void (*f6)() = static_cast<void (*){{$}}
368   // CHECK-FIXES-NEXT: {{^      \($}}
369   // CHECK-FIXES-NEXT: {{^          $}}
370   // CHECK-FIXES-NEXT: {{^      }})>(0);{{$}}
371 
372   // intentionally not LLVM style to check preservation of whitesapce
373   void (*f7)(void) = (void (*)
374       (
375           void
376       )) 0;
377   // CHECK-MESSAGES: :[[@LINE-4]]:14: warning: {{.*}} in variable declaration with initializer
378   // CHECK-MESSAGES: :[[@LINE-3]]:11: warning: {{.*}} in cast expression
379   // CHECK-FIXES:      {{^  }}void (*f7)() = (void (*){{$}}
380   // CHECK-FIXES-NEXT: {{^      \($}}
381   // CHECK-FIXES-NEXT: {{^          $}}
382   // CHECK-FIXES-NEXT: {{^      \)\) 0;$}}
383 
384   // intentionally not LLVM style to check preservation of whitesapce
385   void (*f8)(void) = reinterpret_cast<void (*)
386       (
387           void
388       )>(0);
389   // CHECK-MESSAGES: :[[@LINE-4]]:14: warning: {{.*}} in variable declaration with initializer
390   // CHECK-MESSAGES: :[[@LINE-3]]:11: warning: {{.*}} in named cast
391   // CHECK-FIXES:      {{^  }}void (*f8)() = reinterpret_cast<void (*){{$}}
392   // CHECK-FIXES-NEXT: {{^      \($}}
393   // CHECK-FIXES-NEXT: {{^          $}}
394   // CHECK-FIXES-NEXT: {{^      \)>\(0\);$}}
395 
396   void (*o1)(int) = static_cast<void (*)(int)>(0);
397   void (*o2)(int) = (void (*)(int)) 0;
398   void (*o3)(int) = reinterpret_cast<void (*)(int)>(0);
399 }
400 
401 class generator {
402 public:
operator ()(void)403   int operator()(void) { return 1; }
404   // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: {{.*}} in function definition
405   // CHECK-FIXES: {{^  }}int operator()() { return 1; }{{$}}
406 };
407 
test_lambda_functions()408 void test_lambda_functions() {
409   auto lamb_duh = [](void (*fn)(void)) { (*fn)(); };
410   // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}} in variable declaration
411   // CHECK-FIXES: {{^  }}auto lamb_duh = [](void (*fn)()) { (*fn)(); };{{$}}
412 
413   auto lambda_generator = [](void) { return 1; };
414   // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: {{.*}} in lambda expression
415   // CHECK-FIXES: {{^  }}auto lambda_generator = []() { return 1; };{{$}}
416 
417   auto gen2 = []() { return 1; };
418 
419   auto gen3 = []{ return 1; };
420 
421   auto void_returner = [](void) -> void (*)(void) { return f1; };
422   // CHECK-MESSAGES: [[@LINE-1]]:27: warning: {{.*}} in lambda expression
423   // CHECK-MESSAGES: [[@LINE-2]]:45: warning: {{.*}} in lambda expression
424   // CHECK-FIXES: {{^  }}auto void_returner = []() -> void (*)() { return f1; };{{$}}
425 }
426 
427 #define M(x) x
428 
429 M(void inmacro(void) {})
430 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*}} in function definition
431 // CHECK-FIXES: M(void inmacro() {})
432 
433 #define F(A, B)        \
434   struct F_##A##_##B { \
435     F_##A##_##B(void); \
436   };                   \
437   F_##A##_##B::F_##A##_##B(void)
438 
F(Foo,Bar)439 F(Foo, Bar) {
440 
441 }
442 
443 struct DefinitionWithNoBody {
444   DefinitionWithNoBody(void) = delete;
445   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} in function definition
446   // CHECK-FIXES: DefinitionWithNoBody() = delete;
447 };
448 
449 
450 
451 #define BODY {}
452 #define LAMBDA1 [](void){}
453 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
454 // CHECK-FIXES: LAMBDA1 [](){}
455 
456 #define LAMBDA2 [](void)BODY
457 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
458 // CHECK-FIXES: LAMBDA2 []()BODY
459 
460 #define LAMBDA3(captures, args, body) captures args body
461 #define WRAP(...) __VA_ARGS__
462 
463 #define LAMBDA4 (void)LAMBDA3([],(void),BODY)
464 // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
465 // CHECK-FIXES: LAMBDA4 (void)LAMBDA3([],(),BODY)
466 
467 #define LAMBDA5 []() -> void (*)(void) {return BODY;}
468 // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
469 // CHECK-FIXES: LAMBDA5 []() -> void (*)() {return BODY;}
lambda_expression_with_macro_test()470 void lambda_expression_with_macro_test(){
471   (void)LAMBDA1;
472   (void)LAMBDA2;
473   (void)LAMBDA3([], (void), BODY);
474   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
475   // CHECK-FIXES: (void)LAMBDA3([], (), BODY);
476 
477   LAMBDA4;
478   LAMBDA5;
479   WRAP((void)WRAP(WRAP(LAMBDA3(WRAP([]), WRAP((void)), WRAP(BODY)))));
480   // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
481   // CHECK-FIXES: WRAP((void)WRAP(WRAP(LAMBDA3(WRAP([]), WRAP(()), WRAP(BODY)))));
482 
483   (void)WRAP([](void) {});
484   // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
485   // CHECK-FIXES: (void)WRAP([]() {});
486 
487   [](void) BODY;
488   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
489   // CHECK-FIXES: []() BODY;
490 }
491 
492 namespace qqq {
493 void foo() BODY
494 void bar(void) BODY;
495 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in function definition
496 // CHECK-FIXES: void bar() BODY;
497 }
498 
499 struct S_1 {
g_1S_1500   void g_1(void) const {
501     // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
502     // CHECK-FIXES: void g_1() const {
503     int a;
504     (void)a;
505   }
506 
g_2S_1507   void g_2() const {
508     int a;
509     (void)a;
510   }
511 };
512 
513 template <typename T0>
514 struct S_2 {
g_1S_2515   void g_1(void) const {
516     // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
517     // CHECK-FIXES: void g_1() const {
518     int a;
519     (void)a;
520   }
521 
g_2S_2522   void g_2() const {
523     int a;
524     (void)a;
525   }
526 };
527 
528 template <typename T0>
529 struct S_3 {
530   template <typename T1>
g_1S_3531   void g_1(void) const {
532     // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
533     // CHECK-FIXES: void g_1() const {
534     int a;
535     (void)a;
536   }
537   template <typename T2>
g_2S_3538   void g_2() const {
539     int a;
540     (void)a;
541   }
542 };
543 
544 template <typename T1>
g_3(void)545 void g_3(void) {
546   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
547   // CHECK-FIXES: void g_3() {
548   int a;
549   (void)a;
550 }
551 
552 //Template instantiation
f_testTemplate()553 void f_testTemplate() {
554   S_1();
555   S_2<int>();
556   S_3<int>();
557   g_3<int>();
558 }
559