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