xref: /petsc/src/sys/tests/linter/testStaticFunctionCandidates.cxx (revision e44f6aeb0c7eee2716d50e70cd976c48a5d3c225) !
1 #include "testheader.h"
2 
3 void BareFunctionShouldGetStatic(void) { }
4 
5 extern void ExternFunctionShouldNotGetStatic(void) { }
6 
7 static void StaticFunctionShouldNotGetStatic(void) { }
8 
9 // this should not get static
10 static void StaticFunctionPreDeclShouldNotGetStatic(void);
11 
12 // this should get static!
13 void StaticFunctionPreDeclShouldNotGetStatic(void) { }
14 
15 extern void ExternFunctionPreDeclShouldNotGetStatic(void);
16 
17 void ExternFunctionPreDeclShouldNotGetStatic(void) { }
18 
19 void BareFunctionPreDeclShouldGetStatic(void);
20 
21 void BareFunctionPreDeclShouldGetStatic(void) { }
22 
23 // declaration in testheader has "extern"
24 void ExternHeaderFunctionShouldNotGetStatic(void) { }
25 
26 class Foo {
27 public:
28   friend void swap();
29 };
30 
31 void swap() { }
32 
33 // clang-format off
34 void                                  ExternHeaderBadFormattingShouldNotGetStatic              ( void)
35 {
36 
37 }
38 // clang-format on
39 
40 static char *StaticPointerShouldNotGetStatic()
41 {
42   return nullptr;
43 }
44 
45 char *BarePointerShouldGetStatic()
46 {
47   return nullptr;
48 }
49 
50 extern char *ExternPointerShouldGetStatic()
51 {
52   return nullptr;
53 }
54 
55 PETSC_EXTERN char *PetscExternPointerShouldNotGetStatic()
56 {
57   return nullptr;
58 }
59 
60 PETSC_INTERN char *PetscInternPointerShouldNotGetStatic()
61 {
62   return nullptr;
63 }
64 
65 // clang-format off
66 PETSC_EXTERN char *                   PetscExternPointerBadFormattingShouldNotGetStatic   (   )
67 {
68   return nullptr;
69 }
70 
71 PETSC_INTERN char *               PetscInternBadFormattingPointerShouldNotGetStatic ()
72 {
73   return nullptr;
74 }
75 // clang-format on
76 
77 char *PetscExternHeaderPointerShouldNotGetStatic()
78 {
79   return nullptr;
80 }
81 
82 char *PetscInternHeaderPointerShouldNotGetStatic()
83 {
84   return nullptr;
85 }
86 
87 char *PetscExternHeaderPointerBadFormattingShouldNotGetStatic()
88 {
89   return nullptr;
90 }
91 
92 char *PetscInternHeaderPointerBadFormattingShouldNotGetStatic()
93 {
94   return nullptr;
95 }
96 
97 // ironically enough, this will get static
98 void silence_warnings(void)
99 {
100   (void)StaticFunctionShouldNotGetStatic;
101   (void)StaticFunctionPreDeclShouldNotGetStatic;
102   (void)StaticPointerShouldNotGetStatic;
103 }
104