From: johanknol Date: Thu, 14 Feb 2002 12:35:30 +0000 (+0000) Subject: fixed bug #517082 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e0eae3ff48a9245289412c6cead03d7a306fbee5;p=fw%2Fsdcc fixed bug #517082 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1926 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- 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 */