source: tests/enum.cfa@ 6f9f338

Last change on this file since 6f9f338 was 8705a11, checked in by Andrew Beach <ajbeach@…>, 7 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
RevLine 
[8705a11]1// Testing the use of C enumerations in Cforall.
2
3// Testing enum declaration
[10dc7491]4enum Colours {
[62edde5]5 Red,
6 Yellow,
7 Pink,
8 Blue,
9 Purple,
10 Orange,
11 Green
12};
13
[10dc7491]14enum Colours c1;
15Colours c2;
16
[62edde5]17void f( void ) {
18 enum Fruits {
19 Apple,
20 Banana,
21 Pear,
22 Mango
[10b5970]23 } fruit = Mango; (void) fruit;
24 enum Fruits f1; (void) f1;
25 Fruits f2; (void) f2;
[62edde5]26}
27
[0edbdb2]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 };
[c565d68]42int aa[41] @= { [3] = 3, [1] = 6 };
[0edbdb2]43
[62edde5]44//Dummy main
[10b5970]45int main() {
[66812dd]46 printf( "done\n" ); // non-empty .expect file
[62edde5]47}
Note: See TracBrowser for help on using the repository browser.