fix printing of array types
[cparser] / type.c
diff --git a/type.c b/type.c
index bcc1b25..365b3fe 100644 (file)
--- a/type.c
+++ b/type.c
@@ -133,8 +133,7 @@ static void print_function_type_post(const function_type_t *type,
        fputc(')', out);
 }
 
-static
-void print_pointer_type_pre(const pointer_type_t *type)
+static void print_pointer_type_pre(const pointer_type_t *type)
 {
        intern_print_type_pre(type->points_to);
        fputs("*", out);
@@ -146,8 +145,14 @@ static void print_pointer_type_post(const pointer_type_t *type)
        intern_print_type_post(type->points_to);
 }
 
+static void print_array_type_pre(const array_type_t *type)
+{
+       intern_print_type_pre(type->element_type);
+}
+
 static void print_array_type_post(const array_type_t *type)
 {
+       intern_print_type_post(type->element_type);
        fputc('[', out);
        if(type->is_static) {
                fputs("static ", out);
@@ -173,7 +178,7 @@ void print_enum_definition(const declaration_t *declaration)
                fprintf(out, "%s", entry->symbol->string);
                if(entry->init.initializer != NULL) {
                        fprintf(out, " = ");
-                       print_initializer(entry->init.initializer);
+                       print_expression(entry->init.enum_value);
                }
                fprintf(out, ",\n");
        }
@@ -277,6 +282,7 @@ static void intern_print_type_pre(type_t *type)
                print_pointer_type_pre((pointer_type_t*) type);
                return;
        case TYPE_ARRAY:
+               print_array_type_pre((array_type_t*) type);
                return;
        case TYPE_TYPEDEF:
                print_typedef_type_pre((typedef_type_t*) type);
@@ -384,8 +390,6 @@ bool is_type_floating(const type_t *type)
        case ATOMIC_TYPE_FLOAT_COMPLEX:
        case ATOMIC_TYPE_DOUBLE_COMPLEX:
        case ATOMIC_TYPE_LONG_DOUBLE_COMPLEX:
-#endif
-#ifdef PROVIDE_IMAGINARY
        case ATOMIC_TYPE_FLOAT_IMAGINARY:
        case ATOMIC_TYPE_DOUBLE_IMAGINARY:
        case ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY:
@@ -420,8 +424,6 @@ bool is_type_signed(const type_t *type)
        case ATOMIC_TYPE_FLOAT_COMPLEX:
        case ATOMIC_TYPE_DOUBLE_COMPLEX:
        case ATOMIC_TYPE_LONG_DOUBLE_COMPLEX:
-#endif
-#ifdef PROVIDE_IMAGINARY
        case ATOMIC_TYPE_FLOAT_IMAGINARY:
        case ATOMIC_TYPE_DOUBLE_IMAGINARY:
        case ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY: