mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 00:29:31 +00:00
Replaced several occurance of PtrConversion() with StdConversion().
Variadic arguments of functions should be default-promoted.
This commit is contained in:
parent
3a6920bf10
commit
7e1df39432
@ -1007,6 +1007,25 @@ const Type* PtrConversion (const Type* T)
|
||||
|
||||
|
||||
|
||||
const Type* StdConversion (const Type* T)
|
||||
/* If the type is a function, convert it to pointer to function. If the
|
||||
** expression is an array, convert it to pointer to first element. If the
|
||||
** type is an integer, do integeral promotion. Otherwise return T.
|
||||
*/
|
||||
{
|
||||
if (IsTypeFunc (T)) {
|
||||
return AddressOf (T);
|
||||
} else if (IsTypeArray (T)) {
|
||||
return AddressOf (GetElementType (T));
|
||||
} else if (IsClassInt (T)) {
|
||||
return IntPromotion (T);
|
||||
} else {
|
||||
return T;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const Type* IntPromotion (const Type* T)
|
||||
/* Apply the integer promotions to T and return the result. The returned type
|
||||
** string may be T if there is no need to change it.
|
||||
|
@ -368,6 +368,12 @@ const Type* PtrConversion (const Type* T);
|
||||
** return T.
|
||||
*/
|
||||
|
||||
const Type* StdConversion (const Type* T);
|
||||
/* If the type is a function, convert it to pointer to function. If the
|
||||
** expression is an array, convert it to pointer to first element. If the
|
||||
** type is an integer, do integeral promotion. Otherwise return T.
|
||||
*/
|
||||
|
||||
const Type* IntPromotion (const Type* T);
|
||||
/* Apply the integer promotions to T and return the result. The returned type
|
||||
** string may be T if there is no need to change it.
|
||||
|
@ -765,9 +765,10 @@ static unsigned FunctionArgList (FuncDesc* Func, int IsFastcall, ExprDesc* ED)
|
||||
} else {
|
||||
|
||||
/* No prototype available. Convert array to "pointer to first
|
||||
** element", and function to "pointer to function".
|
||||
** element", function to "pointer to function" and do integral
|
||||
** promotion if necessary.
|
||||
*/
|
||||
Expr.Type = PtrConversion (Expr.Type);
|
||||
TypeConversion (&Expr, StdConversion (Expr.Type));
|
||||
|
||||
}
|
||||
|
||||
@ -3062,7 +3063,7 @@ static void parseadd (ExprDesc* Expr, int DoArrayRef)
|
||||
Error ("Invalid operands for binary operator '+'");
|
||||
} else {
|
||||
/* Array and function types must be converted to pointer types */
|
||||
Expr->Type = PtrConversion (Expr->Type);
|
||||
Expr->Type = StdConversion (Expr->Type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3341,7 +3342,7 @@ static void parsesub (ExprDesc* Expr)
|
||||
}
|
||||
|
||||
/* Result type is either a pointer or an integer */
|
||||
Expr->Type = PtrConversion (Expr->Type);
|
||||
Expr->Type = StdConversion (Expr->Type);
|
||||
|
||||
/* Condition code not set */
|
||||
ED_MarkAsUntested (Expr);
|
||||
|
Loading…
Reference in New Issue
Block a user