From 24d36854d2810c787d81350f9d6beeff3b2df300 Mon Sep 17 00:00:00 2001 From: acqn Date: Mon, 5 Apr 2021 16:40:32 +0800 Subject: [PATCH] Minor cleanups with array element qualifiers. --- src/cc65/expr.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 64980aceb..6a4b44795 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -3132,44 +3132,28 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef) /* Deal with array ref */ if (DoArrayRef) { - TypeCode Qualifiers = T_QUAL_NONE; - Type* ElementType; - /* Check the types of array and subscript */ if (IsClassPtr (lhst)) { if (!IsClassInt (rhst)) { Error ("Array subscript is not an integer"); ED_MakeConstAbs (Expr, 0, GetCharArrayType (1)); - } else if (IsTypeArray (lhst)) { - Qualifiers = GetQualifier (lhst); } } else if (IsClassInt (lhst)) { if (!IsClassPtr (rhst)) { Error ("Subscripted value is neither array nor pointer"); ED_MakeConstAbs (Expr, 0, GetCharArrayType (1)); - } else if (IsTypeArray (rhst)) { - Qualifiers = GetQualifier (rhst); } } else { Error ("Cannot subscript"); ED_MakeConstAbs (Expr, 0, GetCharArrayType (1)); } - /* The element type has the combined qualifiers from itself and the array, - ** it is a member of (if any). - */ - ElementType = Indirect (Expr->Type); - if (GetQualifier (ElementType) != (GetQualifier (ElementType) | Qualifiers)) { - ElementType = TypeDup (ElementType); - ElementType->C |= Qualifiers; - } - /* The final result is usually an lvalue expression of element type ** referenced in the primary, unless it is once again an array. We can just ** assume the usual case first, and change it later if necessary. */ ED_IndExpr (Expr); - Expr->Type = ElementType; + Expr->Type = Indirect (Expr->Type); /* An array element is actually a variable. So the rules for variables with ** respect to the reference type apply: If it's an array, it is virtually