Split out eval_op_type
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:05 +0000 (07:28 -0700)
This splits OP_TYPE into a new function for future use.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* eval.c (eval_op_type): New function.
(evaluate_subexp_standard): Use it.

gdb/ChangeLog
gdb/eval.c

index a7db97d1fc6f8d25b83951a955763763ffac6f5b..9bafa322e8fdc4927de8b74560be25dba020785e 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * eval.c (eval_op_type): New function.
+       (evaluate_subexp_standard): Use it.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * eval.c (eval_op_postdec): New function.
index d4d7f62eaf067cdb606277a1e98eb3e7c8b0d81c..e62f9e5dba4dea8b54b0c155ddb0a97a4f93ad7e 100644 (file)
@@ -2039,6 +2039,20 @@ eval_op_postdec (struct type *expect_type, struct expression *exp,
     }
 }
 
+/* A helper function for OP_TYPE.  */
+
+static struct value *
+eval_op_type (struct type *expect_type, struct expression *exp,
+             enum noside noside, struct type *type)
+{
+  if (noside == EVAL_SKIP)
+    return eval_skip_value (exp);
+  else if (noside == EVAL_AVOID_SIDE_EFFECTS)
+    return allocate_value (type);
+  else
+    error (_("Attempt to use a type name as an expression"));
+}
+
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
                          struct expression *exp, int *pos,
@@ -2994,12 +3008,7 @@ evaluate_subexp_standard (struct type *expect_type,
       /* The value is not supposed to be used.  This is here to make it
         easier to accommodate expressions that contain types.  */
       (*pos) += 2;
-      if (noside == EVAL_SKIP)
-       return eval_skip_value (exp);
-      else if (noside == EVAL_AVOID_SIDE_EFFECTS)
-       return allocate_value (exp->elts[pc + 1].type);
-      else
-       error (_("Attempt to use a type name as an expression"));
+      return eval_op_type (expect_type, exp, noside, exp->elts[pc + 1].type);
 
     case OP_TYPEOF:
     case OP_DECLTYPE:
This page took 0.036417 seconds and 4 git commands to generate.