+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.
/* 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)
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
{
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 */