From 3634f66996bef21692e4343d5271c4c7e5fe5f52 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: [PATCH] Split out eval_opencl_assign This splits BINOP_ASSIGN into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey * opencl-lang.c (eval_opencl_assign): New function. (evaluate_subexp_opencl): Use it. --- gdb/ChangeLog | 5 +++++ gdb/opencl-lang.c | 27 +++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a495f905168..e2a8d6b4e3d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * opencl-lang.c (eval_opencl_assign): New function. + (evaluate_subexp_opencl): Use it. + 2021-03-08 Tom Tromey * eval.c (eval_op_objc_msgcall): New function. diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 183d67897f0..b45e47eb506 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; -- 2.30.2