| 1 | // RUN: %check_clang_tidy %s misc-use-anonymous-namespace %t -- -header-filter=.* -- -I%S/Inputs |
| 2 | #include "use-anonymous-namespace.h" |
| 3 | |
| 4 | static void f1(); |
| 5 | // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function 'f1' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace] |
| 6 | static int v1; |
| 7 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'v1' declared 'static', move to anonymous namespace instead |
| 8 | |
| 9 | namespace a { |
| 10 | static void f3(); |
| 11 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: function 'f3' declared 'static', move to anonymous namespace instead |
| 12 | static int v3; |
| 13 | // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: variable 'v3' declared 'static', move to anonymous namespace instead |
| 14 | } |
| 15 | |
| 16 | // OK |
| 17 | void f5(); |
| 18 | int v5; |
| 19 | |
| 20 | // OK |
| 21 | namespace { |
| 22 | void f6(); |
| 23 | int v6; |
| 24 | } |
| 25 | |
| 26 | // OK |
| 27 | namespace a { |
| 28 | namespace { |
| 29 | void f7(); |
| 30 | int v7; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | // OK |
| 35 | struct Foo { |
| 36 | static void f(); |
| 37 | static int x; |
| 38 | }; |
| 39 | |
| 40 | // OK |
| 41 | void foo() |
| 42 | { |
| 43 | static int x; |
| 44 | } |
| 45 | |
| 46 | // OK |
| 47 | static const int v8{123}; |
| 48 | static constexpr int v9{123}; |
| 49 | |