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 {
52 typedef unsigned char entity_namespace_t;
54 typedef enum storage_class_tag_t {
58 STORAGE_CLASS_TYPEDEF,
60 STORAGE_CLASS_REGISTER,
61 } storage_class_tag_t;
62 typedef unsigned char storage_class_t;
64 typedef enum decl_modifier_t {
66 DM_DLLIMPORT = 1 << 0,
67 DM_DLLEXPORT = 1 << 1,
70 DM_MICROSOFT_INLINE = 1 << 4,
71 DM_FORCEINLINE = 1 << 5,
72 DM_SELECTANY = 1 << 6,
76 DM_NOINLINE = 1 << 10,
77 DM_RESTRICT = 1 << 11,
79 DM_TRANSPARENT_UNION = 1 << 13,
82 DM_CONSTRUCTOR = 1 << 16,
83 DM_DESTRUCTOR = 1 << 17,
87 DM_FASTCALL = 1 << 21,
89 DM_THISCALL = 1 << 23,
90 DM_DEPRECATED = 1 << 24,
91 DM_RETURNS_TWICE = 1 << 25,
96 typedef enum elf_visibility_tag_t {
97 ELF_VISIBILITY_DEFAULT,
98 ELF_VISIBILITY_HIDDEN,
99 ELF_VISIBILITY_INTERNAL,
100 ELF_VISIBILITY_PROTECTED,
102 } elf_visibility_tag_t;
105 * A scope containing entities.
109 entity_t *last_entity; /**< pointer to last entity (so appending is fast) */
110 unsigned depth; /**< while parsing, the depth of this scope in the
115 * a named entity is something which can be referenced by its name
118 struct entity_base_t {
120 entity_namespace_t namespc;
122 source_position_t source_position;
123 scope_t *parent_scope; /**< The scope where this entity
125 entity_t *parent_entity;
127 /** next declaration in a scope */
129 /** next declaration with same symbol */
130 entity_t *symbol_next;
135 entity_t *alias; /* used for name mangling of anonymous types */
137 decl_modifiers_t modifiers;
140 bool transparent_union : 1;
143 il_alignment_t alignment;
148 bool irtype_complete : 1;
153 entity_t *alias; /* used for name mangling of anonymous types */
160 struct enum_value_t {
172 bool address_taken : 1;
173 statement_t *statement;
186 decl_modifiers_t modifiers;
188 il_alignment_t alignment;
192 struct declaration_t {
195 storage_class_t declared_storage_class;
196 storage_class_t storage_class;
197 decl_modifiers_t modifiers;
198 il_alignment_t alignment;
199 attribute_t *attributes;
200 bool used : 1; /**< Set if the declaration is used. */
201 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
207 struct compound_member_t {
209 il_size_t offset; /**< the offset of this member in the compound */
210 unsigned char bit_offset; /**< extra bit offset for bitfield members */
211 unsigned char bit_size; /**< bitsize for bitfield members */
212 bool bitfield : 1; /**< member is (part of) a bitfield */
214 bool address_taken : 1; /**< Set if the address of this
215 declaration was taken. */
223 bool thread_local : 1; /**< GCC __thread */
228 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
230 unsigned elf_visibility : 2;
232 initializer_t *initializer;
236 unsigned int value_number;
244 bool address_taken : 1;
249 unsigned int value_number;
258 bool need_closure : 1; /**< Inner function needs closure. */
259 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
260 unsigned elf_visibility : 2;
264 statement_t *statement;
265 symbol_t *actual_name; /**< gnu extension __REDIRECT */
269 ir_node *static_link; /**< if need_closure is set, the node
270 representing the static link. */
278 enum_value_t enum_value;
280 namespace_t namespacee;
282 declaration_t declaration;
284 parameter_t parameter;
286 compound_member_t compound_member;
289 #define DECLARATION_KIND_CASES \
290 case ENTITY_FUNCTION: \
291 case ENTITY_VARIABLE: \
292 case ENTITY_PARAMETER: \
293 case ENTITY_COMPOUND_MEMBER:
295 static inline bool is_declaration(const entity_t *entity)
297 switch(entity->kind) {
298 DECLARATION_KIND_CASES
305 const char *get_entity_kind_name(entity_kind_t kind);
307 entity_t *allocate_entity_zero(entity_kind_t, entity_namespace_t, symbol_t*);
309 elf_visibility_tag_t get_elf_visibility_from_string(const char *string);