mirror of
https://github.com/cc65/cc65.git
synced 2025-04-06 20:37:16 +00:00
Minor cleanups with array element qualifiers.
This commit is contained in:
parent
896f463a23
commit
24d36854d2
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user