source: tests/enum.cfa @ 048dde4

Last change on this file since 048dde4 was 8705a11, checked in by Andrew Beach <ajbeach@…>, 6 weeks 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
4enum Colours {
5        Red,
6        Yellow,
7        Pink,
8        Blue,
9        Purple,
10        Orange,
11        Green
12};
13
14enum Colours c1;
15Colours c2;
16
17void 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
30struct S {
31    int i;
32};
33enum K { P = 3 + 4 };
34enum Y { W = 9 + (3 && 4 || 7)};
35int p[W];
36enum { X = W + -3 + ~1 / 2 * (int)4 + sizeof(struct S) + _Alignof(struct S) || 3 && 5 + (3 ? 1 : 2 ) + __builtin_offsetof(struct S, i ) };
37int x[X];
38enum { B = 3 + 4 - 7 * 20 / 34 << 3 >> 4 > 8 < 9 <= 23 >= 42 == 12 != 13  & 4 ^ 2 | 8 + sizeof(struct S) + _Alignof(struct S) };
39int y[B];
40enum { J = +3 + -4 / ~20 * ! 0 };
41int z[J] = { 1, 2, 3 };
42int aa[41] @= { [3] = 3, [1] = 6 };
43
44//Dummy main
45int main() {
46        printf( "done\n" );                             // non-empty .expect file
47}
Note: See TracBrowser for help on using the repository browser.