remove more unnecessary XXX_INVALID constants
authorMatthias Braun <matze@braunis.de>
Sat, 13 Aug 2011 12:00:20 +0000 (14:00 +0200)
committerMatthias Braun <matze@braunis.de>
Sat, 13 Aug 2011 12:00:20 +0000 (14:00 +0200)
entity_t.h
mangle.c
parser.c
type.c
type_t.h

index fe0ad0b..8c770ea 100644 (file)
@@ -45,8 +45,7 @@ typedef enum {
 typedef unsigned char entity_kind_t;
 
 typedef enum namespace_tag_t {
-       NAMESPACE_INVALID,
-       NAMESPACE_NORMAL,
+       NAMESPACE_NORMAL = 1,
        NAMESPACE_TAG,
        NAMESPACE_LABEL
 } namespace_tag_t;
index 2291001..780cb90 100644 (file)
--- a/mangle.c
+++ b/mangle.c
@@ -291,9 +291,6 @@ ident *create_name_win32(entity_t *entity)
                }
 
                switch (type->function.linkage) {
-               case LINKAGE_INVALID:
-                       panic("linkage type of function is invalid");
-
                case LINKAGE_C:
                        obstack_printf(o, "%s", entity->base.symbol->string);
                        break;
@@ -344,8 +341,6 @@ ident *create_name_linux_elf(entity_t *entity)
                type_t *type = skip_typeref(entity->declaration.type);
                assert(is_type_function(type));
                switch (type->function.linkage) {
-                       case LINKAGE_INVALID:
-                               panic("linkage type of function is invalid");
                        case LINKAGE_C:
                                if (entity->function.actual_name != NULL)
                                        name = entity->function.actual_name->string;
@@ -373,9 +368,6 @@ ident *create_name_macho(entity_t *entity)
                assert(is_type_function(type));
 
                switch (type->function.linkage) {
-                       case LINKAGE_INVALID:
-                               panic("linkage type of function is invalid");
-
                        default:
                                if (entity->function.actual_name != NULL)
                                        return new_id_from_str(entity->function.actual_name->string);
index 66aa333..082a6d0 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -93,7 +93,7 @@ static switch_statement_t  *current_switch    = NULL;
 static statement_t         *current_loop      = NULL;
 static statement_t         *current_parent    = NULL;
 static ms_try_statement_t  *current_try       = NULL;
-static linkage_kind_t       current_linkage   = LINKAGE_INVALID;
+static linkage_kind_t       current_linkage;
 static goto_statement_t    *goto_first        = NULL;
 static goto_statement_t   **goto_anchor       = NULL;
 static label_statement_t   *label_first       = NULL;
@@ -707,7 +707,6 @@ static void scope_pop(scope_t *old_scope)
 static entity_t *get_entity(const symbol_t *const symbol,
                             namespace_tag_t namespc)
 {
-       assert(namespc != NAMESPACE_INVALID);
        entity_t *entity = symbol->entity;
        for (; entity != NULL; entity = entity->base.symbol_next) {
                if ((namespace_tag_t)entity->base.namespc == namespc)
@@ -740,7 +739,7 @@ static void stack_push(stack_entry_t **stack_ptr, entity_t *entity)
 {
        symbol_t           *symbol  = entity->base.symbol;
        entity_namespace_t  namespc = entity->base.namespc;
-       assert(namespc != NAMESPACE_INVALID);
+       assert(namespc != 0);
 
        /* replace/add entity into entity list of the symbol */
        entity_t **anchor;
@@ -3337,8 +3336,7 @@ end_error:
 }
 
 typedef enum construct_type_kind_t {
-       CONSTRUCT_INVALID,
-       CONSTRUCT_POINTER,
+       CONSTRUCT_POINTER = 1,
        CONSTRUCT_REFERENCE,
        CONSTRUCT_FUNCTION,
        CONSTRUCT_ARRAY
@@ -3635,8 +3633,6 @@ static type_t *construct_declarator_type(construct_type_t *construct_list,
        for (; iter != NULL; iter = iter->base.next) {
                source_position_t const* const pos = &iter->base.pos;
                switch (iter->kind) {
-               case CONSTRUCT_INVALID:
-                       break;
                case CONSTRUCT_FUNCTION: {
                        construct_function_type_t *function      = &iter->function;
                        type_t                    *function_type = function->function_type;
@@ -10375,7 +10371,7 @@ static void parse_linkage_specification(void)
                new_linkage = LINKAGE_CXX;
        } else {
                errorf(&pos, "linkage string \"%s\" not recognized", linkage);
-               new_linkage = LINKAGE_INVALID;
+               new_linkage = LINKAGE_C;
        }
        current_linkage = new_linkage;
 
diff --git a/type.c b/type.c
index 10500c3..f1dedbb 100644 (file)
--- a/type.c
+++ b/type.c
@@ -312,9 +312,6 @@ static void print_imaginary_type(const imaginary_type_t *type)
 static void print_function_type_pre(const function_type_t *type)
 {
        switch (type->linkage) {
-               case LINKAGE_INVALID:
-                       break;
-
                case LINKAGE_C:
                        if (c_mode & _CXX)
                                print_string("extern \"C\" ");
index 05af673..194c1b5 100644 (file)
--- a/type_t.h
+++ b/type_t.h
@@ -106,8 +106,7 @@ struct function_parameter_t {
 
 /** Linkage specifications. */
 typedef enum linkage_kind_t {
-       LINKAGE_INVALID,
-       LINKAGE_C,       /**< C linkage. */
+       LINKAGE_C = 1,   /**< C linkage. */
        LINKAGE_CXX      /**< C++ linkage. */
 } linkage_kind_t;