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:
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;
+}
int getNelements (link *, initList * );
value *valForArray (struct ast * );
value *valForStructElem (struct ast *, struct ast *);
-
+value *valForCastAggr (struct ast *, link *, struct ast *, int ) ;
#endif