type: Make an assert()ion independent of the last entry of an enum.
[cparser] / walk.c
diff --git a/walk.c b/walk.c
index 1e98f4d..647a814 100644 (file)
--- a/walk.c
+++ b/walk.c
@@ -1,21 +1,6 @@
 /*
  * 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>
 
@@ -83,7 +68,7 @@ static void walk_type(type_t *const type, const walk_env_t *const env)
                walk_entity((entity_t*)type->enumt.enume, env);
                return;
        }
-       panic("invalid type found");
+       panic("invalid type");
 }
 
 static void walk_expression(expression_t *const expr,
@@ -178,7 +163,6 @@ static void walk_expression(expression_t *const expr,
 
        case EXPR_LITERAL_CASES:
        case EXPR_LITERAL_CHARACTER:
-       case EXPR_LITERAL_WIDE_CHARACTER:
        case EXPR_REFERENCE:
        case EXPR_ENUM_CONSTANT:
        case EXPR_STRING_LITERAL:
@@ -202,7 +186,7 @@ static void walk_designator(const designator_t *designator,
 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;
@@ -215,8 +199,8 @@ static void walk_initializer(const initializer_t  *initializer,
        case INITIALIZER_DESIGNATOR:
                walk_designator(initializer->designator.designator, env);
                return;
+
        case INITIALIZER_STRING:
-       case INITIALIZER_WIDE_STRING:
                return;
        }
 }
@@ -244,8 +228,8 @@ static void walk_entity(entity_t *entity, const walk_env_t *const 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:
@@ -270,7 +254,7 @@ static void walk_entity(entity_t *entity, const walk_env_t *const env)
        case ENTITY_LOCAL_LABEL:
                return;
        }
-       panic("invalid entity found");
+       panic("invalid entity");
 }
 
 static void walk_declarations(entity_t*            entity,
@@ -336,11 +320,6 @@ static void walk_statement(statement_t *const stmt, const walk_env_t *const 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);