projects
/
cparser
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8db2893
)
Avoid unnecessary casts.
author
Christoph Mallon
<christoph.mallon@gmx.de>
Thu, 19 May 2011 11:29:46 +0000
(13:29 +0200)
committer
Christoph Mallon
<christoph.mallon@gmx.de>
Thu, 19 May 2011 11:32:37 +0000
(13:32 +0200)
parser.c
patch
|
blob
|
history
diff --git
a/parser.c
b/parser.c
index
7fd4819
..
4590d37
100644
(file)
--- a/
parser.c
+++ b/
parser.c
@@
-2415,8
+2415,8
@@
static compound_t *parse_compound_type_specifier(bool is_struct)
{
eat(is_struct ? T_struct : T_union);
{
eat(is_struct ? T_struct : T_union);
- symbol_t *symbol = NULL;
-
compound_t *compound
= NULL;
+ symbol_t *symbol
= NULL;
+
entity_t *entity
= NULL;
attribute_t *attributes = NULL;
if (token.type == T___attribute__) {
attribute_t *attributes = NULL;
if (token.type == T___attribute__) {
@@
-2429,21
+2429,20
@@
static compound_t *parse_compound_type_specifier(bool is_struct)
symbol = token.symbol;
next_token();
symbol = token.symbol;
next_token();
- entity
_t *entity
= get_tag(symbol, kind);
+ entity = get_tag(symbol, kind);
if (entity != NULL) {
if (entity != NULL) {
- compound = &entity->compound;
- if (compound->base.parent_scope != current_scope &&
+ if (entity->base.parent_scope != current_scope &&
(token.type == '{' || token.type == ';')) {
/* we're in an inner scope and have a definition. Shadow
* existing definition in outer scope */
(token.type == '{' || token.type == ';')) {
/* we're in an inner scope and have a definition. Shadow
* existing definition in outer scope */
-
compound
= NULL;
- } else if (
compound->
complete && token.type == '{') {
+
entity
= NULL;
+ } else if (
entity->compound.
complete && token.type == '{') {
assert(symbol != NULL);
errorf(HERE, "multiple definitions of '%s %Y' (previous definition %P)",
is_struct ? "struct" : "union", symbol,
assert(symbol != NULL);
errorf(HERE, "multiple definitions of '%s %Y' (previous definition %P)",
is_struct ? "struct" : "union", symbol,
- &
compound
->base.source_position);
+ &
entity
->base.source_position);
/* clear members in the hope to avoid further errors */
/* clear members in the hope to avoid further errors */
-
compound->
members.entities = NULL;
+
entity->compound.
members.entities = NULL;
}
}
} else if (token.type != '{') {
}
}
} else if (token.type != '{') {
@@
-2458,15
+2457,14
@@
static compound_t *parse_compound_type_specifier(bool is_struct)
return NULL;
}
return NULL;
}
- if (compound == NULL) {
- entity_t *entity = allocate_entity_zero(kind);
- compound = &entity->compound;
+ if (entity == NULL) {
+ entity = allocate_entity_zero(kind);
-
compound->alignment
= 1;
-
compound
->base.namespc = NAMESPACE_TAG;
-
compound
->base.source_position = token.source_position;
-
compound
->base.symbol = symbol;
-
compound
->base.parent_scope = current_scope;
+
entity->compound.alignment
= 1;
+
entity
->base.namespc = NAMESPACE_TAG;
+
entity
->base.source_position = token.source_position;
+
entity
->base.symbol = symbol;
+
entity
->base.parent_scope = current_scope;
if (symbol != NULL) {
environment_push(entity);
}
if (symbol != NULL) {
environment_push(entity);
}
@@
-2474,20
+2472,20
@@
static compound_t *parse_compound_type_specifier(bool is_struct)
}
if (token.type == '{') {
}
if (token.type == '{') {
- parse_compound_type_entries(compound);
+ parse_compound_type_entries(
&entity->
compound);
/* ISO/IEC 14882:1998(E) §7.1.3:5 */
if (symbol == NULL) {
assert(anonymous_entity == NULL);
/* ISO/IEC 14882:1998(E) §7.1.3:5 */
if (symbol == NULL) {
assert(anonymous_entity == NULL);
- anonymous_entity =
(entity_t*)compound
;
+ anonymous_entity =
entity
;
}
}
if (attributes != NULL) {
}
}
if (attributes != NULL) {
- handle_entity_attributes(attributes,
(entity_t*) compound
);
+ handle_entity_attributes(attributes,
entity
);
}
}
- return compound;
+ return
&entity->
compound;
}
static void parse_enum_entries(type_t *const enum_type)
}
static void parse_enum_entries(type_t *const enum_type)
@@
-5606,7
+5604,7
@@
static void parse_external_declaration(void)
assert(entity->kind == ENTITY_FUNCTION);
assert(ndeclaration->kind == ENTITY_FUNCTION);
assert(entity->kind == ENTITY_FUNCTION);
assert(ndeclaration->kind == ENTITY_FUNCTION);
- function_t *function = &entity->function;
+ function_t *
const
function = &entity->function;
if (ndeclaration != entity) {
function->parameters = ndeclaration->function.parameters;
}
if (ndeclaration != entity) {
function->parameters = ndeclaration->function.parameters;
}
@@
-5641,7
+5639,7
@@
static void parse_external_declaration(void)
function_t *old_current_function = current_function;
entity_t *old_current_entity = current_entity;
current_function = function;
function_t *old_current_function = current_function;
entity_t *old_current_entity = current_entity;
current_function = function;
- current_entity =
(entity_t*) function
;
+ current_entity =
entity
;
current_parent = NULL;
goto_first = NULL;
current_parent = NULL;
goto_first = NULL;
@@
-5673,7
+5671,7
@@
static void parse_external_declaration(void)
assert(current_parent == NULL);
assert(current_function == function);
assert(current_parent == NULL);
assert(current_function == function);
- assert(current_entity ==
(entity_t*) function
);
+ assert(current_entity ==
entity
);
current_entity = old_current_entity;
current_function = old_current_function;
label_pop_to(label_stack_top);
current_entity = old_current_entity;
current_function = old_current_function;
label_pop_to(label_stack_top);