/*
* This file is part of cparser.
- * Copyright (C) 2007-2009 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.
+ * Copyright (C) 2012 Matthias Braun <matze@braunis.de>
*/
#include <config.h>
case TYPE_ENUM:
walk_entity((entity_t*)type->enumt.enume, env);
return;
- case TYPE_INVALID:
- break;
}
- panic("invalid type found");
+ panic("invalid type");
}
static void walk_expression(expression_t *const expr,
walk_statement(expr->statement.statement, env);
return;
- EXPR_BINARY_CASES
+ case EXPR_BINARY_CASES:
walk_expression(expr->binary.left, env);
walk_expression(expr->binary.right, env);
return;
- EXPR_UNARY_CASES_OPTIONAL
+ case EXPR_UNARY_CASES_OPTIONAL:
if (expr->unary.value == NULL)
return;
/* FALLTHROUGH */
- EXPR_UNARY_CASES_MANDATORY
+ case EXPR_UNARY_CASES_MANDATORY:
walk_expression(expr->unary.value, env);
return;
walk_designator(expr->offsetofe.designator, env);
return;
- EXPR_LITERAL_CASES
+ case EXPR_LITERAL_CASES:
+ case EXPR_LITERAL_CHARACTER:
case EXPR_REFERENCE:
- case EXPR_REFERENCE_ENUM_VALUE:
+ case EXPR_ENUM_CONSTANT:
case EXPR_STRING_LITERAL:
- case EXPR_WIDE_STRING_LITERAL:
case EXPR_FUNCNAME:
case EXPR_LABEL_ADDRESS:
+ case EXPR_ERROR:
return;
- case EXPR_INVALID:
- break;
}
panic("invalid expr kind");
}
const walk_env_t *const env)
{
for ( ; designator != NULL; designator = designator->next) {
- walk_expression(designator->array_index, env);
+ if (designator->array_index != NULL)
+ walk_expression(designator->array_index, env);
}
}
static void walk_initializer(const initializer_t *initializer,
const walk_env_t *const env)
{
- switch(initializer->kind) {
+ switch (initializer->kind) {
case INITIALIZER_VALUE:
walk_expression(initializer->value.value, env);
return;
case INITIALIZER_DESIGNATOR:
walk_designator(initializer->designator.designator, env);
return;
+
case INITIALIZER_STRING:
- case INITIALIZER_WIDE_STRING:
return;
}
}
return;
}
case ENTITY_ENUM_VALUE:
- walk_expression(entity->enum_value.value, env);
+ if (entity->enum_value.value != NULL)
+ walk_expression(entity->enum_value.value, env);
return;
case ENTITY_TYPEDEF:
walk_type(entity->typedefe.type, env);
return;
case ENTITY_FUNCTION:
walk_type(entity->declaration.type, env);
- if (entity->function.statement != NULL)
- walk_statement(entity->function.statement, env);
+ if (entity->function.body != NULL)
+ walk_statement(entity->function.body, env);
return;
case ENTITY_COMPOUND_MEMBER:
case ENTITY_PARAMETER:
case ENTITY_LABEL:
case ENTITY_LOCAL_LABEL:
return;
- case ENTITY_INVALID:
- break;
}
- panic("invalid entity found");
+ panic("invalid entity");
}
static void walk_declarations(entity_t* entity,
return;
case STATEMENT_CASE_LABEL:
+ if (stmt->case_label.expression) {
+ walk_expression(stmt->case_label.expression, env);
+ if (stmt->case_label.end_range)
+ walk_expression(stmt->case_label.end_range, env);
+ }
walk_statement(stmt->case_label.statement, env);
return;
- case STATEMENT_WHILE:
- walk_expression(stmt->whiles.condition, env);
- walk_statement(stmt->whiles.body, env);
- return;
-
case STATEMENT_DO_WHILE:
walk_statement(stmt->do_while.body, env);
walk_expression(stmt->do_while.condition, env);
walk_statement(stmt->ms_try.final_statement, env);
return;
- case STATEMENT_INVALID:
+ case STATEMENT_COMPUTED_GOTO:
+ walk_expression(stmt->computed_goto.expression, env);
+ return;
+
+ case STATEMENT_ERROR:
case STATEMENT_EMPTY:
case STATEMENT_CONTINUE:
case STATEMENT_BREAK:
- case STATEMENT_GOTO:
case STATEMENT_ASM:
+ case STATEMENT_GOTO:
case STATEMENT_LEAVE:
return;
}