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