From: sandeep Date: Sat, 29 Apr 2000 22:25:35 +0000 (+0000) Subject: Fixed some more intialization things X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=edfd2aa694f046826f3b61da8df2535c2a0c918c;p=fw%2Fsdcc Fixed some more intialization things git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@239 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 7d032076..4920cd18 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -299,7 +299,21 @@ value *initPointer (initList *ilist) expr->left->opval.op == PTR_OP && IS_ADDRESS_OF_OP(expr->left->left)) return valForStructElem(expr->left->left->left, - expr->left->right); + expr->left->right); + + } + /* case 3. (((char *) &a) +/- constant) */ + if (IS_AST_OP(expr) && + (expr->opval.op == '+' || expr->opval.op == '-') && + IS_AST_OP(expr->left) && expr->left->opval.op == CAST && + IS_AST_OP(expr->left->right) && + expr->left->right->opval.op == '&' && + IS_AST_LIT_VALUE(expr->right)) { + + return valForCastAggr(expr->left->right->left, + expr->left->left->opval.lnk, + expr->right,expr->opval.op); + } wrong: diff --git a/src/SDCCval.c b/src/SDCCval.c index daf3f930..69e9a53b 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -1290,3 +1290,25 @@ value *valForStructElem(ast *structT, ast *elemT) val->etype = getSpec(val->type); return val; } + +/*-----------------------------------------------------------------*/ +/* valForCastAggr - will return value for a cast of an aggregate */ +/* plus minus a constant */ +/*-----------------------------------------------------------------*/ +value *valForCastAggr (ast *aexpr, link *type, ast *cnst, int op) +{ + value *val; + + if (!IS_AST_SYM_VALUE(aexpr)) return NULL; + if (!IS_AST_LIT_VALUE(cnst)) return NULL; + + val = newValue(); + + sprintf(val->name,"(%s %c %d)", + AST_SYMBOL(aexpr)->rname, op, + getSize(type->next)*(int)AST_LIT_VALUE(cnst)); + + val->type = type; + val->etype = getSpec(val->type); + return val; +} diff --git a/src/SDCCval.h b/src/SDCCval.h index 23b03936..3751bc6d 100644 --- a/src/SDCCval.h +++ b/src/SDCCval.h @@ -95,5 +95,5 @@ value *constFloatVal (char * ); int getNelements (link *, initList * ); value *valForArray (struct ast * ); value *valForStructElem (struct ast *, struct ast *); - +value *valForCastAggr (struct ast *, link *, struct ast *, int ) ; #endif