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

Improved diagnostics with more detailed type names.

This commit is contained in:
acqn 2020-08-03 01:16:00 +08:00 committed by Oliver Schmidt
parent 11a5f0edf1
commit 6df4f1996b
5 changed files with 13 additions and 7 deletions

View File

@ -127,7 +127,13 @@ void Assignment (ExprDesc* Expr)
/* We must have an lvalue for an assignment */
if (ED_IsRVal (Expr)) {
Error ("Invalid lvalue in assignment");
if (IsTypeArray (Expr->Type)) {
Error ("Array type '%s' is not assignable", GetFullTypeName (Expr->Type));
} else if (IsTypeFunc (Expr->Type)) {
Error ("Function type '%s' is not assignable", GetFullTypeName (Expr->Type));
} else {
Error ("Assignment to rvalue");
}
}
/* Check for assignment to const */

View File

@ -903,7 +903,7 @@ unsigned CheckedSizeOf (const Type* T)
{
unsigned Size = SizeOf (T);
if (Size == 0) {
Error ("Size of data type is unknown");
Error ("Size of type '%s' is unknown", GetFullTypeName (T));
Size = SIZEOF_CHAR; /* Don't return zero */
}
return Size;
@ -919,7 +919,7 @@ unsigned CheckedPSizeOf (const Type* T)
{
unsigned Size = PSizeOf (T);
if (Size == 0) {
Error ("Size of data type is unknown");
Error ("Size of type '%s' is unknown", GetFullTypeName (T));
Size = SIZEOF_CHAR; /* Don't return zero */
}
return Size;

View File

@ -1218,7 +1218,7 @@ static void StructRef (ExprDesc* Expr)
NextToken ();
const SymEntry Field = FindStructField (Expr->Type, Ident);
if (Field.Type == 0) {
Error ("No field named '%s' found in %s", Ident, GetBasicTypeName (Expr->Type));
Error ("No field named '%s' found in '%s'", Ident, GetFullTypeName (Expr->Type));
/* Make the expression an integer at address zero */
ED_MakeConstAbs (Expr, 0, type_int);
return;
@ -1296,7 +1296,7 @@ static void StructRef (ExprDesc* Expr)
Flags = CF_LONG | CF_UNSIGNED | CF_CONST;
break;
default:
Internal ("Invalid %s size: %u", GetBasicTypeName (Expr->Type), StructSize);
Internal ("Invalid '%s' size: %u", GetFullTypeName (Expr->Type), StructSize);
break;
}

View File

@ -513,7 +513,7 @@ void NewFunc (SymEntry* Func)
** We don't currently support this case.
*/
if (RType == Param->Type) {
Error ("Passing %s of this size by value is not supported", GetBasicTypeName (Param->Type));
Error ("Passing '%s' of this size by value is not supported", GetFullTypeName (Param->Type));
}
}

View File

@ -333,7 +333,7 @@ static void ReturnStatement (void)
/* Handle struct/union specially */
ReturnType = GetStructReplacementType (Expr.Type);
if (ReturnType == Expr.Type) {
Error ("Returning %s of this size by value is not supported", GetBasicTypeName (Expr.Type));
Error ("Returning '%s' of this size by value is not supported", GetFullTypeName (Expr.Type));
}
LoadExpr (TypeOf (ReturnType), &Expr);