OldType = Expr->Type;
/* If we're converting to void, we're done. Note: This does also cover a
- * conversion void -> void.
- */
+ ** conversion void -> void.
+ */
if (IsTypeVoid (NewType)) {
ED_MakeRVal (Expr); /* Never an lvalue */
goto ExitPoint;
}
/* Get the sizes of the types. Since we've excluded void types, checking
- * for known sizes makes sense here.
- */
+ ** for known sizes makes sense here.
+ */
OldSize = CheckedSizeOf (OldType);
NewSize = CheckedSizeOf (NewType);
/* lvalue? */
if (ED_IsLVal (Expr)) {
- /* We have an lvalue. If the new size is smaller than the new one,
- * we don't need to do anything. The compiler will generate code
- * to load only the portion of the value that is actually needed.
- * This works only on a little endian architecture, but that's
- * what we support.
- * If both sizes are equal, do also leave the value alone.
- * If the new size is larger, we must convert the value.
- */
+ /* We have an lvalue. If the new size is smaller than the old one,
+ ** we don't need to do anything. The compiler will generate code
+ ** to load only the portion of the value that is actually needed.
+ ** This works only on a little endian architecture, but that's
+ ** what we support.
+ ** If both sizes are equal, do also leave the value alone.
+ ** If the new size is larger, we must convert the value.
+ */
if (NewSize > OldSize) {
/* Load the value into the primary */
LoadExpr (CF_NONE, Expr);
} else if (ED_IsLocAbs (Expr)) {
/* A cast of a constant numeric value to another type. Be sure
- * to handle sign extension correctly.
- */
+ ** to handle sign extension correctly.
+ */
/* Get the current and new size of the value */
unsigned OldBits = OldSize * 8;
unsigned NewBits = NewSize * 8;
/* Check if the new datatype will have a smaller range. If it
- * has a larger range, things are ok, since the value is
- * internally already represented by a long.
- */
+ ** has a larger range, things are OK, since the value is
+ ** internally already represented by a long.
+ */
if (NewBits <= OldBits) {
/* Cut the value to the new size */
} else {
/* The value is not a constant. If the sizes of the types are
- * not equal, add conversion code. Be sure to convert chars
- * correctly.
- */
+ ** not equal, add conversion code. Be sure to convert chars
+ ** correctly.
+ */
if (OldSize != NewSize) {
/* Load the value into the primary */
void TypeConversion (ExprDesc* Expr, 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.
- */
+** warnings or errors where this automatic conversion is suspicious or
+** impossible.
+*/
{
#if 0
/* Debugging */
/* First, do some type checking */
if (IsTypeVoid (NewType) || IsTypeVoid (Expr->Type)) {
/* If one of the sides are of type void, output a more apropriate
- * error message.
- */
+ ** error message.
+ */
Error ("Illegal type");
}
}
/* Pointer to pointer assignment is valid, if:
- * - both point to the same types, or
- * - the rhs pointer is a void pointer, or
- * - the lhs pointer is a void pointer.
- */
+ ** - both point to the same types, or
+ ** - the rhs pointer is a void pointer, or
+ ** - the lhs pointer is a void pointer.
+ */
if (!IsTypeVoid (Indirect (NewType)) && !IsTypeVoid (Indirect (Expr->Type))) {
/* Compare the types */
switch (TypeCmp (NewType, Expr->Type)) {
case TC_INCOMPATIBLE:
- Error ("Incompatible pointer types");
+ Error ("Incompatible pointer types at '%s'", (Expr->Sym? Expr->Sym->Name : "Unknown"));
break;
case TC_QUAL_DIFF: