2011-03-18 Phil Muldoon <pmuldoon@redhat.com>
[deliverable/binutils-gdb.git] / gdb / valarith.c
index a2bf7b0eb56b3e239e75da15e77697652366b67e..68f649f3c078ce13820d4293f21e724189675f5b 100644 (file)
@@ -205,12 +205,15 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
                             && elt_offs >= TYPE_LENGTH (array_type)))
     error (_("no such vector element"));
 
-  v = allocate_value (elt_type);
   if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
-    set_value_lazy (v, 1);
+    v = allocate_value_lazy (elt_type);
   else
-    memcpy (value_contents_writeable (v),
-           value_contents (array) + elt_offs, elt_size);
+    {
+      v = allocate_value (elt_type);
+      value_contents_copy (v, value_embedded_offset (v),
+                          array, value_embedded_offset (array) + elt_offs,
+                          elt_size);
+    }
 
   set_value_component_location (v, array);
   VALUE_REGNUM (v) = VALUE_REGNUM (array);
@@ -312,15 +315,9 @@ unop_user_defined_p (enum exp_opcode op, struct value *arg1)
   if (op == UNOP_ADDR)
     return 0;
   type1 = check_typedef (value_type (arg1));
-  for (;;)
-    {
-      if (TYPE_CODE (type1) == TYPE_CODE_STRUCT)
-       return 1;
-      else if (TYPE_CODE (type1) == TYPE_CODE_REF)
-       type1 = TYPE_TARGET_TYPE (type1);
-      else
-       return 0;
-    }
+  if (TYPE_CODE (type1) == TYPE_CODE_REF)
+    type1 = check_typedef (TYPE_TARGET_TYPE (type1));
+  return TYPE_CODE (type1) == TYPE_CODE_STRUCT;
 }
 
 /* Try to find an operator named OPERATOR which takes NARGS arguments
This page took 0.024731 seconds and 4 git commands to generate.