From: Christoph Mallon Date: Thu, 2 Jun 2011 07:20:10 +0000 (+0200) Subject: Report an error when the index of an array access is not of integer type. X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=50f1a9a89fc2250a31adafeda8449a41f4ed6aa6;p=cparser Report an error when the index of an array access is not of integer type. --- diff --git a/parser.c b/parser.c index a8ac494..2e59eed 100644 --- a/parser.c +++ b/parser.c @@ -7224,7 +7224,9 @@ static expression_t *parse_array_expression(expression_t *left) res_type = type_inside->pointer.points_to; check_idx: res_type = automatic_type_conversion(res_type); - if (is_type_atomic(idx_type, ATOMIC_TYPE_CHAR) && warning.char_subscripts) { + if (!is_type_integer(idx_type)) { + errorf(&idx->base.source_position, "array subscript must have integer type"); + } else if (is_type_atomic(idx_type, ATOMIC_TYPE_CHAR) && warning.char_subscripts) { warningf(&idx->base.source_position, "array subscript has char type"); } } else {