+2016-10-07 Alan Modra <amodra@gmail.com>
+
+ * ldexp.c (MAX): Define.
+ (exp_unop, exp_binop, exp_trinop): Alloc at least enough for
+ etree_type.value.
+
2016-10-07 Alan Modra <amodra@gmail.com>
* testsuite/lib/ld-lib.exp (is_generic_elf): New, extracted from..
}
}
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
etree_type *
exp_binop (int code, etree_type *lhs, etree_type *rhs)
{
- etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->binary));
-
+ etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->binary),
+ sizeof (new_e->value)));
new_e->type.node_code = code;
new_e->type.filename = lhs->type.filename;
new_e->type.lineno = lhs->type.lineno;
etree_type *
exp_trinop (int code, etree_type *cond, etree_type *lhs, etree_type *rhs)
{
- etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->trinary));
-
+ etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->trinary),
+ sizeof (new_e->value)));
new_e->type.node_code = code;
new_e->type.filename = cond->type.filename;
new_e->type.lineno = cond->type.lineno;
etree_type *
exp_unop (int code, etree_type *child)
{
- etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->unary));
-
+ etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->unary),
+ sizeof (new_e->value)));
new_e->unary.type.node_code = code;
new_e->unary.type.filename = child->type.filename;
new_e->unary.type.lineno = child->type.lineno;