1 // RUN: %check_clang_tidy %s fuchsia-default-arguments-declarations %t
2 
foo(int value=5)3 int foo(int value = 5) { return value; }
4 // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
5 // CHECK-FIXES: int foo(int value) { return value; }
6 
bar(int value)7 int bar(int value) { return value; }
8 
9 class Baz {
10 public:
a(int value=5)11   int a(int value = 5) { return value; }
12   // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
13   // CHECK-FIXES: int a(int value) { return value; }
14 
b(int value)15   int b(int value) { return value; }
16 };
17 
18 class Foo {
19   // Fix should be suggested in declaration
20   int a(int value = 53);
21   // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
22   // CHECK-FIXES: int a(int value);
23 };
24 
25 // Fix shouldn't be suggested in implementation
a(int value)26 int Foo::a(int value) {
27   return value;
28 }
29 
30 // Elided functions
f(int=5)31 void f(int = 5) {};
32 // CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
33 // CHECK-FIXES: void f(int) {};
34 
g(int)35 void g(int) {};
36 
37 // Should not suggest fix for macro-defined parameters
38 #define D(val) = val
39 
40 void h(int i D(5));
41 // CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
42 // CHECK-FIXES-NOT: void h(int i);
43 
44 void x(int i);
45 void x(int i = 12);
46 // CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
47 // CHECK-FIXES: void x(int i);
48 
x(int i)49 void x(int i) {}
50 
51 struct S {
52   void x(int i);
53 };
54 
x(int i=12)55 void S::x(int i = 12) {}
56 // CHECK-NOTES: [[@LINE-1]]:11: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
57 // CHECK-FIXES: void S::x(int i) {}
58