string literals as array intiailizers are supported now
[cparser] / type.c
diff --git a/type.c b/type.c
index 1276df2..6653c3f 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,6 +145,11 @@ 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)
 {
        fputc('[', out);
@@ -157,6 +161,7 @@ static void print_array_type_post(const array_type_t *type)
                print_expression(type->size);
        }
        fputc(']', out);
+       intern_print_type_post(type->element_type);
 }
 
 void print_enum_definition(const declaration_t *declaration)
@@ -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);
@@ -470,7 +476,12 @@ bool is_type_incomplete(const type_t *type)
        case TYPE_FUNCTION:
                return true;
 
-       case TYPE_ARRAY:
+       case TYPE_ARRAY: {
+               const array_type_t *array_type = (const array_type_t*) type;
+
+               return array_type->size == NULL;
+       }
+
        case TYPE_ATOMIC:
        case TYPE_POINTER:
        case TYPE_ENUM:
@@ -489,8 +500,9 @@ bool is_type_incomplete(const type_t *type)
 
 bool types_compatible(const type_t *type1, const type_t *type2)
 {
-       (void) type1;
-       (void) type2;
+       if(type1 == type2)
+               return true;
+
        return true;
 }