2 * This file is part of cparser.
3 * Copyright (C) 2007-2009 Matthias Braun <matze@braunis.de>
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.
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.
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
26 #include "attribute.h"
27 #include <libfirm/firm_types.h>
33 ENTITY_COMPOUND_MEMBER,
46 typedef unsigned char entity_kind_t;
48 typedef enum namespace_tag_t {
54 typedef unsigned char entity_namespace_t;
56 typedef enum storage_class_tag_t {
60 STORAGE_CLASS_TYPEDEF,
62 STORAGE_CLASS_REGISTER,
63 } storage_class_tag_t;
64 typedef unsigned char storage_class_t;
66 typedef enum decl_modifier_t {
68 DM_DLLIMPORT = 1 << 0,
69 DM_DLLEXPORT = 1 << 1,
72 DM_MICROSOFT_INLINE = 1 << 4,
73 DM_FORCEINLINE = 1 << 5,
74 DM_SELECTANY = 1 << 6,
78 DM_NOINLINE = 1 << 10,
79 DM_RESTRICT = 1 << 11,
81 DM_TRANSPARENT_UNION = 1 << 13,
84 DM_CONSTRUCTOR = 1 << 16,
85 DM_DESTRUCTOR = 1 << 17,
89 DM_FASTCALL = 1 << 21,
91 DM_THISCALL = 1 << 23,
92 DM_DEPRECATED = 1 << 24,
93 DM_RETURNS_TWICE = 1 << 25,
99 * A scope containing entities.
103 entity_t *last_entity; /**< pointer to last entity (so appending is fast) */
104 unsigned depth; /**< while parsing, the depth of this scope in the
109 * a named entity is something which can be referenced by its name
112 struct entity_base_t {
114 entity_namespace_t namespc;
116 source_position_t source_position;
117 scope_t *parent_scope; /**< The scope where this entity
119 entity_t *parent_entity;
121 /** next declaration in a scope */
123 /** next declaration with same symbol */
124 entity_t *symbol_next;
129 entity_t *alias; /* used for name mangling of anonymous types */
131 decl_modifiers_t modifiers;
134 bool transparent_union : 1;
137 il_alignment_t alignment;
142 bool irtype_complete : 1;
147 entity_t *alias; /* used for name mangling of anonymous types */
154 struct enum_value_t {
166 bool address_taken : 1;
167 statement_t *statement;
180 decl_modifiers_t modifiers;
182 il_alignment_t alignment;
186 struct declaration_t {
189 storage_class_t declared_storage_class;
190 storage_class_t storage_class;
191 decl_modifiers_t modifiers;
192 il_alignment_t alignment;
193 attribute_t *attributes;
194 bool used : 1; /**< Set if the declaration is used. */
195 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
201 struct compound_member_t {
203 il_size_t offset; /**< the offset of this member in the compound */
204 unsigned char bit_offset; /**< extra bit offset for bitfield members */
206 bool address_taken : 1; /**< Set if the address of this
207 declaration was taken. */
215 bool thread_local : 1; /**< GCC __thread */
220 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
223 initializer_t *initializer;
227 unsigned int value_number;
235 bool address_taken : 1;
240 unsigned int value_number;
249 bool need_closure : 1; /**< Inner function needs closure. */
250 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
254 statement_t *statement;
255 symbol_t *actual_name; /**< gnu extension __REDIRECT */
259 ir_node *static_link; /**< if need_closure is set, the node
260 representing the static link. */
268 enum_value_t enum_value;
270 namespace_t namespacee;
272 declaration_t declaration;
274 parameter_t parameter;
276 compound_member_t compound_member;
279 #define DECLARATION_KIND_CASES \
280 case ENTITY_FUNCTION: \
281 case ENTITY_VARIABLE: \
282 case ENTITY_PARAMETER: \
283 case ENTITY_COMPOUND_MEMBER:
285 static inline bool is_declaration(const entity_t *entity)
287 switch(entity->kind) {
288 DECLARATION_KIND_CASES
295 const char *get_entity_kind_name(entity_kind_t kind);
297 entity_t *allocate_entity_zero(entity_kind_t kind);