home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / EXAMPLES / SUPERLIN / TESTSL.C < prev    next >
C/C++ Source or Header  |  1996-06-04  |  2KB  |  138 lines

  1. /*
  2.  *  This C program is not intended to mean anything. But it contains all the
  3.  *  stylistic problems treated by the rules of the file 'rules.lf'.
  4.  *  Moreover it contains some odd syntactic constructions in order to test the
  5.  *  reliability of the C parser.
  6.  *  The main function contains somewhat more coherent code in order to test the
  7.  *  rules checking for uninitialized variables.
  8.  */
  9.  
  10.  
  11. typedef unsigned UNSIGNED;
  12.  
  13.  
  14. typedef UNSIGNED ((**PTR));
  15.  
  16.  
  17. extern int external_name;
  18.  
  19.  
  20. int a[3][~~~0] = {{1, 2, 3},
  21.           {1, 2, 3},
  22.           {0, ~~~1, 1},
  23.          };
  24.  
  25. struct _strange {
  26.   unsigned int :1&~3;
  27.   struct {
  28.     float **f;
  29.     int tag:3;
  30.   }  ** field;
  31. } strange;
  32.  
  33. typedef struct _strange *(*(strange_ptr));
  34.  
  35.  
  36. float **my_function(int i, long double **d)
  37. {
  38.   int a,
  39.       b = ~~0,
  40.       c,
  41.       A_very_explicit_variable_name;
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.   /* that's a big scope */
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.   a=++--b;
  67.   if(a>=++b){
  68.     int i;
  69.     UNSIGNED *j;
  70.  
  71.     typedef long PTR;
  72.  
  73.     **a = (PTR)(++b);
  74.     for(i= 0; i < *++a; i++) {
  75.       enum _ee {PTR, PTR1};
  76.  
  77.       float *(*F);
  78.  
  79.       **F+= 0.3E12L;
  80.     }
  81.     return 1 + i;
  82.   }
  83.   else  /* another indentation style */
  84.   {
  85.     typedef float ((((((((Nested_type))))))));
  86.  
  87.     typedef int PTR;
  88.  
  89.     PTR new_c;
  90.  
  91.  
  92.  
  93.  
  94.  
  95.    /* another big scope */
  96.  
  97.  
  98.  
  99.  
  100.  
  101.      Nested_type *s;
  102.  
  103.      new_c+=3;
  104.     {
  105.       const int PTR;
  106.  
  107.       PTR =0;
  108.     }
  109.   }
  110. }
  111.  
  112.  
  113. main(int argc, char **argv)
  114. {
  115.   int i, j, k, m;
  116.   float **l;
  117.  
  118.   if(1) {
  119.     i = j;
  120.     if(0)
  121.       k = 1;
  122.     else {
  123.       l = my_function(k, (long double **) 0);
  124.       k = 2;
  125.     };
  126.     for(i=0; i<10; i++) {
  127.       j += 1;
  128.       m = 3;
  129.       j *= m;
  130.     }
  131.     l = k + m;
  132.   }
  133.   else
  134.     i = m;
  135.   l = i * k;
  136.   argc = argv[3];
  137. }
  138.