From d7cb3b9ab55120a74c160d1be66e0cc794a6aa32 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 15 Jun 2011 14:57:04 +0200 Subject: [PATCH] remove strange warning A warning which notifies me that I use a GNU extension is strange. If I don't want to use them I can do -std=c99 and turn the situation into an error. When I do use them I don't(!) want to see a warning. --- parser.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/parser.c b/parser.c index d2a8f26..8d08d6b 100644 --- a/parser.c +++ b/parser.c @@ -3768,30 +3768,28 @@ static type_t *construct_declarator_type(construct_type_t *construct_list, if (size_expression != NULL) { switch (is_constant_expression(size_expression)) { - case EXPR_CLASS_CONSTANT: { - long const size = fold_constant_to_int(size_expression); - array_type->array.size = size; - array_type->array.size_constant = true; - /* §6.7.5.2:1 If the expression is a constant expression, it shall - * have a value greater than zero. */ - if (size <= 0) { - if (size < 0 || !GNU_MODE) { - errorf(&size_expression->base.source_position, - "size of array must be greater than zero"); - } else if (warning.other) { - warningf(&size_expression->base.source_position, - "zero length arrays are a GCC extension"); - } - } - break; + case EXPR_CLASS_CONSTANT: { + long const size = fold_constant_to_int(size_expression); + array_type->array.size = size; + array_type->array.size_constant = true; + /* §6.7.5.2:1 If the expression is a constant expression, + * it shall have a value greater than zero. */ + if (size < 0) { + errorf(&size_expression->base.source_position, + "size of array must be greater than zero"); + } else if (size == 0 && !GNU_MODE) { + errorf(&size_expression->base.source_position, + "size of array must be greater than zero (zero length arrays are a GCC extension)"); } + break; + } - case EXPR_CLASS_VARIABLE: - array_type->array.is_vla = true; - break; + case EXPR_CLASS_VARIABLE: + array_type->array.is_vla = true; + break; - case EXPR_CLASS_ERROR: - break; + case EXPR_CLASS_ERROR: + break; } } -- 2.20.1