#define NULL_STRING_LENGTH 6
#endif
-/* XSPEC is defined in stdio.h and used here to place
- auto variables in XSEG */
-
/****************************************************************************/
-typedef char * ptr_t;
+//typedef char * ptr_t;
+#define ptr_t char *
#ifdef toupper
#undef toupper
/*--------------------------------------------------------------------------*/
-int vsprintf (const char *buf, const char *format, va_list ap)
+int vsprintf (const char *buf, char *format, va_list ap)
{
static bit left_justify;
static bit zero_padding;
sym_link *optype;
sym_link *opetype = getSpec (optype = operandType (op));
sym_link *restype;
+ int errors=0;
/* one of them has size zero then error */
if (IS_VOID (optype))
return operandFromValue (valCastLiteral (type,
operandLitValue (op)));
-
/* if casting to/from pointers, do some checking */
if (IS_PTR(type)) { // to a pointer
- if (!IS_PTR(optype)) { // from a non pointer
+ if (!IS_PTR(optype) && !IS_FUNC(optype)) { // from a non pointer
if (IS_INTEGRAL(optype)) {
// maybe this is NULL, than it's ok.
if (!(IS_LITERAL(optype) && (SPEC_CVAL(optype).v_ulong ==0))) {
// no way to set the storage
if (IS_LITERAL(optype)) {
werror(E_LITERAL_GENERIC);
+ errors++;
} else {
werror(E_NONPTR2_GENPTR);
+ errors++;
}
} else if (implicit) {
werror(W_INTEGRAL2PTR_NOCAST);
+ errors++;
}
}
- } else { // shouldn't do that with float, array or structure
- werror(E_INCOMPAT_TYPES);
+ } else {
+ // shouldn't do that with float, array or structure unless to void
+ if (!IS_VOID(getSpec(type)) &&
+ !(IS_CODEPTR(type) && IS_FUNC(optype))) {
+ werror(E_INCOMPAT_TYPES);
+ errors++;
+ }
}
} else { // from a pointer to a pointer
if (implicit) { // if not to generic, they have to match
if ((!IS_GENPTR(type) && (DCL_TYPE(optype) != DCL_TYPE(type)))) {
werror(E_INCOMPAT_PTYPES);
+ errors++;
}
}
}
if (implicit) { // sneaky
if (IS_INTEGRAL(type)) {
werror(W_PTR2INTEGRAL_NOCAST);
+ errors++;
} else { // shouldn't do that with float, array or structure
werror(E_INCOMPAT_TYPES);
+ errors++;
}
}
}
}
+ if (errors) {
+ /* fprintf (stderr, "%s%s %d: ", op->operand.symOperand->name,
+ implicit?"(implicit)":"", errors); */
+ fprintf (stderr, "from type '");
+ printTypeChain (optype, stderr);
+ fprintf (stderr, "' to type '");
+ printTypeChain (type, stderr);
+ fprintf (stderr, "'\n");
+ }
/* if they are the same size create an assignment */
if (getSize (type) == getSize (optype) &&