X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCglue.c;h=e8922ec841debb17375afbee0f9e0123c1fdff7f;hb=0f13c644cfaea92c44ee33764cce21da520676f1;hp=1cb787fc7ed1136b9d8642212e8c2a22a1b8fec2;hpb=d010bd18867edba95da10d259068d22d5d7c114f;p=fw%2Fsdcc diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 1cb787fc..e8922ec8 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -317,7 +317,7 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) /* initPointer - pointer initialization code massaging */ /*-----------------------------------------------------------------*/ value * -initPointer (initList * ilist) +initPointer (initList * ilist, sym_link *toType) { value *val; ast *expr = list2expr (ilist); @@ -329,6 +329,17 @@ initPointer (initList * ilist) if ((val = constExprValue (expr, FALSE))) return val; + /* (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 (W_INIT_WRONG); + printFromToType(expr->left->ftype, toType); + } + // skip the cast ??? + expr=expr->right; + } + /* no then we have to do these cludgy checks */ /* pointers can be initialized with address of a variable or address of an array element */ @@ -945,7 +956,7 @@ printIvalPtr (symbol * sym, sym_link * type, initList * ilist, FILE * oFile) return; } - if (!(val = initPointer (ilist))) + if (!(val = initPointer (ilist, type))) return; /* if character pointer */