aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:09 -0700
commit3634f66996bef21692e4343d5271c4c7e5fe5f52 (patch)
tree0372f5bac9502f666f629bcbaf88ef3c6f1f8d66
parent5e80600ed0e929faaeac205dbf0d4e7f9b2842cb (diff)
downloadbinutils-3634f66996bef21692e4343d5271c4c7e5fe5f52.zip
binutils-3634f66996bef21692e4343d5271c4c7e5fe5f52.tar.gz
binutils-3634f66996bef21692e4343d5271c4c7e5fe5f52.tar.bz2
Split out eval_opencl_assign
This splits BINOP_ASSIGN into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * opencl-lang.c (eval_opencl_assign): New function. (evaluate_subexp_opencl): Use it.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/opencl-lang.c27
2 files changed, 24 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a495f90..e2a8d6b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * opencl-lang.c (eval_opencl_assign): New function.
+ (evaluate_subexp_opencl): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (eval_op_objc_msgcall): New function.
(evaluate_subexp_standard): Use it.
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 183d678..b45e47e 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -670,6 +670,24 @@ opencl_relop (struct expression *exp, struct value *arg1, struct value *arg2,
return val;
}
+/* A helper function for BINOP_ASSIGN. */
+
+static struct value *
+eval_opencl_assign (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ struct value *arg1, struct value *arg2)
+{
+ if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
+ return arg1;
+
+ struct type *type1 = value_type (arg1);
+ if (deprecated_value_modifiable (arg1)
+ && VALUE_LVAL (arg1) != lval_internalvar)
+ arg2 = opencl_value_cast (type1, arg2);
+
+ return value_assign (arg1, arg2);
+}
+
/* Expression evaluator for the OpenCL. Most operations are delegated to
evaluate_subexp_standard; see that function for a description of the
arguments. */
@@ -693,14 +711,7 @@ evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
type1 = value_type (arg1);
arg2 = evaluate_subexp (type1, exp, pos, noside);
- if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
- return arg1;
-
- if (deprecated_value_modifiable (arg1)
- && VALUE_LVAL (arg1) != lval_internalvar)
- arg2 = opencl_value_cast (type1, arg2);
-
- return value_assign (arg1, arg2);
+ return eval_opencl_assign (expect_type, exp, noside, arg1, arg2);
case UNOP_CAST:
type1 = exp->elts[*pos + 1].type;