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>
32 ENTITY_COMPOUND_MEMBER,
45 typedef unsigned char entity_kind_t;
47 typedef enum namespace_tag_t {
53 typedef unsigned char entity_namespace_t;
55 typedef enum storage_class_tag_t {
59 STORAGE_CLASS_TYPEDEF,
61 STORAGE_CLASS_REGISTER,
62 } storage_class_tag_t;
63 typedef unsigned char storage_class_t;
65 typedef enum decl_modifier_t {
67 DM_DLLIMPORT = 1 << 0,
68 DM_DLLEXPORT = 1 << 1,
71 DM_MICROSOFT_INLINE = 1 << 4,
72 DM_FORCEINLINE = 1 << 5,
73 DM_SELECTANY = 1 << 6,
77 DM_NOINLINE = 1 << 10,
78 DM_RESTRICT = 1 << 11,
80 DM_TRANSPARENT_UNION = 1 << 13,
83 DM_CONSTRUCTOR = 1 << 16,
84 DM_DESTRUCTOR = 1 << 17,
88 DM_FASTCALL = 1 << 21,
90 DM_THISCALL = 1 << 23,
91 DM_DEPRECATED = 1 << 24,
92 DM_RETURNS_TWICE = 1 << 25,
97 typedef enum elf_visibility_tag_t {
98 ELF_VISIBILITY_DEFAULT,
99 ELF_VISIBILITY_HIDDEN,
100 ELF_VISIBILITY_INTERNAL,
101 ELF_VISIBILITY_PROTECTED,
103 } elf_visibility_tag_t;
106 * A scope containing entities.
110 entity_t *last_entity; /**< pointer to last entity (so appending is fast) */
111 unsigned depth; /**< while parsing, the depth of this scope in the
116 * a named entity is something which can be referenced by its name
119 struct entity_base_t {
121 entity_namespace_t namespc;
123 source_position_t source_position;
124 scope_t *parent_scope; /**< The scope where this entity
126 entity_t *parent_entity;
128 /** next declaration in a scope */
130 /** next declaration with same symbol */
131 entity_t *symbol_next;
136 entity_t *alias; /* used for name mangling of anonymous types */
138 decl_modifiers_t modifiers;
141 bool transparent_union : 1;
144 il_alignment_t alignment;
149 bool irtype_complete : 1;
154 entity_t *alias; /* used for name mangling of anonymous types */
161 struct enum_value_t {
173 bool address_taken : 1;
174 statement_t *statement;
187 decl_modifiers_t modifiers;
189 il_alignment_t alignment;
193 struct declaration_t {
196 storage_class_t declared_storage_class;
197 storage_class_t storage_class;
198 decl_modifiers_t modifiers;
199 il_alignment_t alignment;
200 attribute_t *attributes;
201 bool used : 1; /**< Set if the declaration is used. */
202 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
208 struct compound_member_t {
210 il_size_t offset; /**< the offset of this member in the compound */
211 unsigned char bit_offset; /**< extra bit offset for bitfield members */
212 unsigned char bit_size; /**< bitsize for bitfield members */
213 bool bitfield : 1; /**< member is (part of) a bitfield */
215 bool address_taken : 1; /**< Set if the address of this
216 declaration was taken. */
224 bool thread_local : 1; /**< GCC __thread */
229 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
231 unsigned elf_visibility : 2;
233 initializer_t *initializer;
237 unsigned int value_number;
245 bool address_taken : 1;
250 unsigned int value_number;
259 bool need_closure : 1; /**< Inner function needs closure. */
260 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
261 unsigned elf_visibility : 2;
265 statement_t *statement;
266 symbol_t *actual_name; /**< gnu extension __REDIRECT */
270 ir_node *static_link; /**< if need_closure is set, the node
271 representing the static link. */
279 enum_value_t enum_value;
281 namespace_t namespacee;
283 declaration_t declaration;
285 parameter_t parameter;
287 compound_member_t compound_member;
290 #define DECLARATION_KIND_CASES \
291 case ENTITY_FUNCTION: \
292 case ENTITY_VARIABLE: \
293 case ENTITY_PARAMETER: \
294 case ENTITY_COMPOUND_MEMBER:
296 static inline bool is_declaration(const entity_t *entity)
298 switch(entity->kind) {
299 DECLARATION_KIND_CASES
306 const char *get_entity_kind_name(entity_kind_t kind);
308 entity_t *allocate_entity_zero(entity_kind_t, entity_namespace_t, symbol_t*);
310 elf_visibility_tag_t get_elf_visibility_from_string(const char *string);