git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1293
4a8a32a2-be11-0410-ad9d-
d568d2c75423
/*-----------------------------------------------------------------*/
/* constExprValue - returns the value of a constant expression */
/*-----------------------------------------------------------------*/
/* constExprValue - returns the value of a constant expression */
+/* or NULL if it is not a constant expression */
/*-----------------------------------------------------------------*/
value *
constExprValue (ast * cexpr, int check)
/*-----------------------------------------------------------------*/
value *
constExprValue (ast * cexpr, int check)
if (check)
werror (E_CONST_EXPECTED, "found expression");
if (check)
werror (E_CONST_EXPECTED, "found expression");
+ if (!val) {
+ // assuming we have been warned before
+ val=constVal("0");
+ }
+
/* if it is a float then it gets tricky */
/* otherwise it is fairly simple */
if (!IS_FLOAT (val->type)) {
/* if it is a float then it gets tricky */
/* otherwise it is fairly simple */
if (!IS_FLOAT (val->type)) {
segment = SPEC_OCLS (symIval->etype);
deleteSetItem (&segment->syms, symIval);
}
segment = SPEC_OCLS (symIval->etype);
deleteSetItem (&segment->syms, symIval);
}
}
wrong:
werror (W_INIT_WRONG);
}
wrong:
werror (W_INIT_WRONG);
/* initializers if not an extern */
if (SPEC_SCLS (sym->etype) == S_CODE &&
sym->ival == NULL &&
/* initializers if not an extern */
if (SPEC_SCLS (sym->etype) == S_CODE &&
sym->ival == NULL &&
port->mem.code_ro &&
!IS_EXTERN (sym->etype) &&
!funcInChain (sym->type))
port->mem.code_ro &&
!IS_EXTERN (sym->etype) &&
!funcInChain (sym->type))
-/*------------------------------------------------------------------*/
-/* compareType - will do type check return 1 if match */
-/*------------------------------------------------------------------*/
+/*--------------------------------------------------------------------*/
+/* compareType - will do type check return 1 if match, -1 if castable */
+/*--------------------------------------------------------------------*/
int
compareType (sym_link * dest, sym_link * src)
{
int
compareType (sym_link * dest, sym_link * src)
{
return -1;
if (SPEC_USIGN (dest) != SPEC_USIGN (src))
return -1;
if (SPEC_USIGN (dest) != SPEC_USIGN (src))