mirror of
https://github.com/cc65/cc65.git
synced 2025-01-13 09:31:53 +00:00
Fixed an error: A function wasn't converted to a void pointer automatically by
the compiler. git-svn-id: svn://svn.cc65.org/cc65/trunk@4741 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
abbfaef2aa
commit
a89231ece7
@ -186,6 +186,11 @@ void TypeConversion (ExprDesc* Expr, Type* NewType)
|
|||||||
Error ("Illegal type");
|
Error ("Illegal type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If Expr is a function, convert it to pointer to function */
|
||||||
|
if (IsTypeFunc(Expr->Type)) {
|
||||||
|
Expr->Type = PointerTo (Expr->Type);
|
||||||
|
}
|
||||||
|
|
||||||
/* If both types are equal, no conversion is needed */
|
/* If both types are equal, no conversion is needed */
|
||||||
if (TypeCmp (Expr->Type, NewType) >= TC_EQUAL) {
|
if (TypeCmp (Expr->Type, NewType) >= TC_EQUAL) {
|
||||||
/* We're already done */
|
/* We're already done */
|
||||||
@ -229,7 +234,7 @@ void TypeConversion (ExprDesc* Expr, Type* NewType)
|
|||||||
*/
|
*/
|
||||||
if (!IsTypeVoid (Indirect (NewType)) && !IsTypeVoid (Indirect (Expr->Type))) {
|
if (!IsTypeVoid (Indirect (NewType)) && !IsTypeVoid (Indirect (Expr->Type))) {
|
||||||
/* Compare the types */
|
/* Compare the types */
|
||||||
switch (TypeCmp (NewType, Expr->Type)) {
|
switch (TypeCmp (NewType, Expr->Type)) {
|
||||||
|
|
||||||
case TC_INCOMPATIBLE:
|
case TC_INCOMPATIBLE:
|
||||||
Error ("Incompatible pointer types");
|
Error ("Incompatible pointer types");
|
||||||
@ -250,16 +255,6 @@ void TypeConversion (ExprDesc* Expr, Type* NewType)
|
|||||||
if (!ED_IsConstAbsInt (Expr) || Expr->IVal != 0) {
|
if (!ED_IsConstAbsInt (Expr) || Expr->IVal != 0) {
|
||||||
Warning ("Converting integer to pointer without a cast");
|
Warning ("Converting integer to pointer without a cast");
|
||||||
}
|
}
|
||||||
} else if (IsTypeFuncPtr (NewType) && IsTypeFunc(Expr->Type)) {
|
|
||||||
/* Function -> Function pointer. First convert rhs to pointer */
|
|
||||||
Expr->Type = PointerTo (Expr->Type);
|
|
||||||
|
|
||||||
/* Assignment of function to function pointer is allowed, provided
|
|
||||||
* that both functions have the same parameter list.
|
|
||||||
*/
|
|
||||||
if (TypeCmp (NewType, Expr->Type) < TC_COMPATIBLE) {
|
|
||||||
Error ("Incompatible types");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Error ("Incompatible types");
|
Error ("Incompatible types");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user