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 / tests2.2a / obviousloop.c < prev    next >
Text File  |  1997-09-03  |  694b  |  78 lines

  1. int f (void)
  2. {
  3.   int x = 3;
  4.  
  5.   while (TRUE)
  6.     {
  7.       x++;
  8.  
  9.       if (x == 12) {
  10.     return 12;
  11.       }
  12.     }
  13.  
  14.   x = 12; /* unreachable */
  15. }
  16.  
  17. int f1 (void)
  18. {
  19.   int x = 3;
  20.  
  21.   while (TRUE)
  22.     {
  23.       x++;
  24.  
  25.       if (x == 12) {
  26.     return 12;
  27.       }
  28.  
  29.       if (x == 8) {
  30.     break;
  31.       }
  32.     }
  33.  
  34.   x = 12;
  35.   /* no return */
  36. }
  37.  
  38. int f1b (void)
  39. {
  40.   int x = 3;
  41.  
  42.   while (TRUE)
  43.     {
  44.       x++;
  45.  
  46.       if (x == 12) {
  47.     return 12;
  48.       }
  49.  
  50.       if (x == 8) {
  51.     for (x = 2; x < 2; x++) {
  52.       if (x == 4) {
  53.         break;
  54.       }
  55.     }
  56.       }
  57.     }
  58.  
  59.   x = 12; /* unreachable */
  60. }
  61.  
  62. int f2 (void)
  63. {
  64.   int x = 3;
  65.  
  66.   for (;;)
  67.     {
  68.       x++;
  69.  
  70.       if (x == 12) {
  71.     return 12;
  72.       }
  73.     }
  74.  
  75.   x = 12; /* unreachable */
  76. }
  77.  
  78.