1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 19:29:37 +00:00

Merge pull request #2288 from acqn/TypeFix

[cc65] Fixed an iteration bug in type composition
This commit is contained in:
Bob Andrews 2023-12-09 22:15:24 +01:00 committed by GitHub
commit 92f869cdfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 8 deletions

View File

@ -4102,9 +4102,10 @@ static void hieQuest (ExprDesc* Expr)
/* Avoid further errors */ /* Avoid further errors */
ResultType = NewPointerTo (type_void); ResultType = NewPointerTo (type_void);
} else { } else {
/* Result has the composite type */ /* Result has the properly qualified composite type */
ResultType = TypeDup (Expr2.Type); ResultType = TypeDup (Expr2.Type);
TypeComposition (ResultType, Expr3.Type); TypeComposition (ResultType, Expr3.Type);
ResultType[1].C |= GetQualifier (Indirect (Expr3.Type));
} }
} }
} else if (IsClassPtr (Expr2.Type) && Expr3IsNULL) { } else if (IsClassPtr (Expr2.Type) && Expr3IsNULL) {

View File

@ -485,13 +485,6 @@ void TypeComposition (Type* lhs, const Type* rhs)
} else if (RightCount != UNSPECIFIED) { } else if (RightCount != UNSPECIFIED) {
SetElementCount (lhs, RightCount); SetElementCount (lhs, RightCount);
} }
} else {
/* Combine the qualifiers */
if (IsClassPtr (lhs)) {
++lhs;
++rhs;
lhs->C |= GetQualifier (rhs);
}
} }
/* Next type string element */ /* Next type string element */

View File

@ -0,0 +1,5 @@
/* Bug #2285 - Regression in type composition */
void foo(); /* OK */
void foo(int (*)(int)); /* OK */
void foo(int (*)(long)); /* WRONG: Should be an error */