Daniel Dunbar | 417dd17 | 2008-10-04 23:47:28 +0000 | [diff] [blame^] | 1 | //-*- C -*- |
| 2 | |
| 3 | /* This is a |
| 4 | multiline comment */ |
| 5 | |
| 6 | // Intended to exercise all syntactic parts of the C language. |
| 7 | |
| 8 | int g0; |
| 9 | int g1, g2; |
| 10 | |
| 11 | struct s0; |
| 12 | |
| 13 | struct s0 { |
| 14 | int x; |
| 15 | }; |
| 16 | |
| 17 | int g3 = 10; |
| 18 | |
| 19 | __asm(""); |
| 20 | |
| 21 | typedef int td0; |
| 22 | |
| 23 | td0 g4; |
| 24 | |
| 25 | enum e0 { |
| 26 | ec0 |
| 27 | }; |
| 28 | |
| 29 | static void f0(int x) { |
| 30 | } |
| 31 | |
| 32 | inline void f0_0(int x) { |
| 33 | ; |
| 34 | } |
| 35 | |
| 36 | extern void f0_1(int x) { |
| 37 | } |
| 38 | |
| 39 | void f1(int, ...); |
| 40 | |
| 41 | // Statements. |
| 42 | void f2() { |
| 43 | for (;;) { |
| 44 | break; |
| 45 | continue; |
| 46 | } |
| 47 | |
| 48 | while (0) { |
| 49 | } |
| 50 | |
| 51 | do { |
| 52 | } while (0); |
| 53 | |
| 54 | void *label = &&theif; |
| 55 | goto *label; |
| 56 | |
| 57 | goto theif; |
| 58 | theif: |
| 59 | if (0) { |
| 60 | ; |
| 61 | } else if (0) { |
| 62 | } else { |
| 63 | } |
| 64 | |
| 65 | switch(0) { |
| 66 | case 0: |
| 67 | case 1 ... 2: |
| 68 | break; |
| 69 | default: |
| 70 | break; |
| 71 | } |
| 72 | |
| 73 | asm ("nop"); |
| 74 | |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | // Expressions. |
| 79 | |
| 80 | #include <stdarg.h> |
| 81 | |
| 82 | typedef struct ipair { |
| 83 | int first, second; |
| 84 | } ipair; |
| 85 | |
| 86 | void f4(int a0, int a1, int a2, va_list ap) { |
| 87 | int t0 = a0 ? a1 : a2; |
| 88 | float t1 = (float) a0; |
| 89 | ipair t2 = {1, 2}; |
| 90 | int t3 = sizeof(ipair); |
| 91 | ipair t4; |
| 92 | t4 = (ipair) {1, 2}; |
| 93 | extern int g(int); |
| 94 | int t5 = g(a0); |
| 95 | int t6 = t4.first; |
| 96 | int t7[10]; |
| 97 | int t8 = t7[a0]; |
| 98 | t8++; |
| 99 | const char *t9 = __FUNCTION__; |
| 100 | char t10 = 'x'; |
| 101 | int t11 = __builtin_offsetof(ipair, first); |
| 102 | int t12 = __builtin_types_compatible_p(ipair, int); |
| 103 | int t13 = va_arg(ap, int); |
| 104 | } |