mirror of
https://github.com/cc65/cc65.git
synced 2024-12-28 06:30:16 +00:00
Fixed a bug: A similar problem as that with structs does also exist for
arrays. An array element has all qualifiers from itself and from the array declaration. git-svn-id: svn://svn.cc65.org/cc65/trunk@4334 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
8dd3cc35dc
commit
9c5224165f
@ -797,6 +797,7 @@ static void ArrayRef (ExprDesc* Expr)
|
||||
ExprDesc Subscript;
|
||||
CodeMark Mark1;
|
||||
CodeMark Mark2;
|
||||
TypeCode Qualifiers;
|
||||
Type* ElementType;
|
||||
Type* tptr1;
|
||||
|
||||
@ -838,12 +839,16 @@ static void ArrayRef (ExprDesc* Expr)
|
||||
* Since we do the necessary checking here, we can rely later on the
|
||||
* correct types.
|
||||
*/
|
||||
Qualifiers = T_QUAL_NONE;
|
||||
if (IsClassPtr (Expr->Type)) {
|
||||
if (!IsClassInt (Subscript.Type)) {
|
||||
Error ("Array subscript is not an integer");
|
||||
/* To avoid any compiler errors, make the expression a valid int */
|
||||
ED_MakeConstAbsInt (&Subscript, 0);
|
||||
}
|
||||
if (IsTypeArray (Expr->Type)) {
|
||||
Qualifiers = GetQualifier (Expr->Type);
|
||||
}
|
||||
ElementType = Indirect (Expr->Type);
|
||||
} else if (IsClassInt (Expr->Type)) {
|
||||
if (!IsClassPtr (Subscript.Type)) {
|
||||
@ -852,6 +857,8 @@ static void ArrayRef (ExprDesc* Expr)
|
||||
* address 0.
|
||||
*/
|
||||
ED_MakeConstAbs (&Subscript, 0, GetCharArrayType (1));
|
||||
} else if (IsTypeArray (Subscript.Type)) {
|
||||
Qualifiers = GetQualifier (Subscript.Type);
|
||||
}
|
||||
ElementType = Indirect (Subscript.Type);
|
||||
} else {
|
||||
@ -863,6 +870,14 @@ static void ArrayRef (ExprDesc* Expr)
|
||||
ED_MakeConstAbsInt (&Subscript, 0);
|
||||
ElementType = Indirect (Expr->Type);
|
||||
}
|
||||
|
||||
/* The element type has the combined qualifiers from itself and the array,
|
||||
* it is a member of (if any).
|
||||
*/
|
||||
if (GetQualifier (ElementType) != (GetQualifier (ElementType) | Qualifiers)) {
|
||||
ElementType = TypeDup (ElementType);
|
||||
ElementType->C |= Qualifiers;
|
||||
}
|
||||
|
||||
/* If the subscript is a bit-field, load it and make it an rvalue */
|
||||
if (ED_IsBitField (&Subscript)) {
|
||||
|
Loading…
Reference in New Issue
Block a user