Fixed an iteration bug in type composition.

This commit is contained in:
acqn 2023-12-09 14:35:00 +08:00
parent 519a52d92c
commit 98ffc031d1
3 changed files with 7 additions and 8 deletions

View File

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

View File

@ -485,13 +485,6 @@ void TypeComposition (Type* lhs, const Type* rhs)
} else if (RightCount != UNSPECIFIED) {
SetElementCount (lhs, RightCount);
}
} else {
/* Combine the qualifiers */
if (IsClassPtr (lhs)) {
++lhs;
++rhs;
lhs->C |= GetQualifier (rhs);
}
}
/* 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 */