mirror of
https://github.com/cc65/cc65.git
synced 2024-09-28 10:55:43 +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 */
|
/* Deal with array ref */
|
||||||
if (DoArrayRef) {
|
if (DoArrayRef) {
|
||||||
TypeCode Qualifiers = T_QUAL_NONE;
|
|
||||||
Type* ElementType;
|
|
||||||
|
|
||||||
/* Check the types of array and subscript */
|
/* Check the types of array and subscript */
|
||||||
if (IsClassPtr (lhst)) {
|
if (IsClassPtr (lhst)) {
|
||||||
if (!IsClassInt (rhst)) {
|
if (!IsClassInt (rhst)) {
|
||||||
Error ("Array subscript is not an integer");
|
Error ("Array subscript is not an integer");
|
||||||
ED_MakeConstAbs (Expr, 0, GetCharArrayType (1));
|
ED_MakeConstAbs (Expr, 0, GetCharArrayType (1));
|
||||||
} else if (IsTypeArray (lhst)) {
|
|
||||||
Qualifiers = GetQualifier (lhst);
|
|
||||||
}
|
}
|
||||||
} else if (IsClassInt (lhst)) {
|
} else if (IsClassInt (lhst)) {
|
||||||
if (!IsClassPtr (rhst)) {
|
if (!IsClassPtr (rhst)) {
|
||||||
Error ("Subscripted value is neither array nor pointer");
|
Error ("Subscripted value is neither array nor pointer");
|
||||||
ED_MakeConstAbs (Expr, 0, GetCharArrayType (1));
|
ED_MakeConstAbs (Expr, 0, GetCharArrayType (1));
|
||||||
} else if (IsTypeArray (rhst)) {
|
|
||||||
Qualifiers = GetQualifier (rhst);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error ("Cannot subscript");
|
Error ("Cannot subscript");
|
||||||
ED_MakeConstAbs (Expr, 0, GetCharArrayType (1));
|
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
|
/* 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
|
** 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.
|
** assume the usual case first, and change it later if necessary.
|
||||||
*/
|
*/
|
||||||
ED_IndExpr (Expr);
|
ED_IndExpr (Expr);
|
||||||
Expr->Type = ElementType;
|
Expr->Type = Indirect (Expr->Type);
|
||||||
|
|
||||||
/* An array element is actually a variable. So the rules for variables with
|
/* 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
|
** respect to the reference type apply: If it's an array, it is virtually
|
||||||
|
Loading…
Reference in New Issue
Block a user