blob: 5c3c8c12d683c033471c8300dc1cdc82752cb56b [file] [log] [blame]
Haojian Wuc253f8b2016-04-05 11:42:08 +00001// RUN: %check_clang_tidy %s readability-static-definition-in-anonymous-namespace %t
2
3namespace {
4
5int a = 1;
6const int b = 1;
7static int c = 1;
8// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'c' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
9// CHECK-FIXES: {{^}}int c = 1;
10static const int d = 1;
11// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'd' is a static definition in anonymous namespace
12// CHECK-FIXES: {{^}}const int d = 1;
13const static int e = 1;
14// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'e' is a static definition in anonymous namespace
15// CHECK-FIXES: {{^}}const int e = 1;
16
17void f() {
18 int a = 1;
19 static int b = 1;
20}
21
22static int g() {
23// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'g' is a static definition in anonymous namespace
24// CHECK-FIXES: {{^}}int g() {
25 return 1;
26}
27
28#define DEFINE_STATIC static
29// CHECK-FIXES: {{^}}#define DEFINE_STATIC static
30DEFINE_STATIC int h = 1;
31// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 'h' is a static definition in anonymous namespace
32// CHECK-FIXES: {{^}}DEFINE_STATIC int h = 1;
33
34#define DEFINE_STATIC_VAR(x) static int x = 2
35// CHECK-FIXES: {{^}}#define DEFINE_STATIC_VAR(x) static int x = 2
36DEFINE_STATIC_VAR(i);
37// CHECK-FIXES: {{^}}DEFINE_STATIC_VAR(i);
38
39} // namespace
40
41namespace N {
42
43int a = 1;
44const int b = 1;
45static int c = 1;
46static const int d = 1;
47const static int e = 1;
48
49} // namespace N