if ((val = constExprValue (expr, FALSE)))
return val;
+ /* ( ptr + constant ) */
+ if (IS_AST_OP (expr) &&
+ (expr->opval.op == '+' || expr->opval.op == '-') &&
+ IS_AST_SYM_VALUE (expr->left) &&
+ (IS_ARRAY(expr->left->ftype) || IS_PTR(expr->left->ftype)) &&
+ compareType(toType, expr->left->ftype) &&
+ IS_AST_LIT_VALUE (expr->right)) {
+ return valForCastAggr (expr->left, expr->left->ftype,
+ expr->right,
+ expr->opval.op);
+ }
+
/* (char *)&a */
if (IS_AST_OP(expr) && expr->opval.op==CAST &&
IS_AST_OP(expr->right) && expr->right->opval.op=='&') {
expr->right, expr->opval.op);
}
-
/* case 4. (char *)(array type) */
if (IS_CAST_OP(expr) && IS_AST_SYM_VALUE (expr->right) &&
IS_ARRAY(expr->right->ftype)) {
return val;
}
wrong:
- werror (W_INIT_WRONG);
+ werror (E_INCOMPAT_PTYPES);
return NULL;
}
{
case IPOINTER:
case POINTER:
- return 0;
+ return GPTYPE_NEAR;
case GPOINTER:
- /* hack - if we get a generic pointer, we just assume
- * it's an FPOINTER (i.e. in XDATA space).
- */
- werror (E_CANNOT_USE_GENERIC_POINTER, iname, oname);
+ werror (E_CANNOT_USE_GENERIC_POINTER,
+ iname ? iname : "<null>",
+ oname ? oname : "<null>");
exit (1);
- // fall through
case FPOINTER:
- return 1;
+ return GPTYPE_FAR;
case CPOINTER:
- return 2;
+ return GPTYPE_CODE;
case PPOINTER:
- return 3;
+ return GPTYPE_XSTACK;
default:
fprintf (stderr, "*** internal error: unknown pointer type %d in GPByte.\n",
p_type);
/* by a string */
if (IS_CHAR (type->next)) {
if (!IS_LITERAL(list2val(ilist)->etype)) {
- werror (W_INIT_WRONG);
+ werror (E_CONST_EXPECTED);
return;
}
if (printIvalChar (type,
/* check the type */
if (compareType (type, val->type) == 0) {
werror (W_INIT_WRONG);
- printFromToType (type, val->type);
+ printFromToType (val->type, type);
}
/* if val is literal */
else
tfprintf (oFile, "\t.byte %s,%s\n", aopLiteral (val, 0), aopLiteral (val, 1));
break;
- case 3:
- fprintf (oFile, "\t.byte %s,%s,#0x02\n",
- aopLiteral (val, 0), aopLiteral (val, 1));
+ case 3: // how about '390??
+ fprintf (oFile, "\t.byte %s,%s,#0x%d\n",
+ aopLiteral (val, 0), aopLiteral (val, 1), GPTYPE_CODE);
}
return;
}
char *
tempfilename (void)
{
-#if !defined(_MSC_VER)
const char *tmpdir = NULL;
if (getenv ("TMP"))
tmpdir = getenv ("TMP");
return name;
}
}
-#endif
return tmpnam (NULL);
}
FILE *
tempfile (void)
{
-#if !defined(_MSC_VER)
const char *tmpdir = NULL;
if (getenv ("TMP"))
tmpdir = getenv ("TMP");
}
return NULL;
}
-#endif
return tmpfile ();
}
-