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