1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Changed parameter constness of TypeConversion().

This commit is contained in:
acqn 2020-08-02 21:51:32 +08:00 committed by Oliver Schmidt
parent 003d47cc8b
commit 80b0e57543
4 changed files with 22 additions and 3 deletions

View File

@ -1009,6 +1009,20 @@ Type* Indirect (Type* T)
const Type* IndirectConst (const Type* T)
/* Do one indirection for the given type, that is, return the type where the
** given type points to.
*/
{
/* We are expecting a pointer expression */
CHECK (IsClassPtr (T));
/* Skip the pointer or array token itself */
return T + 1;
}
Type* ArrayToPtr (Type* T)
/* Convert an array to a pointer to it's first element */
{

View File

@ -345,6 +345,11 @@ Type* Indirect (Type* T);
** given type points to.
*/
const Type* IndirectConst (const Type* T);
/* Do one indirection for the given type, that is, return the type where the
** given type points to.
*/
Type* ArrayToPtr (Type* T);
/* Convert an array to a pointer to it's first element */

View File

@ -192,7 +192,7 @@ ExitPoint:
void TypeConversion (ExprDesc* Expr, Type* NewType)
void TypeConversion (ExprDesc* Expr, const Type* NewType)
/* Do an automatic conversion of the given expression to the new type. Output
** warnings or errors where this automatic conversion is suspicious or
** impossible.
@ -264,7 +264,7 @@ void TypeConversion (ExprDesc* Expr, Type* NewType)
** - the rhs pointer is a void pointer, or
** - the lhs pointer is a void pointer.
*/
if (!IsTypeVoid (Indirect (NewType)) && !IsTypeVoid (Indirect (Expr->Type))) {
if (!IsTypeVoid (IndirectConst (NewType)) && !IsTypeVoid (Indirect (Expr->Type))) {
/* Compare the types */
switch (TypeCmp (NewType, Expr->Type)) {

View File

@ -52,7 +52,7 @@
void TypeCompatibilityDiagnostic (const Type* NewType, const Type* OldType, int IsError, const char* Msg);
/* Print error or warning message about type conversion with proper type names */
void TypeConversion (ExprDesc* Expr, Type* NewType);
void TypeConversion (ExprDesc* Expr, const Type* NewType);
/* Do an automatic conversion of the given expression to the new type. Output
** warnings or errors where this automatic conversion is suspicious or
** impossible.