- T_declspec may start a declaration
[cparser] / ast_t.h
diff --git a/ast_t.h b/ast_t.h
index ef20c90..6dfa8f0 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -1,3 +1,22 @@
+/*
+ * This file is part of cparser.
+ * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
 #ifndef AST_T_H
 #define AST_T_H
 
@@ -17,7 +36,8 @@ typedef enum {
        EXPR_INVALID,
        EXPR_REFERENCE,
        EXPR_CONST,
-       EXPR_CHAR_CONST,
+       EXPR_CHARACTER_CONSTANT,
+       EXPR_WIDE_CHARACTER_CONSTANT,
        EXPR_STRING_LITERAL,
        EXPR_WIDE_STRING_LITERAL,
        EXPR_COMPOUND_LITERAL,
@@ -154,9 +174,12 @@ typedef enum {
        case EXPR_UNARY_ASSUME:                \
        case EXPR_UNARY_BITFIELD_EXTRACT:
 
+/**
+ * A scope containing declarations.
+ */
 struct scope_t {
        declaration_t *declarations;      /**< List of declarations in this scope. */
-       declaration_t *last_declaration;
+       declaration_t *last_declaration;  /**< last declaration in this scope. */
 };
 
 struct expression_base_t {
@@ -168,9 +191,10 @@ struct expression_base_t {
 struct const_expression_t {
        expression_base_t  base;
        union {
-               long long    int_value;
-               long double  float_value;
-               string_t     chars;
+               long long     int_value;
+               long double   float_value;
+               string_t      character;
+               wide_string_t wide_character;
        } v;
 };
 
@@ -391,15 +415,24 @@ union initializer_t {
        initializer_designator_t  designator;
 };
 
+/**
+ * Extended microsoft modifier.
+ */
 typedef enum {
-       DM_DLLIMPORT   = (1 << 0),
-       DM_DLLEXPORT   = (1 << 1),
-       DM_THREAD      = (1 << 2),
-       DM_NAKED       = (1 << 3),
-       DM_FORCEINLINE = (1 << 4),
-       DM_NOTHROW     = (1 << 5),
-       DM_NORETURN    = (1 << 6),
-       DM_NOINLINE    = (1 << 7)
+       DM_DLLIMPORT        = (1 <<  0),
+       DM_DLLEXPORT        = (1 <<  1),
+       DM_THREAD           = (1 <<  2),
+       DM_NAKED            = (1 <<  3),
+       DM_MICROSOFT_INLINE = (1 <<  4),
+       DM_FORCEINLINE      = (1 <<  5),
+       DM_SELECTANY        = (1 <<  6),
+       DM_NOTHROW          = (1 <<  7),
+       DM_NOVTABLE         = (1 <<  8),
+       DM_NORETURN         = (1 <<  9),
+       DM_NOINLINE         = (1 << 10),
+       DM_DEPRECATED       = (1 << 11),
+       DM_RESTRICT         = (1 << 12),
+       DM_NOALIAS          = (1 << 13)
 } decl_modifier_t;
 
 typedef unsigned short decl_modifiers_t;
@@ -408,7 +441,11 @@ struct declaration_t {
        unsigned char       namespc;
        unsigned char       declared_storage_class;
        unsigned char       storage_class;
-       decl_modifiers_t    modifiers;
+       unsigned char       alignment;          /**< Alignmnet of the declaration, 0 for default. */
+       decl_modifiers_t    modifiers;          /**< MS __declspec modifiers. */
+       const char         *deprecated_string;  /**< MS deprecated string if any. */
+       symbol_t           *get_property_sym;   /**< MS get property. */
+       symbol_t           *put_property_sym;   /**< MS put property. */
        unsigned int        address_taken : 1;
        unsigned int        is_inline     : 1;
        unsigned int        used          : 1;  /**< Set if the declaration is used. */
@@ -421,8 +458,8 @@ struct declaration_t {
                initializer_t  *initializer;
                expression_t   *enum_value;
        } init;
-       scope_t             scope;
-       scope_t            *parent_scope;
+       scope_t             scope;              /**< The scope that this declaration opens. */
+       scope_t            *parent_scope;       /**< The parant scope where this declaration lives. */
 
        /** next declaration in a scope */
        declaration_t      *next;
@@ -432,16 +469,18 @@ struct declaration_t {
        /* the following fields are used in ast2firm module */
        unsigned char       declaration_kind;
        union {
-               unsigned int    value_number;
-               ir_entity      *entity;
-               ir_node        *block;
-               tarval         *enum_val;
-               ir_type        *irtype;
+               unsigned int  value_number;
+               ir_entity    *entity;
+               ir_node      *block;
+               ir_node      *vla_base;
+               tarval       *enum_val;
+               ir_type      *irtype;
        } v;
 };
 
 typedef enum {
        STATEMENT_INVALID,
+       STATEMENT_EMPTY,
        STATEMENT_COMPOUND,
        STATEMENT_RETURN,
        STATEMENT_DECLARATION,
@@ -465,6 +504,14 @@ struct statement_base_t {
        source_position_t  source_position;
 };
 
+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;
@@ -592,6 +639,19 @@ 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)
 
 #endif