home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lclint.zip / lclint-2_3h-os2-bin.zip / test / alias.c < prev    next >
Text File  |  1997-09-03  |  1KB  |  59 lines

  1. # include "mut.h"
  2.  
  3. int glob;
  4. int *globp;
  5.  
  6. int f(int *a, int b, int **c)
  7. {
  8.   int *x, *y, *z;
  9.  
  10.   x = a;   
  11.   *x = 3;  /* 1. modifies *a */
  12.   x = a;
  13.   y = x;
  14.   *y = 4;  /* 2. modifies *a */
  15.  
  16.   globp = a;  /* 3. modifies *globp */
  17.   if (*x == 3) return 3; /* 4. returns aliasing globp */
  18.  
  19.   if (*x == 4) 
  20.     {
  21.       globp = z; /* 5, 6. z use before def, modifies globp */
  22.       return 4; /* okay */
  23.     }
  24.   
  25.   *globp = 4; /* 7, 8. modifies *a, *globp */
  26.  
  27.   x = globp;
  28.   *x = 7;     /* 9, 10. modifies *globp, *a */
  29.  
  30.   x = &glob;
  31.   *x = 4;    /* 11. modifies glob */
  32.  
  33.   x = &b;  /* okay */
  34.   *x = 3;  /* okay */
  35.   b = 3;   /* okay */
  36.   *x = b;  /* okay */
  37.   x = *c;  /* okay */
  38.   *x = 4;  /* 12. modifies **c */
  39.   a = *c;  /* okay */
  40.   *a = 4;  /* 13. modifies **c (but not *a) */
  41.   *globp = 3; /* 14, 15. modifies *globp, modifies *a */
  42.   return 4;   /* 16. returns with globp aliasing a */
  43. }
  44.  
  45. int h (mut a, mut b) 
  46.   mut c = mut_create();
  47.  
  48.   mut_mod (a);  /* 17. modifies a */
  49.   a = b;
  50.   mut_mod (a);  /* 18. modifies b */
  51.   b = c; 
  52.   mut_mod (b);  /* okay */
  53.  
  54.   return 3;     /* 19. locally allocated storage c not released */
  55. }
  56.  
  57.  
  58.