Fix Rust test suite for 1.20 beta
[deliverable/binutils-gdb.git] / ld / ldexp.c
index a5931fdb2df6764472e2381f3b3df5421450ba0f..792e21e130c7f90e193d5429bcef749788722f12 100644 (file)
@@ -1,5 +1,5 @@
 /* This module handles expression trees.
-   Copyright (C) 1991-2016 Free Software Foundation, Inc.
+   Copyright (C) 1991-2017 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
 
    This file is part of the GNU Binutils.
@@ -990,16 +990,12 @@ is_align_conditional (const etree_type *tree)
 static void
 try_copy_symbol_type (struct bfd_link_hash_entry *h, etree_type *src)
 {
-  if (src->type.node_class == etree_name)
-    {
-      struct bfd_link_hash_entry *hsrc;
+  struct bfd_link_hash_entry *hsrc;
 
-      hsrc = bfd_link_hash_lookup (link_info.hash, src->name.name,
-                                   FALSE, FALSE, TRUE);
-      if (hsrc)
-       bfd_copy_link_hash_symbol_type (link_info.output_bfd, h,
-                                                   hsrc);
-    }
+  hsrc = bfd_link_hash_lookup (link_info.hash, src->name.name,
+                              FALSE, FALSE, TRUE);
+  if (hsrc != NULL)
+    bfd_copy_link_hash_symbol_type (link_info.output_bfd, h, hsrc);
 }
 
 static void
@@ -1077,6 +1073,7 @@ exp_fold_tree_1 (etree_type *tree)
                 before relaxation and so be stripped incorrectly.  */
              if (expld.phase == lang_mark_phase_enum
                  && expld.section != bfd_abs_section_ptr
+                 && expld.section != bfd_und_section_ptr
                  && !(expld.result.valid_p
                       && expld.result.value == 0
                       && (is_value (tree->assign.src, 0)
@@ -1085,7 +1082,8 @@ exp_fold_tree_1 (etree_type *tree)
                           || is_align_conditional (tree->assign.src))))
                expld.section->flags |= SEC_KEEP;
 
-             if (!expld.result.valid_p)
+             if (!expld.result.valid_p
+                 || expld.section == bfd_und_section_ptr)
                {
                  if (expld.phase != lang_mark_phase_enum)
                    einfo (_("%F%S invalid assignment to"
@@ -1273,11 +1271,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 +1296,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 +1315,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.023637 seconds and 4 git commands to generate.