}
/* the parameter type must be at least castable */
- if (checkType (defParm->type, actParm->ftype) == 0)
+ if (compareType (defParm->type, actParm->ftype) == 0)
{
werror (E_TYPE_MISMATCH_PARM, *parmNumber);
werror (E_CONTINUE, "defined type ");
}
/* if the parameter is castable then add the cast */
- if (checkType (defParm->type, actParm->ftype) < 0)
+ if (compareType (defParm->type, actParm->ftype) < 0)
{
ast *pTree = resolveSymbols (copyAst (actParm));
/* if they are pointers they must be castable */
if (IS_PTR (LTYPE (tree)) && IS_PTR (RTYPE (tree)))
{
- if (checkType (LTYPE (tree), RTYPE (tree)) == 0)
+ if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
{
werror (E_COMPARE_OP);
fprintf (stderr, "comparing type ");
if (!((IS_PTR (LTYPE (tree)) && IS_LITERAL (RTYPE (tree))) ||
(IS_PTR (RTYPE (tree)) && IS_LITERAL (LTYPE (tree)))))
- if (checkType (LTYPE (tree), RTYPE (tree)) == 0)
+ if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
{
werror (E_COMPARE_OP);
fprintf (stderr, "comparing type ");
case ':':
/* if they don't match we have a problem */
- if (checkType (LTYPE (tree), RTYPE (tree)) == 0)
+ if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
{
werror (E_TYPE_MISMATCH, "conditional operator", " ");
goto errorTreeReturn;
}
/* they should either match or be castable */
- if (checkType (LTYPE (tree), RTYPE (tree)) == 0)
+ if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
{
werror (E_TYPE_MISMATCH, "assignment", " ");
fprintf (stderr, "type --> '");
if (!tree->right)
goto voidcheck;
- if (checkType (currFunc->type->next, RTYPE (tree)) == 0)
+ if (compareType (currFunc->type->next, RTYPE (tree)) == 0)
{
werror (E_RETURN_MISMATCH);
goto errorTreeReturn;
}
/* if there is going to be a casing required then add it */
- if (checkType (currFunc->type->next, RTYPE (tree)) < 0)
+ if (compareType (currFunc->type->next, RTYPE (tree)) < 0)
{
#if 0 && defined DEMAND_INTEGER_PROMOTION
if (IS_INTEGRAL (currFunc->type->next))
SET_ISADDR (IC_RESULT (ic), 0);
}
/* if casting to the same */
- if (checkType (operandType (IC_RESULT (ic)),
+ if (compareType (operandType (IC_RESULT (ic)),
operandType (IC_RIGHT (ic))) == 1)
{
ic->op = '=';
/* for pointer_gets if the types of result & left r the
same then change it type of result to next */
if (IS_PTR (t1) &&
- checkType (t2 = operandType (IC_RESULT (ic)), t1) == 1)
+ compareType (t2 = operandType (IC_RESULT (ic)), t1) == 1)
{
setOperandType (IC_RESULT (ic), t2->next);
}
!computeOnly)
{
applyToSet (cseSet, findPrevIc, ic, &pdic);
- if (pdic && checkType (operandType (IC_RESULT (pdic)),
+ if (pdic && compareType (operandType (IC_RESULT (pdic)),
operandType (IC_RESULT (ic))) != 1)
pdic = NULL;
}
emitRegularMap (memmap * map, bool addPublics, bool arFlag)
{
symbol *sym;
+ ast *ival = NULL;
if (addPublics)
{
it is a global variable */
if (sym->ival && sym->level == 0)
{
- ast *ival = NULL;
if (IS_AGGREGATE (sym->type))
ival = initAggregates (sym, sym->ival, NULL);
decorateType (resolveSymbols (list2expr (sym->ival))));
codeOutFile = statsg->oFile;
allocInfo = 0;
+
+ // set ival's lineno to where the symbol was defined
+ ival->lineno=sym->lineDef;
+
eBBlockFromiCode (iCodeFromAst (ival));
allocInfo = 1;
sym->ival = NULL;
/* return the generic pointer high byte for a given pointer type. */
/*-----------------------------------------------------------------*/
int
-pointerTypeToGPByte (const int p_type)
+pointerTypeToGPByte (const int p_type, const char *iname, const char *oname)
{
switch (p_type)
{
/* 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);
+ exit (1);
+ // fall through
case FPOINTER:
return 1;
case CPOINTER:
/* printGPointerType - generates ival for generic pointer type */
/*-----------------------------------------------------------------*/
void
-printGPointerType (FILE * oFile, const char *name,
+printGPointerType (FILE * oFile, const char *iname, const char *oname,
const unsigned int type)
{
- _printPointerType (oFile, name);
- fprintf (oFile, ",#0x%02x\n", pointerTypeToGPByte (type));
+ _printPointerType (oFile, iname);
+ fprintf (oFile, ",#0x%02x\n", pointerTypeToGPByte (type, iname, oname));
}
/*-----------------------------------------------------------------*/
val = list2val (ilist);
/* check the types */
- if ((dLvl = checkType (val->type, type->next)) <= 0)
+ if ((dLvl = compareType (val->type, type->next)) <= 0)
{
tfprintf (oFile, "\t!dw !constword\n", 0);
return;
}
else if (size == GPTRSIZE)
{
- /* PENDING: 0x02 or 0x%02x, CDATA? */
- printGPointerType (oFile, val->name,
- (IS_PTR (val->type) ? DCL_TYPE (val->type) :
- PTR_TYPE (SPEC_OCLS (val->etype))));
+ int type;
+ if (IS_PTR (val->type)) {
+ type = DCL_TYPE (val->type);
+ } else {
+ type = PTR_TYPE (SPEC_OCLS (val->etype));
+ }
+ if (val->sym && val->sym->isstrlit) {
+ // this is a literal string
+ type=CPOINTER;
+ }
+ printGPointerType (oFile, val->name, sym->name, type);
}
else
{
return;
/* check the type */
- if (checkType (type, val->type) == 0)
+ if (compareType (type, val->type) == 0)
werror (E_INIT_WRONG);
/* if val is literal */
}
else if (size == GPTRSIZE)
{
- printGPointerType (oFile, val->name,
+ printGPointerType (oFile, val->name, sym->name,
(IS_PTR (val->type) ? DCL_TYPE (val->type) :
PTR_TYPE (SPEC_OCLS (val->etype))));
}
return (floatFromVal (left->operand.valOperand) ==
floatFromVal (right->operand.valOperand));
case TYPE:
- if (checkType (left->operand.typeOperand,
+ if (compareType (left->operand.typeOperand,
right->operand.typeOperand) == 1)
return 1;
}
}
/* if the operand is already the desired type then do nothing */
- if (checkType (type, optype) == 1)
+ if (compareType (type, optype) == 1)
return op;
/* if this is a literal then just change the type & return */
!IS_GENPTR (type))
{
werror (E_INCOMPAT_CAST);
- werror (E_CONTINUE, "from type '");
+ fprintf (stderr, "from type '");
printTypeChain (optype, stderr);
fprintf (stderr, "' to type '");
printTypeChain (type, stderr);
/* first check the type for pointer assignement */
if (left->isaddr && IS_PTR (ltype) && IS_ITEMP (left) &&
- checkType (ltype, rtype) < 0)
+ compareType (ltype, rtype) < 0)
{
- if (checkType (ltype->next, rtype) < 0)
+ if (compareType (ltype->next, rtype) < 0)
right = geniCodeCast (ltype->next, right, TRUE);
}
- else if (checkType (ltype, rtype) < 0)
+ else if (compareType (ltype, rtype) < 0)
right = geniCodeCast (ltype, right, TRUE);
/* if left is a true symbol & ! volatile
sym_link *rtype = operandType (right);
sym_link *ltype = operandType (left);
if (IS_PTR (rtype) && IS_ITEMP (right)
- && right->isaddr && checkType (rtype->next, ltype) == 1)
+ && right->isaddr && compareType (rtype->next, ltype) == 1)
right = geniCodeRValue (right, TRUE);
else
right = geniCodeRValue (right, FALSE);
sym_link *rtype = operandType (right);
sym_link *ltype = operandType (left);
if (IS_PTR (rtype) && IS_ITEMP (right)
- && right->isaddr && checkType (rtype->next, ltype) == 1)
+ && right->isaddr && compareType (rtype->next, ltype) == 1)
right = geniCodeRValue (right, TRUE);
else
right = geniCodeRValue (right, FALSE);
sym_link *rtype = operandType (right);
sym_link *ltype = operandType (left);
if (IS_PTR (rtype) && IS_ITEMP (right)
- && right->isaddr && checkType (rtype->next, ltype) == 1)
+ && right->isaddr && compareType (rtype->next, ltype) == 1)
{
right = geniCodeRValue (right, TRUE);
}
{
_validatePorts ();
- argc--;
- while (argc)
+ while (argc--)
{
if (!strncmp (*argv, "-m", 2))
{
return;
}
argv++;
- argc--;
}
/* Use the first in the list */
port = _ports[0];
{
for (su = 0; su < 2; su++)
{
- if (checkType (type, __multypes[bwd][su]) == 1)
+ if (compareType (type, __multypes[bwd][su]) == 1)
{
func = __conv[0][bwd][su];
goto found;
{
for (su = 0; su < 2; su++)
{
- if (checkType (type, __multypes[bwd][su]) == 1)
+ if (compareType (type, __multypes[bwd][su]) == 1)
{
func = __conv[1][bwd][su];
goto found;
{
for (su = 0; su < 2; su++)
{
- if (checkType (type, __multypes[bwd][su]) == 1)
+ if (compareType (type, __multypes[bwd][su]) == 1)
{
if (op == '*')
func = __muldiv[0][bwd][su];
if (IS_EXTERN (csym->etype))
{
/* do types match ? */
- if (checkType (csym->type, sym->type) != 1)
+ if (compareType (csym->type, sym->type) != 1)
/* no then error */
werror (E_DUPLICATE, csym->name);
/* then check the type with the current one */
if (IS_EXTERN (csym->etype))
{
- if (checkType (csym->type, sym->type) <= 0)
+ if (compareType (csym->type, sym->type) <= 0)
werror (W_EXTERN_MISMATCH, csym->name);
}
}
}
/*------------------------------------------------------------------*/
-/* checkType - will do type check return 1 if match */
+/* compareType - will do type check return 1 if match */
/*------------------------------------------------------------------*/
int
-checkType (sym_link * dest, sym_link * src)
+compareType (sym_link * dest, sym_link * src)
{
if (!dest && !src)
return 1;
if (IS_DECL (src))
{
if (DCL_TYPE (src) == DCL_TYPE (dest))
- return checkType (dest->next, src->next);
+ return compareType (dest->next, src->next);
else if (IS_PTR (src) && IS_PTR (dest))
return -1;
else if (IS_PTR (dest) && IS_ARRAY (src))
return -1;
else if (IS_PTR (dest) && IS_FUNC (dest->next) && IS_FUNC (src))
- return -1 * checkType (dest->next, src);
+ return -1 * compareType (dest->next, src);
else
return 0;
}
}
/* check the return value type */
- if (checkType (csym->type, sym->type) <= 0)
+ if (compareType (csym->type, sym->type) <= 0)
{
werror (E_PREV_DEF_CONFLICT, csym->name, "type");
werror (E_CONTINUE, "previous definition type ");
checkValue = acargs;
}
- if (checkType (exargs->type, checkValue->type) <= 0)
+ if (compareType (exargs->type, checkValue->type) <= 0)
{
werror (E_ARG_TYPE, argCnt);
return 0;
sym_link *newIntLink ();
sym_link *newCharLink ();
sym_link *newLongLink ();
-int checkType (sym_link *, sym_link *);
+int compareType (sym_link *, sym_link *);
int checkFunction (symbol *);
void cleanUpLevel (bucket **, int);
void cleanUpBlock (bucket **, int);
/* if the type from and type to are the same
then if this is the only use then packit */
- if (checkType (operandType (IC_RIGHT (ic)),
+ if (compareType (operandType (IC_RIGHT (ic)),
operandType (IC_LEFT (ic))) ==
1) {
iCode *dic =
/* if the type from and type to are the same
then if this is the only use then packit */
- if (checkType (operandType (IC_RIGHT (ic)),
+ if (compareType (operandType (IC_RIGHT (ic)),
operandType (IC_LEFT (ic))) == 1)
{
iCode *dic = packRegsForOneuse (ic, IC_RIGHT (ic), ebp);
/* if the type from and type to are the same
then if this is the only use then packit */
- if (checkType (operandType (IC_RIGHT (ic)),
+ if (compareType (operandType (IC_RIGHT (ic)),
operandType (IC_LEFT (ic))) == 1)
{
iCode *dic = packRegsForOneuse (ic, IC_RIGHT (ic), ebp);
/* if the type from and type to are the same
then if this is the only use then packit */
- if (checkType (operandType (IC_RIGHT (ic)),
+ if (compareType (operandType (IC_RIGHT (ic)),
operandType (IC_LEFT (ic))) == 1)
{
iCode *dic = packRegsForOneuse (ic, IC_RIGHT (ic), ebp);
"stray '\\' at column %d" },
{ W_NEWLINE_IN_STRING, ERROR_LEVEL_WARNING,
"newline in string constant" },
+{ E_CANNOT_USE_GENERIC_POINTER, ERROR_LEVEL_ERROR,
+ "cannot use generic pointer %s to initialize %s" },
};
/*
#define E_ARGUMENT_MISSING 148 /* Option requires an argument. */
#define W_STRAY_BACKSLASH 149
#define W_NEWLINE_IN_STRING 150
+#define E_CANNOT_USE_GENERIC_POINTER 151
/** Describes the maximum error level that will be logged. Any level
* includes all of the levels listed after it.