aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorKen Werner <ken.werner@de.ibm.com>2010-10-08 16:50:55 +0000
committerKen Werner <ken.werner@de.ibm.com>2010-10-08 16:50:55 +0000
commit3bdf2bbd3e87625fb26815d48e36fc7fb3656aca (patch)
tree8cdedd474e475a8c3e7400499b1bd70129574fd1 /gdb/valops.c
parent1360ae660fd58c21cb036ed99a76686bd675eecb (diff)
downloadgdb-3bdf2bbd3e87625fb26815d48e36fc7fb3656aca.zip
gdb-3bdf2bbd3e87625fb26815d48e36fc7fb3656aca.tar.gz
gdb-3bdf2bbd3e87625fb26815d48e36fc7fb3656aca.tar.bz2
gdb:
* valops.c (value_cast): Handle vector types. * valarith.c (value_binop): Widen scalar to vector if appropriate. gdb/testsuite: * gdb.base/gnu_vector.c (ia, ib, fa, fb): New variables. * gdb.base/gnu_vector.exp: Add tests for scalar to vector widening.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index 13c83ff..fe4576e 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -421,7 +421,8 @@ value_cast (struct type *type, struct value *arg2)
}
if (current_language->c_style_arrays
- && TYPE_CODE (type2) == TYPE_CODE_ARRAY)
+ && TYPE_CODE (type2) == TYPE_CODE_ARRAY
+ && !TYPE_VECTOR (type2))
arg2 = value_coerce_array (arg2);
if (TYPE_CODE (type2) == TYPE_CODE_FUNC)
@@ -537,6 +538,26 @@ 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;
+ int i, n;
+
+ eltype = check_typedef (TYPE_TARGET_TYPE (type));
+ arg2 = value_cast (eltype, arg2);
+ val = allocate_value (type);
+ n = TYPE_LENGTH (type) / TYPE_LENGTH (eltype);
+
+ for (i = 0; i < n; 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 (TYPE_LENGTH (type) == TYPE_LENGTH (type2))
{
if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)