Skip to content

Commit c96d02b

Browse files
Merge pull request #4784 from YosysHQ/krys/reduce_warnings
Reduce number of warnings
2 parents d780864 + e634e9c commit c96d02b

File tree

11 files changed

+69
-74
lines changed

11 files changed

+69
-74
lines changed

backends/aiger2/aiger.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ struct Index {
262262
if (cell->type.in(ID($gt), ID($ge)))
263263
std::swap(aport, bport);
264264
int carry = cell->type.in(ID($le), ID($ge)) ? CFALSE : CTRUE;
265-
Lit a, b;
265+
Lit a = Writer::EMPTY_LIT;
266+
Lit b = Writer::EMPTY_LIT;
266267
// TODO: this might not be the most economic structure; revisit at a later date
267268
for (int i = 0; i < width; i++) {
268269
a = visit(cursor, aport[i]);
@@ -664,8 +665,6 @@ struct Index {
664665
struct AigerWriter : Index<AigerWriter, unsigned int, 0, 1> {
665666
typedef unsigned int Lit;
666667

667-
const static Lit CONST_FALSE = 0;
668-
const static Lit CONST_TRUE = 1;
669668
const static constexpr Lit EMPTY_LIT = std::numeric_limits<Lit>::max();
670669

671670
static Lit negate(Lit lit) {
@@ -802,8 +801,6 @@ struct AigerWriter : Index<AigerWriter, unsigned int, 0, 1> {
802801
};
803802

804803
struct XAigerAnalysis : Index<XAigerAnalysis, int, 0, 0> {
805-
const static int CONST_FALSE = 0;
806-
const static int CONST_TRUE = 0;
807804
const static constexpr int EMPTY_LIT = -1;
808805

809806
XAigerAnalysis()

backends/edif/edif.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ struct EdifBackend : public Backend {
338338
*f << stringf("\n (property %s (integer %u))", EDIF_DEF(name), val.as_int());
339339
else {
340340
std::string hex_string = "";
341-
for (size_t i = 0; i < val.size(); i += 4) {
341+
for (auto i = 0; i < val.size(); i += 4) {
342342
int digit_value = 0;
343343
if (i+0 < val.size() && val.at(i+0) == RTLIL::State::S1) digit_value |= 1;
344344
if (i+1 < val.size() && val.at(i+1) == RTLIL::State::S1) digit_value |= 2;

frontends/aiger2/xaiger.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,10 @@ struct Xaiger2Frontend : public Frontend {
198198

199199
int ci_counter = 0;
200200
for (uint32_t i = 0; i < no_boxes; i++) {
201-
uint32_t box_inputs, box_outputs, box_id, box_seq;
202-
box_inputs = read_be32(*f);
203-
box_outputs = read_be32(*f);
204-
box_id = read_be32(*f);
205-
box_seq = read_be32(*f);
201+
/* unused box_inputs = */ read_be32(*f);
202+
YS_MAYBE_UNUSED auto box_outputs = read_be32(*f);
203+
/* unused box_id = */ read_be32(*f);
204+
auto box_seq = read_be32(*f);
206205

207206
log("box_seq=%d boxes.size=%d\n", box_seq, (int) boxes.size());
208207
log_assert(box_seq < boxes.size());
@@ -337,11 +336,10 @@ struct Xaiger2Frontend : public Frontend {
337336
len, ci_num, co_num, pi_num, po_num, no_boxes);
338337

339338
for (uint32_t i = 0; i < no_boxes; i++) {
340-
uint32_t box_inputs, box_outputs, box_id, box_seq;
341-
box_inputs = read_be32(*f);
342-
box_outputs = read_be32(*f);
343-
box_id = read_be32(*f);
344-
box_seq = read_be32(*f);
339+
YS_MAYBE_UNUSED auto box_inputs = read_be32(*f);
340+
/* unused box_outputs = */ read_be32(*f);
341+
/* unused box_id = */ read_be32(*f);
342+
auto box_seq = read_be32(*f);
345343

346344
log("box_seq=%d boxes.size=%d\n", box_seq, (int) boxes.size());
347345
log_assert(box_seq < boxes.size());

frontends/ast/ast.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,21 +931,21 @@ bool AstNode::bits_only_01() const
931931
RTLIL::Const AstNode::bitsAsUnsizedConst(int width)
932932
{
933933
RTLIL::State extbit = bits.back();
934-
while (width > int(bits.size()))
934+
while (width > GetSize(bits))
935935
bits.push_back(extbit);
936936
return RTLIL::Const(bits);
937937
}
938938

939939
RTLIL::Const AstNode::bitsAsConst(int width, bool is_signed)
940940
{
941941
std::vector<RTLIL::State> bits = this->bits;
942-
if (width >= 0 && width < int(bits.size()))
942+
if (width >= 0 && width < GetSize(bits))
943943
bits.resize(width);
944-
if (width >= 0 && width > int(bits.size())) {
944+
if (width >= 0 && width > GetSize(bits)) {
945945
RTLIL::State extbit = RTLIL::State::S0;
946946
if ((is_signed || is_unsized) && !bits.empty())
947947
extbit = bits.back();
948-
while (width > int(bits.size()))
948+
while (width > GetSize(bits))
949949
bits.push_back(extbit);
950950
}
951951
return RTLIL::Const(bits);
@@ -1029,7 +1029,7 @@ double AstNode::asReal(bool is_signed)
10291029
val = const_neg(val, val, false, false, val.size());
10301030

10311031
double v = 0;
1032-
for (size_t i = 0; i < val.size(); i++)
1032+
for (auto i = 0; i < val.size(); i++)
10331033
// IEEE Std 1800-2012 Par 6.12.2: Individual bits that are x or z in
10341034
// the net or the variable shall be treated as zero upon conversion.
10351035
if (val.at(i) == RTLIL::State::S1)

frontends/ast/genrtlil.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
984984
// unallocated enum, ignore
985985
break;
986986
case AST_CONSTANT:
987-
width_hint = max(width_hint, int(bits.size()));
987+
width_hint = max(width_hint, GetSize(bits));
988988
if (!is_signed)
989989
sign_hint = false;
990990
break;

frontends/ast/simplify.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,7 +3493,7 @@ skip_dynamic_range_lvalue_expansion:;
34933493
delete buf;
34943494

34953495
uint32_t result = 0;
3496-
for (size_t i = 0; i < arg_value.size(); i++)
3496+
for (auto i = 0; i < arg_value.size(); i++)
34973497
if (arg_value.at(i) == RTLIL::State::S1)
34983498
result = i + 1;
34993499

@@ -4339,7 +4339,7 @@ replace_fcall_later:;
43394339
RTLIL::Const a = children[1]->bitsAsConst(width_hint, sign_hint);
43404340
RTLIL::Const b = children[2]->bitsAsConst(width_hint, sign_hint);
43414341
log_assert(a.size() == b.size());
4342-
for (size_t i = 0; i < a.size(); i++)
4342+
for (auto i = 0; i < a.size(); i++)
43434343
if (a[i] != b[i])
43444344
a.bits()[i] = RTLIL::State::Sx;
43454345
newNode = mkconst_bits(a.to_bits(), sign_hint);

0 commit comments

Comments
 (0)