Fold arithmetic integer expressions fallout
authorAlan Modra <amodra@gmail.com>
Fri, 7 Oct 2016 12:24:45 +0000 (22:54 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 7 Oct 2016 12:29:30 +0000 (22:59 +1030)
* ldexp.c (MAX): Define.
(exp_unop, exp_binop, exp_trinop): Alloc at least enough for
etree_type.value.

ld/ChangeLog
ld/ldexp.c

index 7be0a2acba7beaea349d96bb49f3f22bb58678c9..6fb93bc33aeedf11b4101b21f6c77bf3da15c9ae 100644 (file)
@@ -1,3 +1,9 @@
+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..
index a5931fdb2df6764472e2381f3b3df5421450ba0f..b2c762036da7cbad047b5cf2bbcbf7163fd34784 100644 (file)
@@ -1273,11 +1273,13 @@ exp_value_fold (etree_type *tree)
     }
 }
 
+#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;
@@ -1296,8 +1298,8 @@ exp_binop (int code, etree_type *lhs, etree_type *rhs)
 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;
@@ -1315,8 +1317,8 @@ exp_trinop (int code, etree_type *cond, etree_type *lhs, etree_type *rhs)
 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;
This page took 0.029201 seconds and 4 git commands to generate.