Last change
on this file since 52eb7b7 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
|
Rev | Line | |
---|
[8705a11] | 1 | // Testing the use of C enumerations in Cforall.
|
---|
| 2 |
|
---|
| 3 | // Testing enum declaration
|
---|
[10dc7491] | 4 | enum Colours {
|
---|
[62edde5] | 5 | Red,
|
---|
| 6 | Yellow,
|
---|
| 7 | Pink,
|
---|
| 8 | Blue,
|
---|
| 9 | Purple,
|
---|
| 10 | Orange,
|
---|
| 11 | Green
|
---|
| 12 | };
|
---|
| 13 |
|
---|
[10dc7491] | 14 | enum Colours c1;
|
---|
| 15 | Colours c2;
|
---|
| 16 |
|
---|
[62edde5] | 17 | void 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 |
|
---|
| 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 };
|
---|
[c565d68] | 42 | int aa[41] @= { [3] = 3, [1] = 6 };
|
---|
[0edbdb2] | 43 |
|
---|
[62edde5] | 44 | //Dummy main
|
---|
[10b5970] | 45 | int main() {
|
---|
[66812dd] | 46 | printf( "done\n" ); // non-empty .expect file
|
---|
[62edde5] | 47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.