xref: /petsc/src/sys/tests/linter/testReferences.c (revision f1580f4e3ce5d5b2393648fd039d0d41b440385d)
1 /* for access to private vec members */
2 #include <petsc/private/viewerimpl.h>
3 
4 /* forward declare */
5 void extractFunc(PetscViewer, void **);
6 
7 void testOutOfLineReference(PetscViewer v, PetscViewer v2) {
8   /* linter should be able to connect all of these to v */
9   void  *foo  = v->data, *bar, *baz, *blop;
10   void **blip = &v->data;
11 
12   bar  = v->data;
13   blop = blip[0];
14   extractFunc(v, &baz);
15 
16   /* incorrect */
17   PetscValidPointer(foo, -1);
18   PetscValidPointer(bar, -2);
19   PetscValidPointer(baz, -3);
20   PetscValidPointer((void *)v->data, -4);
21   PetscValidPointer(*blip, -5);
22   PetscValidPointer(blop, -6);
23 
24   /* correct */
25   PetscValidPointer(foo, 1);
26   PetscValidPointer(bar, 1);
27   PetscValidPointer(baz, 1);
28   PetscValidPointer((void *)v->data, 1);
29   PetscValidPointer(*blip, 1);
30   PetscValidPointer(blop, 1);
31   return;
32 }
33