- some comments
[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 /**
242  * A constant.
243  */
244 struct const_expression_t {
245         expression_base_t  base;
246         union {
247                 long long      int_value;
248                 long double    float_value;
249                 string_t       character;
250                 wide_string_t  wide_character;
251         } v;
252         bool               is_ms_noop;  /**< True, if this constant is the result
253                                              of an microsoft __noop operator */
254 };
255
256 struct string_literal_expression_t {
257         expression_base_t  base;
258         string_t           value;
259 };
260
261 struct funcname_expression_t {
262         expression_base_t  base;
263         funcname_kind_t    kind;
264         string_t           value;     /**< the value once assigned. */
265 };
266
267 struct wide_string_literal_expression_t {
268         expression_base_t  base;
269         wide_string_t      value;
270 };
271
272 struct compound_literal_expression_t {
273         expression_base_t  base;
274         type_t            *type;
275         initializer_t     *initializer;
276 };
277
278 struct builtin_constant_expression_t {
279         expression_base_t  base;
280         expression_t      *value;
281 };
282
283 struct builtin_types_compatible_expression_t {
284         expression_base_t  base;
285         type_t            *left;
286         type_t            *right;
287 };
288
289 struct reference_expression_t {
290         expression_base_t  base;
291         entity_t          *entity;
292 };
293
294 /**
295  * An argument of a call.
296  */
297 struct call_argument_t {
298         expression_t    *expression;  /**< The expression which value is transmitted. */
299         call_argument_t *next;        /**< Links to the next argument of this call. */
300 };
301
302
303 struct call_expression_t {
304         expression_base_t  base;
305         expression_t      *function;  /**< The address of the function to call. */
306         call_argument_t   *arguments; /**< List of arguments of this call. */
307 };
308
309
310 struct unary_expression_t {
311         expression_base_t  base;
312         expression_t      *value;     /**< The unary operand. */
313 };
314
315 struct binary_expression_t {
316         expression_base_t  base;
317         expression_t      *left;
318         expression_t      *right;
319 };
320
321 struct select_expression_t {
322         expression_base_t  base;
323         expression_t      *compound;
324         entity_t          *compound_entry;
325 };
326
327 struct array_access_expression_t {
328         expression_base_t  base;
329         expression_t      *array_ref; /**< the referenced array */
330         expression_t      *index;     /**< the index used */
331         bool               flipped;   /**< True if index/ref was written in a 5[a] way */
332 };
333
334 struct typeprop_expression_t {
335         expression_base_t  base;
336         type_t            *type;
337         expression_t      *tp_expression;
338 };
339
340 struct designator_t {
341         source_position_t  source_position;
342         symbol_t          *symbol;      /**< the symbol if any */
343         expression_t      *array_index; /**< the array index if any */
344         designator_t      *next;
345 };
346
347 struct offsetof_expression_t {
348         expression_base_t  base;
349         type_t            *type;
350         designator_t      *designator;
351 };
352
353 struct va_start_expression_t {
354         expression_base_t  base;
355         expression_t      *ap;
356         variable_t        *parameter;
357 };
358
359 struct va_arg_expression_t {
360         expression_base_t  base;
361         expression_t      *ap;
362 };
363
364 struct conditional_expression_t {
365         expression_base_t  base;
366         expression_t      *condition;
367         expression_t      *true_expression;
368         expression_t      *false_expression;
369 };
370
371 struct statement_expression_t {
372         expression_base_t  base;
373         statement_t       *statement;
374 };
375
376 struct classify_type_expression_t {
377         expression_base_t  base;
378         expression_t      *type_expression;
379 };
380
381 struct label_address_expression_t {
382         expression_base_t  base;
383         label_t           *label;
384 };
385
386 union expression_t {
387         expression_kind_t                     kind;
388         expression_base_t                     base;
389         const_expression_t                    conste;
390         funcname_expression_t                 funcname;
391         string_literal_expression_t           string;
392         wide_string_literal_expression_t      wide_string;
393         compound_literal_expression_t         compound_literal;
394         builtin_constant_expression_t         builtin_constant;
395         builtin_types_compatible_expression_t builtin_types_compatible;
396         reference_expression_t                reference;
397         call_expression_t                     call;
398         unary_expression_t                    unary;
399         binary_expression_t                   binary;
400         select_expression_t                   select;
401         array_access_expression_t             array_access;
402         typeprop_expression_t                 typeprop;
403         offsetof_expression_t                 offsetofe;
404         va_start_expression_t                 va_starte;
405         va_arg_expression_t                   va_arge;
406         conditional_expression_t              conditional;
407         statement_expression_t                statement;
408         classify_type_expression_t            classify_type;
409         label_address_expression_t            label_address;
410 };
411
412 typedef enum initializer_kind_t {
413         INITIALIZER_VALUE,
414         INITIALIZER_LIST,
415         INITIALIZER_STRING,
416         INITIALIZER_WIDE_STRING,
417         INITIALIZER_DESIGNATOR
418 } initializer_kind_t;
419
420 struct initializer_base_t {
421         initializer_kind_t kind;
422 };
423
424 struct initializer_value_t {
425         initializer_base_t  base;
426         expression_t       *value;
427 };
428
429 struct initializer_list_t {
430         initializer_base_t  base;
431         size_t              len;
432         initializer_t      *initializers[];
433 };
434
435 struct initializer_string_t {
436         initializer_base_t base;
437         string_t           string;
438 };
439
440 struct initializer_wide_string_t {
441         initializer_base_t  base;
442         wide_string_t       string;
443 };
444
445 struct initializer_designator_t {
446         initializer_base_t  base;
447         designator_t       *designator;
448 };
449
450 union initializer_t {
451         initializer_kind_t        kind;
452         initializer_base_t        base;
453         initializer_value_t       value;
454         initializer_list_t        list;
455         initializer_string_t      string;
456         initializer_wide_string_t wide_string;
457         initializer_designator_t  designator;
458 };
459
460 /**
461  * GNU attributes.
462  */
463 typedef enum gnu_attribute_kind_t {
464         GNU_AK_CONST,
465         GNU_AK_VOLATILE,
466         GNU_AK_CDECL,
467         GNU_AK_STDCALL,
468         GNU_AK_FASTCALL,
469         GNU_AK_DEPRECATED,
470         GNU_AK_NOINLINE,
471         GNU_AK_RETURNS_TWICE,
472         GNU_AK_NORETURN,
473         GNU_AK_NAKED,
474         GNU_AK_PURE,
475         GNU_AK_ALWAYS_INLINE,
476         GNU_AK_MALLOC,
477         GNU_AK_WEAK,
478         GNU_AK_CONSTRUCTOR,
479         GNU_AK_DESTRUCTOR,
480         GNU_AK_NOTHROW,
481         GNU_AK_TRANSPARENT_UNION,
482         GNU_AK_COMMON,
483         GNU_AK_NOCOMMON,
484         GNU_AK_PACKED,
485         GNU_AK_SHARED,
486         GNU_AK_NOTSHARED,
487         GNU_AK_USED,
488         GNU_AK_UNUSED,
489         GNU_AK_NO_INSTRUMENT_FUNCTION,
490         GNU_AK_WARN_UNUSED_RESULT,
491         GNU_AK_LONGCALL,
492         GNU_AK_SHORTCALL,
493         GNU_AK_LONG_CALL,
494         GNU_AK_SHORT_CALL,
495         GNU_AK_FUNCTION_VECTOR,
496         GNU_AK_INTERRUPT,
497         GNU_AK_INTERRUPT_HANDLER,
498         GNU_AK_NMI_HANDLER,
499         GNU_AK_NESTING,
500         GNU_AK_NEAR,
501         GNU_AK_FAR,
502         GNU_AK_SIGNAL,
503         GNU_AK_EIGTHBIT_DATA,
504         GNU_AK_TINY_DATA,
505         GNU_AK_SAVEALL,
506         GNU_AK_FLATTEN,
507         GNU_AK_SSEREGPARM,
508         GNU_AK_EXTERNALLY_VISIBLE,
509         GNU_AK_RETURN_TWICE,
510         GNU_AK_MAY_ALIAS,
511         GNU_AK_MS_STRUCT,
512         GNU_AK_GCC_STRUCT,
513         GNU_AK_DLLIMPORT,
514         GNU_AK_DLLEXPORT,
515         GNU_AK_ALIGNED,
516         GNU_AK_ALIAS,
517         GNU_AK_SECTION,
518         GNU_AK_FORMAT,
519         GNU_AK_FORMAT_ARG,
520         GNU_AK_WEAKREF,
521         GNU_AK_NONNULL,
522         GNU_AK_TLS_MODEL,
523         GNU_AK_VISIBILITY,
524         GNU_AK_REGPARM,
525         GNU_AK_MODEL,
526         GNU_AK_MODE,
527         GNU_AK_TRAP_EXIT,
528         GNU_AK_SP_SWITCH,
529         GNU_AK_SENTINEL,
530         GNU_AK_LAST
531 } gnu_attribute_kind_t;
532
533 /**
534  * The statement kinds.
535  */
536 typedef enum statement_kind_t {
537         STATEMENT_INVALID,
538         STATEMENT_EMPTY,
539         STATEMENT_COMPOUND,
540         STATEMENT_RETURN,
541         STATEMENT_DECLARATION,
542         STATEMENT_IF,
543         STATEMENT_SWITCH,
544         STATEMENT_EXPRESSION,
545         STATEMENT_CONTINUE,
546         STATEMENT_BREAK,
547         STATEMENT_GOTO,
548         STATEMENT_LABEL,
549         STATEMENT_CASE_LABEL,
550         STATEMENT_WHILE,
551         STATEMENT_DO_WHILE,
552         STATEMENT_FOR,
553         STATEMENT_ASM,
554         STATEMENT_MS_TRY,          /**< MS __try/__finally or __try/__except */
555         STATEMENT_LEAVE            /**< MS __leave */
556 } statement_kind_t;
557
558 /**
559  * The base class of every statement.
560  */
561 struct statement_base_t {
562         statement_kind_t   kind;
563         statement_t       *next;         /**< Point to the next statement in a compound statement. */
564         source_position_t  source_position;
565         statement_t       *parent;       /**< The Parent statement that controls the execution. */
566         bool               reachable;    /**< True, if this statement is reachable. */
567 #ifndef NDEBUG
568         bool               transformed;
569 #endif
570 };
571
572 struct invalid_statement_t {
573         statement_base_t  base;
574 };
575
576 struct empty_statement_t {
577         statement_base_t  base;
578 };
579
580 struct return_statement_t {
581         statement_base_t  base;
582         expression_t     *value;    /**< The return value if any. */
583 };
584
585 struct compound_statement_t {
586         statement_base_t  base;
587         statement_t      *statements;
588         scope_t           scope;
589         bool              stmt_expr; /**< True if this compound statement is a statement expression. */
590 };
591
592 struct declaration_statement_t {
593         statement_base_t  base;
594         entity_t         *declarations_begin;
595         entity_t         *declarations_end;
596 };
597
598 struct if_statement_t {
599         statement_base_t  base;
600         expression_t     *condition;
601         statement_t      *true_statement;
602         statement_t      *false_statement;
603 };
604
605 struct switch_statement_t {
606         statement_base_t        base;
607         expression_t           *expression;
608         statement_t            *body;
609         case_label_statement_t *first_case, *last_case;  /**< List of all cases, including default. */
610         case_label_statement_t *default_label;           /**< The default label if existent. */
611         unsigned long           default_proj_nr;         /**< The Proj-number for the default Proj. */
612 };
613
614 struct goto_statement_t {
615         statement_base_t  base;
616         label_t          *label;         /**< The destination label. */
617         expression_t     *expression;    /**< The expression for an assigned goto. */
618         goto_statement_t *next;          /**< links all goto statements of a function */
619 };
620
621 struct case_label_statement_t {
622         statement_base_t        base;
623         expression_t           *expression;    /**< The case label expression, NULL for default label. */
624         expression_t           *end_range;     /**< For GNUC case a .. b: the end range expression, NULL else. */
625         case_label_statement_t *next;          /**< link to the next case label in switch */
626         statement_t            *statement;
627         long                   first_case;     /**< The folded value of expression. */
628         long                   last_case;      /**< The folded value of end_range. */
629         bool                   is_bad;         /**< If set marked as bad to suppress warnings. */
630         bool                   is_empty_range; /**< If set marked this as an empty range. */
631 };
632
633 struct label_statement_t {
634         statement_base_t   base;
635         label_t           *label;
636         statement_t       *statement;
637         label_statement_t *next;    /**< links all label statements of a function */
638 };
639
640 struct expression_statement_t {
641         statement_base_t  base;
642         expression_t     *expression;
643 };
644
645 struct while_statement_t {
646         statement_base_t  base;
647         expression_t     *condition;
648         statement_t      *body;
649 };
650
651 struct do_while_statement_t {
652         statement_base_t  base;
653         expression_t     *condition;
654         statement_t      *body;
655 };
656
657 struct for_statement_t {
658         statement_base_t  base;
659         expression_t     *initialisation;
660         expression_t     *condition;
661         expression_t     *step;
662         statement_t      *body;
663         scope_t           scope;
664         bool              condition_reachable:1;
665         bool              step_reachable:1;
666 };
667
668 struct asm_argument_t {
669         string_t        constraints;
670         expression_t   *expression;
671         symbol_t       *symbol;
672         asm_argument_t *next;
673 };
674
675 struct asm_clobber_t {
676         string_t       clobber;
677         asm_clobber_t *next;
678 };
679
680 struct asm_statement_t {
681         statement_base_t base;
682         string_t         asm_text;
683         asm_argument_t  *inputs;
684         asm_argument_t  *outputs;
685         asm_clobber_t   *clobbers;
686         bool             is_volatile;
687 };
688
689 struct ms_try_statement_t {
690         statement_base_t  base;
691         statement_t      *try_statement;
692         expression_t     *except_expression; /**< non-null for except, NULL for finally */
693         statement_t      *final_statement;
694 };
695
696 struct leave_statement_t {
697         statement_base_t  base;
698 };
699
700 union statement_t {
701         statement_kind_t         kind;
702         statement_base_t         base;
703         return_statement_t       returns;
704         compound_statement_t     compound;
705         declaration_statement_t  declaration;
706         if_statement_t           ifs;
707         switch_statement_t       switchs;
708         goto_statement_t         gotos;
709         case_label_statement_t   case_label;
710         label_statement_t        label;
711         expression_statement_t   expression;
712         while_statement_t        whiles;
713         do_while_statement_t     do_while;
714         for_statement_t          fors;
715         asm_statement_t          asms;
716         ms_try_statement_t       ms_try;
717         leave_statement_t        leave;
718 };
719
720 struct translation_unit_t {
721         scope_t      scope;
722         statement_t *global_asm;
723 };
724
725 static inline
726 void *_allocate_ast(size_t size)
727 {
728         return obstack_alloc(&ast_obstack, size);
729 }
730
731 static inline
732 bool is_invalid_expression(expression_t *expression)
733 {
734         return expression->base.kind == EXPR_INVALID;
735 }
736
737 static inline
738 bool is_invalid_statement(statement_t *statement)
739 {
740         return statement->base.kind == STATEMENT_INVALID;
741 }
742
743
744 #define allocate_ast(size)                 _allocate_ast(size)
745
746 #endif