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