From e4c3d741547cee4625f336ab1e8045ccb8be9332 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 18 Dec 2007 14:04:04 +0000 Subject: [PATCH] mark implicit array sizes and don't always print them [r18795] --- parser.c | 3 ++- type.c | 8 +++++--- type_t.h | 5 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/parser.c b/parser.c index fd62ec3..68b43f6 100644 --- 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 --- 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); diff --git a/type_t.h b/type_t.h index 9c8a85c..a31aa5d 100644 --- 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 { -- 2.20.1