if (tree == NULL)
return tree;
+#if 0
/* print the line */
/* if not block & function */
if (tree->type == EX_OP &&
filename = tree->filename;
lineno = tree->lineno;
}
+#endif
/* make sure we resolve the true & false labels for ifx */
if (tree->type == EX_OP && tree->opval.op == IFX)
/* if there is an initial value */
if (sym->ival && SPEC_SCLS (sym->etype) != S_CODE)
{
+ initList *ilist=sym->ival;
+
+ while (ilist->type == INIT_DEEP) {
+ ilist = ilist->init.deep;
+ }
+
+ /* update lineno for error msg */
+ lineno=sym->lineDef;
+ setAstLineno (ilist->init.node, lineno);
+
if (IS_AGGREGATE (sym->type)) {
work = initAggregates (sym, sym->ival, NULL);
} else {
work = newNode ('=', newAst_VALUE (symbolVal (sym)),
list2expr (sym->ival));
}
-
+
+ // just to be sure
setAstLineno (work, sym->lineDef);
+
sym->ival = NULL;
if (init)
init = newNode (NULLOP, init, work);
tree->decorated = 1;
+#if 0
/* print the line */
/* if not block & function */
if (tree->type == EX_OP &&
filename = tree->filename;
lineno = tree->lineno;
}
+#endif
/* if any child is an error | this one is an error do nothing */
if (tree->isError ||
LRVAL (tree) = RRVAL (tree) = 1;
/* if the left is a pointer */
- if (IS_PTR (LTYPE (tree)))
+ if (IS_PTR (LTYPE (tree)) || IS_ARRAY (LTYPE (tree)))
TETYPE (tree) = getSpec (TTYPE (tree) =
LTYPE (tree));
else
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=='&') {
if (compareType(toType, expr->left->ftype)!=1) {
- werror (E_INIT_WRONG);
+ werror (W_INIT_WRONG);
printFromToType(expr->left->ftype, toType);
}
// skip the cast ???
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 (E_INIT_WRONG);
+ werror (E_INCOMPAT_PTYPES);
return NULL;
}
case POINTER:
return 0;
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);
exit (1);
- // fall through
case FPOINTER:
return 1;
case CPOINTER:
/* check the type */
if (compareType (type, val->type) == 0) {
- werror (E_INIT_WRONG);
+ werror (W_INIT_WRONG);
printFromToType (val->type, type);
}
"storage class not allowed for automatic variable '%s' in reentrant function unless static" },
{ E_AUTO_ABSA, ERROR_LEVEL_ERROR,
"absolute address not allowed for automatic var '%s' in reentrant function " },
-{ E_INIT_WRONG, ERROR_LEVEL_ERROR,
+{ W_INIT_WRONG, ERROR_LEVEL_WARNING,
"Initializer different levels of indirections" },
{ E_FUNC_REDEF, ERROR_LEVEL_ERROR,
"Function name '%s' redefined " },
#define W_INIT_IGNORED 15 /* initialiser ignored */
#define E_AUTO_ASSUMED 16 /* sclass auto assumed */
#define E_AUTO_ABSA 17 /* abs addr for auto var*/
-#define E_INIT_WRONG 18 /* initializer type != */
+#define W_INIT_WRONG 18 /* initializer type != */
#define E_FUNC_REDEF 19 /* func name redefined */
#define E_ID_UNDEF 20 /* identifer undefined */
#define W_STACK_OVERFLOW 21 /* stack overflow */
*/
#include <testfwk.h>
+#if defined __mcs51 || defined __ds390 || defined __xa51
+#define XDATA xdata
+#else
+#define XDATA
+#endif
+
typedef unsigned int UINT;
typedef struct _HeapEntryState
testDivByZero(void)
{
HeapEntryState aStates[] = {
- { (void *)1, 0 }
+ { (void XDATA *)1, 0 }
};
- void *p = (void *)0x1234;
+ void *p = (void XDATA *)0x1234;
ASSERT(_getHeapEntryState(p, aStates, 1) == NULL);