Use strstart() instead of strncmp().
[cparser] / ast_t.h
diff --git a/ast_t.h b/ast_t.h
index 2e389c0..41367a9 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -29,7 +29,6 @@
 #include "type.h"
 #include "entity_t.h"
 #include "adt/obst.h"
-#include "target_value.h"
 
 /** The AST obstack contains all data that must stay in the AST. */
 extern struct obstack ast_obstack;
@@ -63,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,
@@ -109,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,
@@ -218,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:
@@ -255,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
+                                             */
 };
 
 /**
@@ -263,10 +264,10 @@ struct expression_base_t {
 struct literal_expression_t {
        expression_base_t  base;
        string_t           value;
-       symbol_t          *suffix;
+       string_t           suffix;
 
        /* ast2firm data */
-       tarval            *target_value;
+       ir_tarval         *target_value;
 };
 
 struct string_literal_expression_t {
@@ -333,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 {
@@ -480,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,
@@ -515,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. */
@@ -668,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