EVAL should however take care of evaluating (typeof (f op e))f
*/
int fund = (*expp)->ex_type->tp_fund;
+ struct type *tp;
/* We expect an lvalue */
if (!(*expp)->ex_lvalue) {
}
if (oper == '=') {
ch7cast(&expr, oper, (*expp)->ex_type);
+ tp = expr->ex_type;
}
else { /* turn e into e' where typeof(e') = typeof (f op e) */
struct expr *extmp = intexpr((arith)0, INT);
extmp->ex_lvalue = 1;
extmp->ex_type = (*expp)->ex_type;
ch7bin(&extmp, oper, expr);
- /* note that ch7bin creates a tree of the expression
+ /* Note that ch7bin creates a tree of the expression
((typeof (f op e))f op (typeof (f op e))e),
- where f ~ extmp and e ~ expr;
- we have to use (typeof (f op e))e
+ where f ~ extmp and e ~ expr.
+ We want to use (typeof (f op e))e.
Ch7bin does not create a tree if both operands
were illegal or constants!
*/
+ tp = extmp->ex_type; /* perform the arithmetic in type tp */
if (extmp->ex_class == Oper) {
expr = extmp->OP_RIGHT;
extmp->OP_RIGHT = NILEXPR;
else
expr = extmp;
}
+
#ifndef NOBITFIELD
if (fund == FIELD)
*expp = new_oper((*expp)->ex_type->tp_up, *expp, oper, expr);
else
-#endif NOBITFIELD
*expp = new_oper((*expp)->ex_type, *expp, oper, expr);
- (*expp)->OP_TYPE = expr->ex_type; /* for EVAL() */
+#else NOBITFIELD
+ *expp = new_oper((*expp)->ex_type, *expp, oper, expr);
+#endif NOBITFIELD
+
+ (*expp)->OP_TYPE = tp; /* for EVAL() */
}
/* Some interesting (?) questions answered.
case RIGHTAB:
opnd2integral(expp, oper);
opnd2integral(&expr, oper);
- ch7cast(&expr, oper, int_type); /* leftop should be int */
+ fund = arithbalance(expp, oper, &expr); /* ch. 7.5 */
+ ch7cast(&expr, oper, int_type); /* cvt. rightop to int */
non_commutative_binop(expp, oper, expr);
break;
case '<':
#include "atw.h"
#define CRASH() crash("EVAL: CRASH at line %u", __LINE__)
-#define roundup(n) ((n) < word_size ? word_size : (n))
+#define toword(n) ((n) < word_size ? word_size : (n))
char *symbol2str();
char *long2str();
case ANDAB:
case XORAB:
case ORAB:
+ {
+ arith old_offset;
+ arith tmpvar = tmp_pointer_var(&old_offset);
+
#ifndef NOBITFIELD
if (leftop->ex_type->tp_fund == FIELD) {
eval_field(expr, code);
}
#endif NOBITFIELD
if (leftop->ex_class != Value) {
- arith old_offset;
- arith tmpvar = tmp_pointer_var(&old_offset);
-
EVAL(leftop, LVAL, TRUE, NO_LABEL, NO_LABEL);
C_lal(tmpvar);
C_sti(pointer_size);
C_lal(tmpvar);
C_loi(pointer_size);
C_loi(leftop->ex_type->tp_size);
- conversion(leftop->ex_type, tp);
- EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
- assop(tp, oper);
- conversion(tp, leftop->ex_type);
- if (gencode)
- C_dup(roundup(leftop->ex_type->tp_size));
+ }
+ else {
+ load_val(leftop, RVAL);
+ }
+ conversion(leftop->ex_type, tp);
+ EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
+ assop(tp, oper);
+ conversion(tp, leftop->ex_type);
+ if (gencode)
+ C_dup(toword(leftop->ex_type->tp_size));
+ if (leftop->ex_class != Value) {
C_lal(tmpvar);
C_loi(pointer_size);
C_sti(leftop->ex_type->tp_size);
free_tmp_var(old_offset);
}
- else {
- load_val(leftop, RVAL);
- conversion(leftop->ex_type, tp);
- EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
- assop(tp, oper);
- conversion(tp, leftop->ex_type);
- if (gencode)
- C_dup(roundup(leftop->ex_type->tp_size));
+ else {
store_val(
&(leftop->ex_object.ex_value),
leftop->ex_type
if (gencode)
conversion(leftop->ex_type, expr->ex_type);
break;
+ }
case '(':
{
register struct expr *expr;