| Last change
 on this file since 2410424 was             8705a11, checked in by Andrew Beach <ajbeach@…>, 8 months ago | 
        
          | 
Added a test to check enumerations based on trac#46, which has been solved for a while, so that it may be closed.
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            918 bytes | 
      
      
| Line |  | 
|---|
| 1 | // Testing the use of C enumerations in Cforall. | 
|---|
| 2 |  | 
|---|
| 3 | // Testing enum declaration | 
|---|
| 4 | enum Colours { | 
|---|
| 5 | Red, | 
|---|
| 6 | Yellow, | 
|---|
| 7 | Pink, | 
|---|
| 8 | Blue, | 
|---|
| 9 | Purple, | 
|---|
| 10 | Orange, | 
|---|
| 11 | Green | 
|---|
| 12 | }; | 
|---|
| 13 |  | 
|---|
| 14 | enum Colours c1; | 
|---|
| 15 | Colours c2; | 
|---|
| 16 |  | 
|---|
| 17 | void f( void ) { | 
|---|
| 18 | enum Fruits { | 
|---|
| 19 | Apple, | 
|---|
| 20 | Banana, | 
|---|
| 21 | Pear, | 
|---|
| 22 | Mango | 
|---|
| 23 | } fruit = Mango;        (void) fruit; | 
|---|
| 24 | enum Fruits f1;         (void) f1; | 
|---|
| 25 | Fruits f2;                      (void) f2; | 
|---|
| 26 | } | 
|---|
| 27 |  | 
|---|
| 28 | // test constant-expressions | 
|---|
| 29 |  | 
|---|
| 30 | struct S { | 
|---|
| 31 | int i; | 
|---|
| 32 | }; | 
|---|
| 33 | enum K { P = 3 + 4 }; | 
|---|
| 34 | enum Y { W = 9 + (3 && 4 || 7)}; | 
|---|
| 35 | int p[W]; | 
|---|
| 36 | enum { X = W + -3 + ~1 / 2 * (int)4 + sizeof(struct S) + _Alignof(struct S) || 3 && 5 + (3 ? 1 : 2 ) + __builtin_offsetof(struct S, i ) }; | 
|---|
| 37 | int x[X]; | 
|---|
| 38 | enum { B = 3 + 4 - 7 * 20 / 34 << 3 >> 4 > 8 < 9 <= 23 >= 42 == 12 != 13  & 4 ^ 2 | 8 + sizeof(struct S) + _Alignof(struct S) }; | 
|---|
| 39 | int y[B]; | 
|---|
| 40 | enum { J = +3 + -4 / ~20 * ! 0 }; | 
|---|
| 41 | int z[J] = { 1, 2, 3 }; | 
|---|
| 42 | int aa[41] @= { [3] = 3, [1] = 6 }; | 
|---|
| 43 |  | 
|---|
| 44 | //Dummy main | 
|---|
| 45 | int main() { | 
|---|
| 46 | printf( "done\n" );                             // non-empty .expect file | 
|---|
| 47 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.