summaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authoraburgess <aburgess>2013-01-25 17:16:32 +0000
committeraburgess <aburgess>2013-01-25 17:16:32 +0000
commitfebdbbf9cb02f4f696e889874d43fea5d4006c2e (patch)
treef36ea99f3d67992b6082c45140684a65347da6f8 /gdb/valops.c
parentfb5e48c5990d7d6ef7e9921a075df50ad21950a5 (diff)
downloadgdb-febdbbf9cb02f4f696e889874d43fea5d4006c2e.tar.gz
http://sourceware.org/ml/gdb-patches/2012-11/msg00312.html
gdb/ChangeLog * valarith.c (value_vector_widen): New function for replicating a scalar into a vector. (value_binop): Use value_vector_widen to widen scalar to vector rather than casting, this better matches gcc C behaviour. * valops.c (value_casst): Update logic for casting between vector types, and for casting from scalar to vector, try to match gcc C behaviour. * value.h (value_vector_widen): Declare. * opencl-lang.c (opencl_value_cast): New opencl specific casting function, handle special case for casting scalar to vector. (opencl_relop): Use opencl_value_cast. (evaluate_subexp_opencl): Use opencl_value_cast instead of value_cast, and handle BINOP_ASSIGN, UNOP_CAST, and UNOP_CAST_TYPE in order to use opencl_value_cast. gdb/testsuite/ChangeLog * gdb.base/gnu_vector.c: New variable for use in tests. * gdb.base/gnu_vector.exp: Update and extend tests to reflect changes in scalar to vector casting and widening. * gdb.python/py-type.c: New variables for use in tests. * gdb.python/py-type.exp: Update vector related tests to reflect changes in scalar to vector casting and widening.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index e3d36a12ca9..b9bc460fa67 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -546,29 +546,13 @@ value_cast (struct type *type, struct value *arg2)
minus one, instead of biasing the normal case. */
return value_from_longest (type, -1);
}
- else if (code1 == TYPE_CODE_ARRAY && TYPE_VECTOR (type) && scalar)
- {
- /* Widen the scalar to a vector. */
- struct type *eltype;
- struct value *val;
- LONGEST low_bound, high_bound;
- int i;
-
- if (!get_array_bounds (type, &low_bound, &high_bound))
- error (_("Could not determine the vector bounds"));
-
- eltype = check_typedef (TYPE_TARGET_TYPE (type));
- arg2 = value_cast (eltype, arg2);
- val = allocate_value (type);
-
- for (i = 0; i < high_bound - low_bound + 1; i++)
- {
- /* Duplicate the contents of arg2 into the destination vector. */
- memcpy (value_contents_writeable (val) + (i * TYPE_LENGTH (eltype)),
- value_contents_all (arg2), TYPE_LENGTH (eltype));
- }
- return val;
- }
+ else if (code1 == TYPE_CODE_ARRAY && TYPE_VECTOR (type)
+ && code2 == TYPE_CODE_ARRAY && TYPE_VECTOR (type2)
+ && TYPE_LENGTH (type) != TYPE_LENGTH (type2))
+ error (_("Cannot convert between vector values of different sizes"));
+ else if (code1 == TYPE_CODE_ARRAY && TYPE_VECTOR (type) && scalar
+ && TYPE_LENGTH (type) != TYPE_LENGTH (type2))
+ error (_("can only cast scalar to vector of same size"));
else if (code1 == TYPE_CODE_VOID)
{
return value_zero (type, not_lval);