From 0c1c8650276b582c47dad917668dc0d3612b1427 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sat, 16 Aug 2008 07:16:16 +0000 Subject: [PATCH] =?utf8?q?Comply=20with=20=C2=A76.7.5.3(8).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit [r21212] --- parser.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/parser.c b/parser.c index 8688a93..f42ad8e 100644 --- a/parser.c +++ b/parser.c @@ -3387,6 +3387,8 @@ static declaration_t *parse_identifier_list(void) return declarations; } +static type_t *automatic_type_conversion(type_t *orig_type); + static void semantic_parameter(declaration_t *declaration) { /* TODO: improve error messages */ @@ -3399,19 +3401,15 @@ static void semantic_parameter(declaration_t *declaration) } type_t *const orig_type = declaration->type; - type_t * type = skip_typeref(orig_type); - - /* Array as last part of a parameter type is just syntactic sugar. Turn it - * into a pointer. § 6.7.5.3 (7) */ - if (is_type_array(type)) { - type_t *const element_type = type->array.element_type; - - type = make_pointer_type(element_type, type->base.qualifiers); - - declaration->type = type; - } + /* §6.7.5.3(7): Array as last part of a parameter type is just syntactic + * sugar. Turn it into a pointer. + * §6.7.5.3(8): A declaration of a parameter as ``function returning type'' + * shall be adjusted to ``pointer to function returning type'', as in 6.3.2.1. + */ + type_t *const type = automatic_type_conversion(orig_type); + declaration->type = type; - if (is_type_incomplete(type)) { + if (is_type_incomplete(skip_typeref(type))) { errorf(HERE, "incomplete type '%T' not allowed for parameter '%Y'", orig_type, declaration->symbol); } -- 2.20.1