source: tests/enum.cfa @ 960665c

Last change on this file since 960665c was 0edbdb2, checked in by Peter A. Buhr <pabuhr@…>, 2 years ago

add constant expression tests

  • Property mode set to 100644
File size: 856 bytes
RevLine 
[62edde5]1//Testing enum declaration
[10dc7491]2enum Colours {
[62edde5]3        Red,
4        Yellow,
5        Pink,
6        Blue,
7        Purple,
8        Orange,
9        Green
10};
11
[10dc7491]12enum Colours c1;
13Colours c2;
14
[62edde5]15void f( void ) {
16        enum Fruits {
17                Apple,
18                Banana,
19                Pear,
20                Mango
21        } fruit = Mango;
[10dc7491]22        enum Fruits f1;
23        Fruits f2;
[62edde5]24}
25
[0edbdb2]26// test constant-expressions
27
28struct S {
29    int i;
30};
31enum K { P = 3 + 4 };
32enum Y { W = 9 + (3 && 4 || 7)};
33int p[W];
34enum { X = W + -3 + ~1 / 2 * (int)4 + sizeof(struct S) + _Alignof(struct S) || 3 && 5 + (3 ? 1 : 2 ) + __builtin_offsetof(struct S, i ) };
35int x[X];
36enum { B = 3 + 4 - 7 * 20 / 34 << 3 >> 4 > 8 < 9 <= 23 >= 42 == 12 != 13  & 4 ^ 2 | 8 + sizeof(struct S) + _Alignof(struct S) };
37int y[B];
38enum { J = +3 + -4 / ~20 * ! 0 };
39int z[J] = { 1, 2, 3 };
40int aa[41] @= { [3] : 3, [1] : 6 };
41
[62edde5]42//Dummy main
[10dc7491]43int main(int argc, char const *argv[]) {
[66812dd]44        printf( "done\n" );                             // non-empty .expect file
[62edde5]45}
Note: See TracBrowser for help on using the repository browser.