Skip to content

Commit 5c8b0bc

Browse files
committed
Fix empty foreach in constraints
Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
1 parent 491f972 commit 5c8b0bc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/V3Randomize.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,13 @@ class ConstraintExprVisitor final : public VNVisitor {
695695
AstNode* const cstmtp = new AstText{fl, "ret += \" \" + "};
696696
cstmtp->addNext(itemp);
697697
cstmtp->addNext(new AstText{fl, ";"});
698-
AstNode* const exprsp = new AstText{fl, "([&]{ std::string ret = \"(bvand\";"};
698+
AstNode* const exprsp = new AstText{fl, "([&]{ std::string ret;"};
699699
exprsp->addNext(new AstBegin{
700700
fl, "",
701701
new AstForeach{fl, nodep->arrayp()->unlinkFrBack(), new AstCStmt{fl, cstmtp}},
702702
false, true});
703+
exprsp->addNext(
704+
new AstText{fl, "return ret.empty() ? \"#b1\" : \"(bvand \" + ret + \")\";"});
703705
exprsp->addNext(new AstText{fl, "return ret + \")\"; })()"});
704706
AstNodeExpr* const newp = new AstCExpr{fl, exprsp};
705707
newp->dtypeSetString();

0 commit comments

Comments
 (0)