From e634e9c26b05da25ea5c0afc886f5793b012b5f2 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:01:57 +1300 Subject: [PATCH] aiger2: Resolve warnings - Remove unused statics CONST_FALSE and CONST_TRUE (which appear to have been folded into the `Index` declaration as CFALSE and CTRUE). - Assign default value of EMPTY_LIT to `a` and `b` for comparison ops. - Tag debug only variables with YS_MAYBE_UNUSED, don't assign unused variables (but continue to call the function because it moves the file pointer). --- backends/aiger2/aiger.cc | 7 ++----- frontends/aiger2/xaiger.cc | 18 ++++++++---------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/backends/aiger2/aiger.cc b/backends/aiger2/aiger.cc index a230cda4f9c..141217fe5d0 100644 --- a/backends/aiger2/aiger.cc +++ b/backends/aiger2/aiger.cc @@ -262,7 +262,8 @@ struct Index { if (cell->type.in(ID($gt), ID($ge))) std::swap(aport, bport); int carry = cell->type.in(ID($le), ID($ge)) ? CFALSE : CTRUE; - Lit a, b; + Lit a = Writer::EMPTY_LIT; + Lit b = Writer::EMPTY_LIT; // TODO: this might not be the most economic structure; revisit at a later date for (int i = 0; i < width; i++) { a = visit(cursor, aport[i]); @@ -664,8 +665,6 @@ struct Index { struct AigerWriter : Index { typedef unsigned int Lit; - const static Lit CONST_FALSE = 0; - const static Lit CONST_TRUE = 1; const static constexpr Lit EMPTY_LIT = std::numeric_limits::max(); static Lit negate(Lit lit) { @@ -802,8 +801,6 @@ struct AigerWriter : Index { }; struct XAigerAnalysis : Index { - const static int CONST_FALSE = 0; - const static int CONST_TRUE = 0; const static constexpr int EMPTY_LIT = -1; XAigerAnalysis() diff --git a/frontends/aiger2/xaiger.cc b/frontends/aiger2/xaiger.cc index 04beee3965b..dd3ca428547 100644 --- a/frontends/aiger2/xaiger.cc +++ b/frontends/aiger2/xaiger.cc @@ -198,11 +198,10 @@ struct Xaiger2Frontend : public Frontend { int ci_counter = 0; for (uint32_t i = 0; i < no_boxes; i++) { - uint32_t box_inputs, box_outputs, box_id, box_seq; - box_inputs = read_be32(*f); - box_outputs = read_be32(*f); - box_id = read_be32(*f); - box_seq = read_be32(*f); + /* unused box_inputs = */ read_be32(*f); + YS_MAYBE_UNUSED auto box_outputs = read_be32(*f); + /* unused box_id = */ read_be32(*f); + auto box_seq = read_be32(*f); log("box_seq=%d boxes.size=%d\n", box_seq, (int) boxes.size()); log_assert(box_seq < boxes.size()); @@ -337,11 +336,10 @@ struct Xaiger2Frontend : public Frontend { len, ci_num, co_num, pi_num, po_num, no_boxes); for (uint32_t i = 0; i < no_boxes; i++) { - uint32_t box_inputs, box_outputs, box_id, box_seq; - box_inputs = read_be32(*f); - box_outputs = read_be32(*f); - box_id = read_be32(*f); - box_seq = read_be32(*f); + YS_MAYBE_UNUSED auto box_inputs = read_be32(*f); + /* unused box_outputs = */ read_be32(*f); + /* unused box_id = */ read_be32(*f); + auto box_seq = read_be32(*f); log("box_seq=%d boxes.size=%d\n", box_seq, (int) boxes.size()); log_assert(box_seq < boxes.size());