mark implicit array sizes and don't always print them
authorMatthias Braun <matze@braunis.de>
Tue, 18 Dec 2007 14:04:04 +0000 (14:04 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 18 Dec 2007 14:04:04 +0000 (14:04 +0000)
[r18795]

parser.c
type.c
type_t.h

index fd62ec3..68b43f6 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2533,7 +2533,8 @@ static void parse_init_declarator_rest(declaration_t *declaration)
                                        panic("invalid initializer type");
                        }
 
-                       array_type->size = cnst;
+                       array_type->size              = cnst;
+                       array_type->has_implicit_size = true;
                }
        }
 
diff --git a/type.c b/type.c
index a3e4832..5c3da00 100644 (file)
--- a/type.c
+++ b/type.c
@@ -7,9 +7,10 @@
 #include "adt/error.h"
 
 static struct obstack   _type_obst;
-struct obstack         *type_obst = &_type_obst;
 static FILE            *out;
-static int              type_visited = 0;
+struct obstack         *type_obst                 = &_type_obst;
+static int              type_visited              = 0;
+static bool             print_implicit_array_size = true;
 
 static void intern_print_type_pre(const type_t *type, bool top);
 static void intern_print_type_post(const type_t *type, bool top);
@@ -189,7 +190,8 @@ static void print_array_type_post(const array_type_t *type)
                fputs("static ", out);
        }
        print_type_qualifiers(type->type.qualifiers);
-       if(type->size != NULL) {
+       if(type->size != NULL
+                       && (print_implicit_array_size || !type->has_implicit_size)) {
                print_expression(type->size);
        }
        fputc(']', out);
index 9c8a85c..a31aa5d 100644 (file)
--- a/type_t.h
+++ b/type_t.h
@@ -97,8 +97,9 @@ struct array_type_t {
        type_base_t   type;
        type_t       *element_type;
        expression_t *size;
-       bool          is_static;
-       bool          is_variable;
+       unsigned      is_static         : 1;
+       unsigned      is_variable       : 1;
+       unsigned      has_implicit_size : 1;
 };
 
 struct function_parameter_t {