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