tcc -MD: drop system includes and duplicates
[tinycc.git] / tests / tests2 / 17_enum.c
blobe2bc736290ba8f9e65cfe416549e94b8b0d2c85d
1 #include <stdio.h>
3 enum fred
5 a,
6 b,
7 c,
8 d,
9 e = 54,
10 f = 73,
15 /* All following uses of enum efoo should compile
16 without warning. While forward enums aren't ISO C,
17 it's accepted by GCC also in strict mode, and only warned
18 about with -pedantic. This happens in the real world. */
19 /* Strict ISO C doesn't allow this kind of forward declaration of
20 enums, but GCC accepts it (and gives only pedantic warning), and
21 it occurs in the wild. */
22 enum efoo;
23 struct Sforward_use {
24 int (*fmember) (enum efoo x);
27 extern enum efoo it_real_fn(void);
28 enum efoo {
29 ONE,
30 TWO,
32 struct S2 {
33 enum efoo (*f2) (void);
35 void should_compile(struct S2 *s)
37 s->f2 = it_real_fn;
40 enum efoo it_real_fn(void)
42 return TWO;
45 static unsigned int deref_uintptr(unsigned int *p)
47 return *p;
50 enum Epositive {
51 epos_one, epos_two
54 int main()
56 enum fred frod;
57 enum Epositive epos = epos_two;
59 printf("%d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h);
60 /* printf("%d\n", frod); */
61 frod = 12;
62 printf("%d\n", frod);
63 frod = e;
64 printf("%d\n", frod);
66 /* Following should compile without warning. */
67 printf ("enum to int: %u\n", deref_uintptr(&epos));
69 return 0;
72 /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/