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 / cases.c < prev    next >
C/C++ Source or Header  |  1997-09-03  |  769b  |  42 lines

  1. extern int g(int x);
  2.  
  3. int f(int j)
  4. {
  5.   int i;
  6.  
  7.   switch (j) 
  8.     {
  9.     case 3: /* okay */
  10.       i = g(j);
  11.       printf("3");
  12.     case 4:  /* 2. Fall through case (no preceeding break) */
  13.       if (i == 3) /* 1. Variable i used before definition */
  14.     {
  15.       printf("hullo");
  16.       return 3;
  17.     }
  18.       else
  19.     {
  20.       printf("yabba");
  21.       break;
  22.     }
  23.     case 5: /* okay */
  24.       i = g(j++);
  25.       while (i < 3)
  26.     {
  27.       i++;
  28.       if (j == 4) break;
  29.     }
  30.     case 6: /* 3. Fall through case (no preceeding break) */
  31.       printf("high");
  32.       return 3;
  33.     case 7: /* okay */
  34.     case 8: /* okay */
  35.     case 9:
  36.       printf("nope");
  37.     default: /* 4. Fall through case (no preceeding break) */
  38.       printf("splat");
  39.    }
  40. } /* 5. Path with no return in function declared to return int */
  41.   
  42.