From: Tom Tromey Date: Mon, 8 Mar 2021 14:27:57 +0000 (-0700) Subject: Introduce unop_alignof_operation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae4bb61e199c90c71e3482169233a0f40f446484;p=binutils-gdb.git Introduce unop_alignof_operation This adds class unop_alignof_operation, which implements UNOP_ALIGNOF. gdb/ChangeLog 2021-03-08 Tom Tromey * expop.h (class unop_alignof_operation): New. * eval.c (eval_op_alignof): No longer static. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cf5d7839f6a..94bcb64fa03 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * expop.h (class unop_alignof_operation): New. + * eval.c (eval_op_alignof): No longer static. + 2021-03-08 Tom Tromey * expop.h (class unop_sizeof_operation): New. diff --git a/gdb/eval.c b/gdb/eval.c index f5a5a205080..3cf8bf1d5a9 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 8cb7281830b..87e52acb6bf 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 +{ +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 */