From 662e82c013ac69a4e53e96ab942d8fda6440d37b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 1 Jan 2022 09:36:52 +0100 Subject: [PATCH] Handle signedness of struct members struct members are currently always treated as unsigned. This leads to incorrect behavior in contexts where the sign makes a difference. E.g. ``` struct packed { int x; } s; s.x = -1; if (s.x > 0) $display("FAILED"); ``` Query the signedness of the struct member form the type of the member. Signed-off-by: Lars-Peter Clausen --- netstruct.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netstruct.h b/netstruct.h index 767819e4b..211796f06 100644 --- a/netstruct.h +++ b/netstruct.h @@ -34,8 +34,8 @@ class netstruct_t : public LineInfo, public ivl_type_s { ivl_type_t net_type; inline ivl_variable_type_t data_type() const { return net_type->base_type(); }; - // We need to keep the individual element sign information. - bool get_signed() const { return false; }; + bool get_signed() const + { return net_type->get_signed(); } }; public: