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:22 -0700
commitae4bb61e199c90c71e3482169233a0f40f446484 (patch)
tree78966cfc258cf9c7b79bbd612abc75dab2578d9a
parent85d23bda83101f4c278337428dc15eda0eecc95b (diff)
downloadbinutils-ae4bb61e199c90c71e3482169233a0f40f446484.zip
binutils-ae4bb61e199c90c71e3482169233a0f40f446484.tar.gz
binutils-ae4bb61e199c90c71e3482169233a0f40f446484.tar.bz2
Introduce unop_alignof_operation
This adds class unop_alignof_operation, which implements UNOP_ALIGNOF. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class unop_alignof_operation): New. * eval.c (eval_op_alignof): No longer static.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c2
-rw-r--r--gdb/expop.h25
3 files changed, 31 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cf5d783..94bcb64 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * expop.h (class unop_alignof_operation): New.
+ * eval.c (eval_op_alignof): No longer static.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* expop.h (class unop_sizeof_operation): New.
* ax-gdb.c (unop_sizeof_operation::do_generate_ax): New method.
diff --git a/gdb/eval.c b/gdb/eval.c
index f5a5a20..3cf8bf1 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1881,7 +1881,7 @@ eval_op_ind (struct type *expect_type, struct expression *exp,
/* A helper function for UNOP_ALIGNOF. */
-static struct value *
+struct value *
eval_op_alignof (struct type *expect_type, struct expression *exp,
enum noside noside,
struct value *arg1)
diff --git a/gdb/expop.h b/gdb/expop.h
index 8cb7281..87e52ac 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -189,6 +189,10 @@ extern struct value *eval_op_ind (struct type *expect_type,
extern struct value *eval_op_type (struct type *expect_type,
struct expression *exp,
enum noside noside, struct type *type);
+extern struct value *eval_op_alignof (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ struct value *arg1);
namespace expr
{
@@ -1611,6 +1615,27 @@ protected:
override;
};
+/* Implement 'alignof'. */
+class unop_alignof_operation
+ : public maybe_constant_operation<operation_up>
+{
+public:
+
+ using maybe_constant_operation::maybe_constant_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ value *val = std::get<0> (m_storage)->evaluate (nullptr, exp,
+ EVAL_AVOID_SIDE_EFFECTS);
+ return eval_op_alignof (expect_type, exp, noside, val);
+ }
+
+ enum exp_opcode opcode () const override
+ { return UNOP_ALIGNOF; }
+};
+
} /* namespace expr */
#endif /* EXPOP_H */