X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast_t.h;h=41367a9786c4cb9be03fb9a193d0dbf15fbaaf50;hb=c080804a9ae61e4ba0ec6fc7288c81c326fa9ddb;hp=15d87358dce61a24f02ab8b8b1d5c3f6e950f82d;hpb=58470bf2cd0db88a0dea7d68433283b569a2ba83;p=cparser diff --git a/ast_t.h b/ast_t.h index 15d8735..41367a9 100644 --- a/ast_t.h +++ b/ast_t.h @@ -62,8 +62,7 @@ typedef enum precedence_t { * Expression kinds. */ typedef enum expression_kind_t { - EXPR_UNKNOWN = 0, - EXPR_INVALID, + EXPR_ERROR = 1, EXPR_REFERENCE, EXPR_REFERENCE_ENUM_VALUE, EXPR_LITERAL_BOOLEAN, @@ -108,7 +107,6 @@ typedef enum expression_kind_t { EXPR_UNARY_PREFIX_INCREMENT, EXPR_UNARY_PREFIX_DECREMENT, EXPR_UNARY_CAST, - EXPR_UNARY_CAST_IMPLICIT, /**< compiler generated cast */ EXPR_UNARY_ASSUME, /**< MS __assume() */ EXPR_UNARY_DELETE, EXPR_UNARY_DELETE_ARRAY, @@ -217,7 +215,6 @@ typedef enum funcname_kind_t { case EXPR_UNARY_PREFIX_INCREMENT: \ case EXPR_UNARY_PREFIX_DECREMENT: \ case EXPR_UNARY_CAST: \ - case EXPR_UNARY_CAST_IMPLICIT: \ case EXPR_UNARY_ASSUME: \ case EXPR_UNARY_DELETE: \ case EXPR_UNARY_DELETE_ARRAY: @@ -254,6 +251,11 @@ struct expression_base_t { #ifndef NDEBUG bool transformed : 1; /**< Set if this expression was transformed. */ #endif + bool implicit : 1; /**< compiler generated expression. + Examples: + select into anonymous structs + implicit casts + */ }; /** @@ -262,7 +264,7 @@ struct expression_base_t { struct literal_expression_t { expression_base_t base; string_t value; - symbol_t *suffix; + string_t suffix; /* ast2firm data */ ir_tarval *target_value; @@ -332,8 +334,6 @@ struct select_expression_t { expression_base_t base; expression_t *compound; entity_t *compound_entry; - bool implicit : 1; /**< compiler generated select - (for anonymous struct/union) */ }; struct array_access_expression_t { @@ -479,7 +479,7 @@ union initializer_t { * The statement kinds. */ typedef enum statement_kind_t { - STATEMENT_INVALID, + STATEMENT_ERROR = 1, STATEMENT_EMPTY, STATEMENT_COMPOUND, STATEMENT_RETURN, @@ -514,14 +514,6 @@ struct statement_base_t { #endif }; -struct invalid_statement_t { - statement_base_t base; -}; - -struct empty_statement_t { - statement_base_t base; -}; - struct return_statement_t { statement_base_t base; expression_t *value; /**< The return value if any. */ @@ -667,32 +659,18 @@ struct translation_unit_t { statement_t *global_asm; }; -static inline void *_allocate_ast(size_t size) -{ - return obstack_alloc(&ast_obstack, size); -} - -static inline bool is_invalid_expression(expression_t *expression) -{ - return expression->base.kind == EXPR_INVALID; -} - -static inline bool is_invalid_statement(statement_t *statement) -{ - return statement->base.kind == STATEMENT_INVALID; -} - -#define allocate_ast(size) _allocate_ast(size) - /** * Allocate an AST node with given size and * initialize all fields with zero. */ static inline void *allocate_ast_zero(size_t size) { - void *res = allocate_ast(size); - memset(res, 0, size); - return res; + return memset(obstack_alloc(&ast_obstack, size), 0, size); } +/** If set, implicit casts are printed. */ +extern bool print_implicit_casts; +/** If set parenthesis are printed to indicate operator precedence. */ +extern bool print_parenthesis; + #endif