Implement -Wparentheses.
[cparser] / ast_t.h
1 /*
2  * This file is part of cparser.
3  * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 #ifndef AST_T_H
21 #define AST_T_H
22
23 #include <libfirm/firm_types.h>
24 #include <assert.h>
25
26 #include "ast.h"
27 #include "symbol.h"
28 #include "token_t.h"
29 #include "type.h"
30 #include "entity_t.h"
31 #include "adt/obst.h"
32
33 /** The AST obstack contains all data that must stay in the AST. */
34 extern struct obstack ast_obstack;
35
36 /**
37  * Operator precedence classes
38  */
39 typedef enum precedence_t {
40         PREC_BOTTOM,
41         PREC_EXPRESSION,     /* ,                                  left to right */
42         PREC_ASSIGNMENT,     /* = += -= *= /= %= <<= >>= &= ^= |=  right to left */
43         PREC_CONDITIONAL,    /* ?:                                 right to left */
44         PREC_LOGICAL_OR,     /* ||                                 left to right */
45         PREC_LOGICAL_AND,    /* &&                                 left to right */
46         PREC_OR,             /* |                                  left to right */
47         PREC_XOR,            /* ^                                  left to right */
48         PREC_AND,            /* &                                  left to right */
49         PREC_EQUALITY,       /* == !=                              left to right */
50         PREC_RELATIONAL,     /* < <= > >=                          left to right */
51         PREC_SHIFT,          /* << >>                              left to right */
52         PREC_ADDITIVE,       /* + -                                left to right */
53         PREC_MULTIPLICATIVE, /* * / %                              left to right */
54         PREC_CAST,           /* (type)                             right to left */
55         PREC_UNARY,          /* ! ~ ++ -- + - * & sizeof           right to left */
56         PREC_POSTFIX,        /* () [] -> .                         left to right */
57         PREC_PRIMARY,
58         PREC_TOP
59 } precedence_t;
60
61 /**
62  * Expression kinds.
63  */
64 typedef enum expression_kind_t {
65         EXPR_UNKNOWN = 0,
66         EXPR_INVALID,
67         EXPR_REFERENCE,
68         EXPR_REFERENCE_ENUM_VALUE,
69         EXPR_CONST,
70         EXPR_CHARACTER_CONSTANT,
71         EXPR_WIDE_CHARACTER_CONSTANT,
72         EXPR_STRING_LITERAL,
73         EXPR_WIDE_STRING_LITERAL,
74         EXPR_COMPOUND_LITERAL,
75         EXPR_CALL,
76         EXPR_CONDITIONAL,
77         EXPR_SELECT,
78         EXPR_ARRAY_ACCESS,
79         EXPR_SIZEOF,
80         EXPR_CLASSIFY_TYPE,
81         EXPR_ALIGNOF,
82
83         EXPR_FUNCNAME,
84         EXPR_BUILTIN_SYMBOL,
85         EXPR_BUILTIN_CONSTANT_P,
86         EXPR_BUILTIN_PREFETCH,
87         EXPR_OFFSETOF,
88         EXPR_VA_START,
89         EXPR_VA_ARG,
90         EXPR_STATEMENT,
91         EXPR_LABEL_ADDRESS, /**< GCC extension &&label operator */
92
93         EXPR_UNARY_FIRST,
94         EXPR_UNARY_NEGATE = EXPR_UNARY_FIRST,
95         EXPR_UNARY_PLUS,
96         EXPR_UNARY_BITWISE_NEGATE,
97         EXPR_UNARY_NOT,
98         EXPR_UNARY_DEREFERENCE,
99         EXPR_UNARY_TAKE_ADDRESS,
100         EXPR_UNARY_POSTFIX_INCREMENT,
101         EXPR_UNARY_POSTFIX_DECREMENT,
102         EXPR_UNARY_PREFIX_INCREMENT,
103         EXPR_UNARY_PREFIX_DECREMENT,
104         EXPR_UNARY_CAST,
105         EXPR_UNARY_CAST_IMPLICIT, /**< compiler generated cast */
106         EXPR_UNARY_ASSUME,        /**< MS __assume() */
107         EXPR_UNARY_DELETE,
108         EXPR_UNARY_DELETE_ARRAY,
109         EXPR_UNARY_THROW,
110         EXPR_UNARY_LAST = EXPR_UNARY_THROW,
111
112         EXPR_BINARY_FIRST,
113         EXPR_BINARY_ADD = EXPR_BINARY_FIRST,
114         EXPR_BINARY_SUB,
115         EXPR_BINARY_MUL,
116         EXPR_BINARY_DIV,
117         EXPR_BINARY_MOD,
118         EXPR_BINARY_EQUAL,
119         EXPR_BINARY_NOTEQUAL,
120         EXPR_BINARY_LESS,
121         EXPR_BINARY_LESSEQUAL,
122         EXPR_BINARY_GREATER,
123         EXPR_BINARY_GREATEREQUAL,
124         EXPR_BINARY_BITWISE_AND,
125         EXPR_BINARY_BITWISE_OR,
126         EXPR_BINARY_BITWISE_XOR,
127         EXPR_BINARY_LOGICAL_AND,
128         EXPR_BINARY_LOGICAL_OR,
129         EXPR_BINARY_SHIFTLEFT,
130         EXPR_BINARY_SHIFTRIGHT,
131         EXPR_BINARY_ASSIGN,
132         EXPR_BINARY_MUL_ASSIGN,
133         EXPR_BINARY_DIV_ASSIGN,
134         EXPR_BINARY_MOD_ASSIGN,
135         EXPR_BINARY_ADD_ASSIGN,
136         EXPR_BINARY_SUB_ASSIGN,
137         EXPR_BINARY_SHIFTLEFT_ASSIGN,
138         EXPR_BINARY_SHIFTRIGHT_ASSIGN,
139         EXPR_BINARY_BITWISE_AND_ASSIGN,
140         EXPR_BINARY_BITWISE_XOR_ASSIGN,
141         EXPR_BINARY_BITWISE_OR_ASSIGN,
142         EXPR_BINARY_COMMA,
143
144         EXPR_BINARY_ISGREATER,
145         EXPR_BINARY_ISGREATEREQUAL,
146         EXPR_BINARY_ISLESS,
147         EXPR_BINARY_ISLESSEQUAL,
148         EXPR_BINARY_ISLESSGREATER,
149         EXPR_BINARY_ISUNORDERED,
150         EXPR_BINARY_LAST = EXPR_BINARY_ISUNORDERED,
151 } expression_kind_t;
152
153 typedef enum funcname_kind_t {
154         FUNCNAME_FUNCTION,           /**< C99 __func__, older __FUNCTION__ */
155         FUNCNAME_PRETTY_FUNCTION,    /**< GNUC __PRETTY_FUNCTION__ */
156         FUNCNAME_FUNCSIG,            /**< MS __FUNCSIG__ */
157         FUNCNAME_FUNCDNAME           /**< MS __FUNCDNAME__ */
158 } funcname_kind_t;
159
160 /* convenience macros */
161 #define EXPR_BINARY_CASES                  \
162         case EXPR_BINARY_ADD:                  \
163         case EXPR_BINARY_SUB:                  \
164         case EXPR_BINARY_MUL:                  \
165         case EXPR_BINARY_DIV:                  \
166         case EXPR_BINARY_MOD:                  \
167         case EXPR_BINARY_EQUAL:                \
168         case EXPR_BINARY_NOTEQUAL:             \
169         case EXPR_BINARY_LESS:                 \
170         case EXPR_BINARY_LESSEQUAL:            \
171         case EXPR_BINARY_GREATER:              \
172         case EXPR_BINARY_GREATEREQUAL:         \
173         case EXPR_BINARY_BITWISE_AND:          \
174         case EXPR_BINARY_BITWISE_OR:           \
175         case EXPR_BINARY_BITWISE_XOR:          \
176         case EXPR_BINARY_LOGICAL_AND:          \
177         case EXPR_BINARY_LOGICAL_OR:           \
178         case EXPR_BINARY_SHIFTLEFT:            \
179         case EXPR_BINARY_SHIFTRIGHT:           \
180         case EXPR_BINARY_ASSIGN:               \
181         case EXPR_BINARY_MUL_ASSIGN:           \
182         case EXPR_BINARY_DIV_ASSIGN:           \
183         case EXPR_BINARY_MOD_ASSIGN:           \
184         case EXPR_BINARY_ADD_ASSIGN:           \
185         case EXPR_BINARY_SUB_ASSIGN:           \
186         case EXPR_BINARY_SHIFTLEFT_ASSIGN:     \
187         case EXPR_BINARY_SHIFTRIGHT_ASSIGN:    \
188         case EXPR_BINARY_BITWISE_AND_ASSIGN:   \
189         case EXPR_BINARY_BITWISE_XOR_ASSIGN:   \
190         case EXPR_BINARY_BITWISE_OR_ASSIGN:    \
191         case EXPR_BINARY_COMMA:                \
192         case EXPR_BINARY_ISGREATER:            \
193         case EXPR_BINARY_ISGREATEREQUAL:       \
194         case EXPR_BINARY_ISLESS:               \
195         case EXPR_BINARY_ISLESSEQUAL:          \
196         case EXPR_BINARY_ISLESSGREATER:        \
197         case EXPR_BINARY_ISUNORDERED:
198
199 /**
200  * unary expression with mandatory operand
201  */
202 #define EXPR_UNARY_CASES_MANDATORY         \
203         case EXPR_UNARY_NEGATE:                \
204         case EXPR_UNARY_PLUS:                  \
205         case EXPR_UNARY_BITWISE_NEGATE:        \
206         case EXPR_UNARY_NOT:                   \
207         case EXPR_UNARY_DEREFERENCE:           \
208         case EXPR_UNARY_TAKE_ADDRESS:          \
209         case EXPR_UNARY_POSTFIX_INCREMENT:     \
210         case EXPR_UNARY_POSTFIX_DECREMENT:     \
211         case EXPR_UNARY_PREFIX_INCREMENT:      \
212         case EXPR_UNARY_PREFIX_DECREMENT:      \
213         case EXPR_UNARY_CAST:                  \
214         case EXPR_UNARY_CAST_IMPLICIT:         \
215         case EXPR_UNARY_ASSUME:                \
216         case EXPR_UNARY_DELETE:                \
217         case EXPR_UNARY_DELETE_ARRAY:
218
219 /**
220  * unary expression with optinal operand
221  */
222 #define EXPR_UNARY_CASES_OPTIONAL \
223         case EXPR_UNARY_THROW:        \
224
225 #define EXPR_UNARY_CASES       \
226         EXPR_UNARY_CASES_MANDATORY \
227         EXPR_UNARY_CASES_OPTIONAL
228
229 struct expression_base_t {
230         expression_kind_t   kind;
231         type_t             *type;
232         source_position_t   source_position;
233         bool                parenthesized;
234 #ifndef NDEBUG
235         bool                transformed;
236 #endif
237 };
238
239 struct const_expression_t {
240         expression_base_t  base;
241         union {
242                 long long      int_value;
243                 long double    float_value;
244                 string_t       character;
245                 wide_string_t  wide_character;
246         } v;
247         bool               is_ms_noop;  /**< True, if this constant is the result
248                                              of an microsoft __noop operator */
249 };
250
251 struct string_literal_expression_t {
252         expression_base_t  base;
253         string_t           value;
254 };
255
256 struct funcname_expression_t {
257         expression_base_t  base;
258         funcname_kind_t    kind;
259         string_t           value;     /**< the value once assigned. */
260 };
261
262 struct wide_string_literal_expression_t {
263         expression_base_t  base;
264         wide_string_t      value;
265 };
266
267 struct compound_literal_expression_t {
268         expression_base_t  base;
269         type_t            *type;
270         initializer_t     *initializer;
271 };
272
273 struct builtin_symbol_expression_t {
274         expression_base_t  base;
275         symbol_t          *symbol;
276 };
277
278 struct builtin_constant_expression_t {
279         expression_base_t  base;
280         expression_t      *value;
281 };
282
283 struct builtin_prefetch_expression_t {
284         expression_base_t  base;
285         expression_t      *adr;
286         expression_t      *rw;
287         expression_t      *locality;
288 };
289
290 struct reference_expression_t {
291         expression_base_t  base;
292         entity_t          *entity;
293 };
294
295 struct call_argument_t {
296         expression_t    *expression;
297         call_argument_t *next;
298 };
299
300 struct call_expression_t {
301         expression_base_t  base;
302         expression_t      *function;
303         call_argument_t   *arguments;
304 };
305
306 struct unary_expression_t {
307         expression_base_t  base;
308         expression_t      *value;
309 };
310
311 struct binary_expression_t {
312         expression_base_t  base;
313         expression_t      *left;
314         expression_t      *right;
315 };
316
317 struct select_expression_t {
318         expression_base_t  base;
319         expression_t      *compound;
320         entity_t          *compound_entry;
321 };
322
323 struct array_access_expression_t {
324         expression_base_t  base;
325         expression_t      *array_ref;
326         expression_t      *index;
327         bool               flipped; /**< index/ref was written in a 5[a] way */
328 };
329
330 struct typeprop_expression_t {
331         expression_base_t  base;
332         type_t            *type;
333         expression_t      *tp_expression;
334 };
335
336 struct designator_t {
337         source_position_t  source_position;
338         symbol_t          *symbol;
339         expression_t      *array_index;
340         designator_t      *next;
341 };
342
343 struct offsetof_expression_t {
344         expression_base_t  base;
345         type_t            *type;
346         designator_t      *designator;
347 };
348
349 struct va_start_expression_t {
350         expression_base_t  base;
351         expression_t      *ap;
352         variable_t        *parameter;
353 };
354
355 struct va_arg_expression_t {
356         expression_base_t  base;
357         expression_t      *ap;
358 };
359
360 struct conditional_expression_t {
361         expression_base_t  base;
362         expression_t      *condition;
363         expression_t      *true_expression;
364         expression_t      *false_expression;
365 };
366
367 struct statement_expression_t {
368         expression_base_t  base;
369         statement_t       *statement;
370 };
371
372 struct classify_type_expression_t {
373         expression_base_t  base;
374         expression_t      *type_expression;
375 };
376
377 struct label_address_expression_t {
378         expression_base_t  base;
379         label_t           *label;
380 };
381
382 union expression_t {
383         expression_kind_t                kind;
384         expression_base_t                base;
385         const_expression_t               conste;
386         funcname_expression_t            funcname;
387         string_literal_expression_t      string;
388         wide_string_literal_expression_t wide_string;
389         compound_literal_expression_t    compound_literal;
390         builtin_symbol_expression_t      builtin_symbol;
391         builtin_constant_expression_t    builtin_constant;
392         builtin_prefetch_expression_t    builtin_prefetch;
393         reference_expression_t           reference;
394         call_expression_t                call;
395         unary_expression_t               unary;
396         binary_expression_t              binary;
397         select_expression_t              select;
398         array_access_expression_t        array_access;
399         typeprop_expression_t            typeprop;
400         offsetof_expression_t            offsetofe;
401         va_start_expression_t            va_starte;
402         va_arg_expression_t              va_arge;
403         conditional_expression_t         conditional;
404         statement_expression_t           statement;
405         classify_type_expression_t       classify_type;
406         label_address_expression_t       label_address;
407 };
408
409 typedef enum initializer_kind_t {
410         INITIALIZER_VALUE,
411         INITIALIZER_LIST,
412         INITIALIZER_STRING,
413         INITIALIZER_WIDE_STRING,
414         INITIALIZER_DESIGNATOR
415 } initializer_kind_t;
416
417 struct initializer_base_t {
418         initializer_kind_t kind;
419 };
420
421 struct initializer_value_t {
422         initializer_base_t  base;
423         expression_t       *value;
424 };
425
426 struct initializer_list_t {
427         initializer_base_t  base;
428         size_t              len;
429         initializer_t      *initializers[];
430 };
431
432 struct initializer_string_t {
433         initializer_base_t base;
434         string_t           string;
435 };
436
437 struct initializer_wide_string_t {
438         initializer_base_t  base;
439         wide_string_t       string;
440 };
441
442 struct initializer_designator_t {
443         initializer_base_t  base;
444         designator_t       *designator;
445 };
446
447 union initializer_t {
448         initializer_kind_t        kind;
449         initializer_base_t        base;
450         initializer_value_t       value;
451         initializer_list_t        list;
452         initializer_string_t      string;
453         initializer_wide_string_t wide_string;
454         initializer_designator_t  designator;
455 };
456
457 /**
458  * GNU attributes.
459  */
460 typedef enum gnu_attribute_kind_t {
461         GNU_AK_CONST,
462         GNU_AK_VOLATILE,
463         GNU_AK_CDECL,
464         GNU_AK_STDCALL,
465         GNU_AK_FASTCALL,
466         GNU_AK_DEPRECATED,
467         GNU_AK_NOINLINE,
468         GNU_AK_NORETURN,
469         GNU_AK_NAKED,
470         GNU_AK_PURE,
471         GNU_AK_ALWAYS_INLINE,
472         GNU_AK_MALLOC,
473         GNU_AK_WEAK,
474         GNU_AK_CONSTRUCTOR,
475         GNU_AK_DESTRUCTOR,
476         GNU_AK_NOTHROW,
477         GNU_AK_TRANSPARENT_UNION,
478         GNU_AK_COMMON,
479         GNU_AK_NOCOMMON,
480         GNU_AK_PACKED,
481         GNU_AK_SHARED,
482         GNU_AK_NOTSHARED,
483         GNU_AK_USED,
484         GNU_AK_UNUSED,
485         GNU_AK_NO_INSTRUMENT_FUNCTION,
486         GNU_AK_WARN_UNUSED_RESULT,
487         GNU_AK_LONGCALL,
488         GNU_AK_SHORTCALL,
489         GNU_AK_LONG_CALL,
490         GNU_AK_SHORT_CALL,
491         GNU_AK_FUNCTION_VECTOR,
492         GNU_AK_INTERRUPT,
493         GNU_AK_INTERRUPT_HANDLER,
494         GNU_AK_NMI_HANDLER,
495         GNU_AK_NESTING,
496         GNU_AK_NEAR,
497         GNU_AK_FAR,
498         GNU_AK_SIGNAL,
499         GNU_AK_EIGTHBIT_DATA,
500         GNU_AK_TINY_DATA,
501         GNU_AK_SAVEALL,
502         GNU_AK_FLATTEN,
503         GNU_AK_SSEREGPARM,
504         GNU_AK_EXTERNALLY_VISIBLE,
505         GNU_AK_RETURN_TWICE,
506         GNU_AK_MAY_ALIAS,
507         GNU_AK_MS_STRUCT,
508         GNU_AK_GCC_STRUCT,
509         GNU_AK_DLLIMPORT,
510         GNU_AK_DLLEXPORT,
511         GNU_AK_ALIGNED,
512         GNU_AK_ALIAS,
513         GNU_AK_SECTION,
514         GNU_AK_FORMAT,
515         GNU_AK_FORMAT_ARG,
516         GNU_AK_WEAKREF,
517         GNU_AK_NONNULL,
518         GNU_AK_TLS_MODEL,
519         GNU_AK_VISIBILITY,
520         GNU_AK_REGPARM,
521         GNU_AK_MODEL,
522         GNU_AK_MODE,
523         GNU_AK_TRAP_EXIT,
524         GNU_AK_SP_SWITCH,
525         GNU_AK_SENTINEL,
526         GNU_AK_LAST
527 } gnu_attribute_kind_t;
528
529 typedef enum statement_kind_t {
530         STATEMENT_INVALID,
531         STATEMENT_EMPTY,
532         STATEMENT_COMPOUND,
533         STATEMENT_RETURN,
534         STATEMENT_DECLARATION,
535         STATEMENT_LOCAL_LABEL,
536         STATEMENT_IF,
537         STATEMENT_SWITCH,
538         STATEMENT_EXPRESSION,
539         STATEMENT_CONTINUE,
540         STATEMENT_BREAK,
541         STATEMENT_GOTO,
542         STATEMENT_LABEL,
543         STATEMENT_CASE_LABEL,
544         STATEMENT_WHILE,
545         STATEMENT_DO_WHILE,
546         STATEMENT_FOR,
547         STATEMENT_ASM,
548         STATEMENT_MS_TRY,          /**< MS __try/__finally or __try/__except */
549         STATEMENT_LEAVE            /**< MS __leave */
550 } statement_kind_t;
551
552 struct statement_base_t {
553         statement_kind_t   kind;
554         statement_t       *next;
555         source_position_t  source_position;
556         statement_t       *parent;
557         bool               reachable;
558 #ifndef NDEBUG
559         bool               transformed;
560 #endif
561 };
562
563 struct invalid_statement_t {
564         statement_base_t  base;
565 };
566
567 struct empty_statement_t {
568         statement_base_t  base;
569 };
570
571 struct return_statement_t {
572         statement_base_t  base;
573         expression_t     *value;
574 };
575
576 struct compound_statement_t {
577         statement_base_t  base;
578         statement_t      *statements;
579         scope_t           scope;
580 };
581
582 struct declaration_statement_t {
583         statement_base_t  base;
584         entity_t         *declarations_begin;
585         entity_t         *declarations_end;
586 };
587
588 struct local_label_statement_t {
589         statement_base_t  base;
590         entity_t         *labels_begin;
591         entity_t         *labels_end;
592 };
593
594 struct if_statement_t {
595         statement_base_t  base;
596         expression_t     *condition;
597         statement_t      *true_statement;
598         statement_t      *false_statement;
599 };
600
601 struct switch_statement_t {
602         statement_base_t        base;
603         expression_t           *expression;
604         statement_t            *body;
605         case_label_statement_t *first_case, *last_case;  /**< List of all cases, including default. */
606         case_label_statement_t *default_label;           /**< The default label if existent. */
607         unsigned long           default_proj_nr;         /**< The Proj-number for the default Proj. */
608 };
609
610 struct goto_statement_t {
611         statement_base_t  base;
612         label_t          *label;         /**< The destination label. */
613         expression_t     *expression;    /**< The expression for an assigned goto. */
614         goto_statement_t *next;          /**< links all goto statements of a function */
615 };
616
617 struct case_label_statement_t {
618         statement_base_t        base;
619         expression_t           *expression;    /**< The case label expression, NULL for default label. */
620         expression_t           *end_range;     /**< For GNUC case a .. b: the end range expression, NULL else. */
621         case_label_statement_t *next;          /**< link to the next case label in switch */
622         statement_t            *statement;
623         long                   first_case;     /**< The folded value of expression. */
624         long                   last_case;      /**< The folded value of end_range. */
625         bool                   is_bad;         /**< If set marked as bad to suppress warnings. */
626         bool                   is_empty_range; /**< If set marked this as an empty range. */
627 };
628
629 struct label_statement_t {
630         statement_base_t   base;
631         label_t           *label;
632         statement_t       *statement;
633         label_statement_t *next;    /**< links all label statements of a function */
634 };
635
636 struct expression_statement_t {
637         statement_base_t  base;
638         expression_t     *expression;
639 };
640
641 struct while_statement_t {
642         statement_base_t  base;
643         expression_t     *condition;
644         statement_t      *body;
645 };
646
647 struct do_while_statement_t {
648         statement_base_t  base;
649         expression_t     *condition;
650         statement_t      *body;
651 };
652
653 struct for_statement_t {
654         statement_base_t  base;
655         expression_t     *initialisation;
656         expression_t     *condition;
657         expression_t     *step;
658         statement_t      *body;
659         scope_t           scope;
660         bool              condition_reachable:1;
661         bool              step_reachable:1;
662 };
663
664 struct asm_argument_t {
665         string_t        constraints;
666         expression_t   *expression;
667         symbol_t       *symbol;
668         asm_argument_t *next;
669 };
670
671 struct asm_clobber_t {
672         string_t       clobber;
673         asm_clobber_t *next;
674 };
675
676 struct asm_statement_t {
677         statement_base_t base;
678         string_t         asm_text;
679         asm_argument_t  *inputs;
680         asm_argument_t  *outputs;
681         asm_clobber_t   *clobbers;
682         bool             is_volatile;
683 };
684
685 struct ms_try_statement_t {
686         statement_base_t  base;
687         statement_t      *try_statement;
688         expression_t     *except_expression; /**< non-null for except, NULL for finally */
689         statement_t      *final_statement;
690 };
691
692 struct leave_statement_t {
693         statement_base_t  base;
694 };
695
696 union statement_t {
697         statement_kind_t         kind;
698         statement_base_t         base;
699         return_statement_t       returns;
700         compound_statement_t     compound;
701         declaration_statement_t  declaration;
702         local_label_statement_t  local_label;
703         if_statement_t           ifs;
704         switch_statement_t       switchs;
705         goto_statement_t         gotos;
706         case_label_statement_t   case_label;
707         label_statement_t        label;
708         expression_statement_t   expression;
709         while_statement_t        whiles;
710         do_while_statement_t     do_while;
711         for_statement_t          fors;
712         asm_statement_t          asms;
713         ms_try_statement_t       ms_try;
714         leave_statement_t        leave;
715 };
716
717 struct translation_unit_t {
718         scope_t      scope;
719         statement_t *global_asm;
720 };
721
722 static inline
723 void *_allocate_ast(size_t size)
724 {
725         return obstack_alloc(&ast_obstack, size);
726 }
727
728 static inline
729 bool is_invalid_expression(expression_t *expression)
730 {
731         return expression->base.kind == EXPR_INVALID;
732 }
733
734 static inline
735 bool is_invalid_statement(statement_t *statement)
736 {
737         return statement->base.kind == STATEMENT_INVALID;
738 }
739
740
741 #define allocate_ast(size)                 _allocate_ast(size)
742
743 #endif