fixed a bug in the constant merger

This commit is contained in:
hneemann 2018-03-26 00:25:45 +02:00
parent b910dc94e0
commit 5179b720ae

View File

@ -39,6 +39,8 @@ public class MergeConstants {
final HDLNode node1 = nodes.get(n1); final HDLNode node1 = nodes.get(n1);
ExprConstant con1 = getConstant(node1); ExprConstant con1 = getConstant(node1);
if (con1 != null) { if (con1 != null) {
//modification of loop variable n2 is intended!
//CHECKSTYLE.OFF: ModifiedControlVariable
for (int n2 = n1 + 1; n2 < nodes.size(); n2++) { for (int n2 = n1 + 1; n2 < nodes.size(); n2++) {
final HDLNode node2 = nodes.get(n2); final HDLNode node2 = nodes.get(n2);
ExprConstant con2 = getConstant(node2); ExprConstant con2 = getConstant(node2);
@ -46,9 +48,11 @@ public class MergeConstants {
if (con1.isEqualTo(con2)) { if (con1.isEqualTo(con2)) {
merge(node1, node2); merge(node1, node2);
nodes.remove(n2); nodes.remove(n2);
n2--;
} }
} }
} }
//CHECKSTYLE.ON: ModifiedControlVariable
} }
n1++; n1++;