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 / outglob.c < prev    next >
Text File  |  1997-09-03  |  752b  |  55 lines

  1. int x1, x2, x3;
  2.  
  3. int g()
  4. {
  5.   return x1 + x2 + x3; /* 1. uses x3 before definition */
  6. }
  7.  
  8. int f()
  9. {
  10.   int loc;
  11.  
  12.   if (3 > 4)
  13.     {
  14.       loc = 3;
  15.       return x1; /* 2, 3, 4. bad --- x1 not defined, x2, x3 not defined */ 
  16.     }
  17.   else  
  18.     { 
  19.       if (4 > 6)
  20.     {
  21.       loc = x1;  /* 5. x1 not defined */
  22.       loc = g(); /* 6. bad --- x1, x2 not defined before call (defines x2 and x3) */
  23.       loc = x3; 
  24.     }
  25.       else if (2 > 3)
  26.     {
  27.       loc = x3; /* 7. x3 not defined */
  28.       x1 = 6;
  29.       x2 = 7;
  30.       return g(); 
  31.     }
  32.       else
  33.     {
  34.       x1 = 6;
  35.       x2 = 7;
  36.       
  37.       return 12; /* 8. returns with x3 not defined */
  38.     }
  39.     }
  40.  
  41.   return 12; /* NO! [9, 10. returns with x2 and x3 undefined (x1 IS defined on all branches!)] */
  42. }
  43.  
  44. int h (void)
  45. {
  46.   return x1; /* okay */
  47. }
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.