Fix parsing of eventually[] and pexpr memory leaks (#6530)

* Fix parsing of eventually[]
* Fix parser memory leaks for pexpr

Signed-off-by: Bartłomiej Chmiel <[email protected]>
This commit is contained in:
Bartłomiej Chmiel
2025-10-06 15:42:40 +02:00
committed by GitHub
parent 0280de11da
commit 9f5d22b21f
9 changed files with 352 additions and 85 deletions
+29 -29
View File
@@ -6334,9 +6334,9 @@ property_port_itemDirE:
property_declarationBody<nodep>: // IEEE: part of property_declaration
assertion_variable_declarationList property_spec
{ $$ = nullptr; BBUNSUP($1->fileline(), "Unsupported: property variable declaration"); DEL($1); }
{ $$ = nullptr; BBUNSUP($1->fileline(), "Unsupported: property variable declaration"); DEL($1, $2); }
| assertion_variable_declarationList property_spec ';'
{ $$ = nullptr; BBUNSUP($1->fileline(), "Unsupported: property variable declaration"); DEL($1); }
{ $$ = nullptr; BBUNSUP($1->fileline(), "Unsupported: property variable declaration"); DEL($1, $2); }
// // IEEE-2012: Incorrectly has yCOVER ySEQUENCE then property_spec here.
// // Fixed in IEEE 1800-2017
| property_spec { $$ = $1; }
@@ -6445,14 +6445,16 @@ property_spec<propSpecp>: // IEEE: property_spec
property_statementCaseIf<nodeExprp>: // IEEE: property_statement - minus pexpr
yCASE '(' expr/*expression_or_dist*/ ')' property_case_itemList yENDCASE
{ $$ = new AstConst{$1, AstConst::BitFalse{}};
BBUNSUP($<fl>1, "Unsupported: property case expression"); }
BBUNSUP($<fl>1, "Unsupported: property case expression");
DEL($3, $5); }
| yCASE '(' expr/*expression_or_dist*/ ')' yENDCASE
{ $$ = new AstConst{$1, AstConst::BitFalse{}};
BBUNSUP($<fl>1, "Unsupported: property case expression"); }
BBUNSUP($<fl>1, "Unsupported: property case expression");
DEL($3); }
| yIF '(' expr/*expression_or_dist*/ ')' pexpr %prec prLOWER_THAN_ELSE
{ $$ = $5; BBUNSUP($<fl>1, "Unsupported: property case expression"); }
{ $$ = $5; BBUNSUP($<fl>1, "Unsupported: property case expression"); DEL($3); }
| yIF '(' expr/*expression_or_dist*/ ')' pexpr yELSE pexpr
{ $$ = $5; BBUNSUP($<fl>1, "Unsupported: property case expression"); }
{ $$ = $5; BBUNSUP($<fl>1, "Unsupported: property case expression"); DEL($3, $7); }
;
property_case_itemList<caseItemp>: // IEEE: {property_case_item}
@@ -6523,9 +6525,9 @@ pexpr<nodeExprp>: // IEEE: property_expr (The name pexpr is important as regex
| property_statementCaseIf { $$ = $1; }
//
| ~o~pexpr/*sexpr*/ yP_POUNDMINUSPD pexpr
{ $$ = $3; BBUNSUP($2, "Unsupported: #-# (in property expression)"); }
{ $$ = $1; BBUNSUP($2, "Unsupported: #-# (in property expression)"); DEL($3); }
| ~o~pexpr/*sexpr*/ yP_POUNDEQPD pexpr
{ $$ = $3; BBUNSUP($2, "Unsupported: #=# (in property expression)"); }
{ $$ = $1; BBUNSUP($2, "Unsupported: #=# (in property expression)"); DEL($3); }
| yNEXTTIME pexpr
{ $$ = $2; BBUNSUP($1, "Unsupported: nexttime (in property expression)"); }
| yS_NEXTTIME pexpr
@@ -6540,22 +6542,20 @@ pexpr<nodeExprp>: // IEEE: property_expr (The name pexpr is important as regex
{ $$ = $3; BBUNSUP($1, "Unsupported: always[] (in property expression)"); DEL($2); }
| yS_ALWAYS anyrange pexpr %prec yS_ALWAYS
{ $$ = $3; BBUNSUP($1, "Unsupported: s_always (in property expression)"); DEL($2); }
| yEVENTUALLY pexpr
{ $$ = $2; BBUNSUP($1, "Unsupported: eventually (in property expression)"); }
| yS_EVENTUALLY pexpr
{ $$ = $2; BBUNSUP($1, "Unsupported: s_eventually (in property expression)"); }
| yEVENTUALLY '[' constExpr ']' pexpr %prec yEVENTUALLY
{ $$ = $5; BBUNSUP($1, "Unsupported: eventually[] (in property expression)"); DEL($3); }
| yS_EVENTUALLY anyrange pexpr %prec yS_EVENTUALLY
{ $$ = $3; BBUNSUP($1, "Unsupported: s_eventually[] (in property expression)"); DEL($2); }
| yEVENTUALLY anyrange pexpr %prec yS_EVENTUALLY
{ $$ = $3; BBUNSUP($1, "Unsupported: eventually[] (in property expression)"); DEL($2); }
| ~o~pexpr yUNTIL pexpr
{ $$ = $1; BBUNSUP($2, "Unsupported: until (in property expression)"); }
{ $$ = $1; BBUNSUP($2, "Unsupported: until (in property expression)"); DEL($3); }
| ~o~pexpr yS_UNTIL pexpr
{ $$ = $1; BBUNSUP($2, "Unsupported: s_until (in property expression)"); }
{ $$ = $1; BBUNSUP($2, "Unsupported: s_until (in property expression)"); DEL($3); }
| ~o~pexpr yUNTIL_WITH pexpr
{ $$ = $1; BBUNSUP($2, "Unsupported: until_with (in property expression)"); }
{ $$ = $1; BBUNSUP($2, "Unsupported: until_with (in property expression)"); DEL($3); }
| ~o~pexpr yS_UNTIL_WITH pexpr
{ $$ = $1; BBUNSUP($2, "Unsupported: s_until_with (in property expression)"); }
{ $$ = $1; BBUNSUP($2, "Unsupported: s_until_with (in property expression)"); DEL($3); }
| ~o~pexpr yIMPLIES pexpr
{ $$ = new AstLogOr{$2, new AstLogNot{$2, $1}, $3}; }
// // yIFF also used by event_expression
@@ -6594,15 +6594,15 @@ sexpr<nodeExprp>: // ==IEEE: sequence_expr (The name sexpr is important as reg
// // IEEE: "sequence_expr cycle_delay_range sequence_expr { cycle_delay_range sequence_expr }"
// // Both rules basically mean we can repeat sequences, so make it simpler:
cycle_delay_range ~p~sexpr %prec yP_POUNDPOUND
{ $$ = $2; BBUNSUP($2->fileline(), "Unsupported: ## (in sequence expression)"); }
{ $$ = $2; BBUNSUP($2->fileline(), "Unsupported: ## (in sequence expression)"); DEL($1); }
| ~p~sexpr cycle_delay_range sexpr %prec prPOUNDPOUND_MULTI
{ $$ = $1; BBUNSUP($2->fileline(), "Unsupported: ## (in sequence expression)"); }
{ $$ = $1; BBUNSUP($2->fileline(), "Unsupported: ## (in sequence expression)"); DEL($2, $3); }
//
// // IEEE: expression_or_dist [ boolean_abbrev ]
// // Note expression_or_dist includes "expr"!
// // sexpr/*sexpression_or_dist*/ --- Hardcoded below
| ~p~sexpr/*sexpression_or_dist*/ boolean_abbrev
{ $$ = $1; BBUNSUP($2->fileline(), "Unsupported: boolean abbrev (in sequence expression)"); }
{ $$ = $1; BBUNSUP($2->fileline(), "Unsupported: boolean abbrev (in sequence expression)"); DEL($2); }
//
// // IEEE: "sequence_instance [ sequence_abbrev ]"
// // version without sequence_abbrev looks just like normal function call
@@ -6616,7 +6616,7 @@ sexpr<nodeExprp>: // ==IEEE: sequence_expr (The name sexpr is important as reg
// // "'(' sexpr ')' boolean_abbrev" matches "[sexpr:'(' expr ')'] boolean_abbrev" so we can drop it
| '(' ~p~sexpr ')' { $$ = $2; }
| '(' ~p~sexpr ',' sequence_match_itemList ')'
{ $$ = $2; BBUNSUP($3, "Unsupported sequence match items"); }
{ $$ = $2; BBUNSUP($3, "Unsupported sequence match items"); DEL($4); }
//
// // AND/OR are between pexprs OR sexprs
| ~p~sexpr yAND ~p~sexpr
@@ -6627,18 +6627,18 @@ sexpr<nodeExprp>: // ==IEEE: sequence_expr (The name sexpr is important as reg
BBUNSUP($2, "Unsupported: or (in sequence expression)"); }
// // Intersect always has an sexpr rhs
| ~p~sexpr yINTERSECT sexpr
{ $$ = $1; BBUNSUP($2, "Unsupported: intersect (in sequence expression)"); }
{ $$ = $1; BBUNSUP($2, "Unsupported: intersect (in sequence expression)"); DEL($3); }
//
| yFIRST_MATCH '(' sexpr ')'
{ $$ = nullptr; BBUNSUP($1, "Unsupported: first_match (in sequence expression)"); DEL($3); }
{ $$ = $3; BBUNSUP($1, "Unsupported: first_match (in sequence expression)"); }
| yFIRST_MATCH '(' sexpr ',' sequence_match_itemList ')'
{ $$ = nullptr; BBUNSUP($1, "Unsupported: first_match (in sequence expression)"); DEL($3, $5); }
{ $$ = $3; BBUNSUP($1, "Unsupported: first_match (in sequence expression)"); DEL($5); }
| ~p~sexpr/*sexpression_or_dist*/ yTHROUGHOUT sexpr
{ $$ = $1; BBUNSUP($2, "Unsupported: throughout (in sequence expression)"); }
{ $$ = $1; BBUNSUP($2, "Unsupported: throughout (in sequence expression)"); DEL($3); }
// // Below pexpr's are really sequence_expr, but avoid conflict
// // IEEE: sexpr yWITHIN sexpr
| ~p~sexpr yWITHIN sexpr
{ $$ = $1; BBUNSUP($2, "Unsupported: within (in sequence expression)"); }
{ $$ = $1; BBUNSUP($2, "Unsupported: within (in sequence expression)"); DEL($3); }
// // Note concurrent_assertion had duplicate rule for below
//UNSUP clocking_event ~p~sexpr %prec prSEQ_CLOCKING { }
//
@@ -6664,7 +6664,7 @@ cycle_delay_range<nodep>: // IEEE: ==cycle_delay_range
// // the sv-ac committee has been asked to clarify (Mantis 1901)
| yP_POUNDPOUND anyrange
{ $$ = new AstConst{$1, AstConst::BitFalse{}};
BBUNSUP($<fl>1, "Unsupported: ## range cycle delay range expression"); }
BBUNSUP($<fl>1, "Unsupported: ## range cycle delay range expression"); DEL($2); }
| yP_POUNDPOUND yP_BRASTAR ']'
{ $$ = new AstConst{$1, AstConst::BitFalse{}};
BBUNSUP($<fl>1, "Unsupported: ## [*] cycle delay range expression"); }
@@ -6691,7 +6691,7 @@ boolean_abbrev<nodeExprp>: // ==IEEE: boolean_abbrev
yP_BRASTAR constExpr ']'
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [*] boolean abbrev expression"); }
| yP_BRASTAR constExpr ':' constExpr ']'
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [*] boolean abbrev expression"); }
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [*] boolean abbrev expression"); DEL($4); }
| yP_BRASTAR ']'
{ $$ = new AstConst{$1, AstConst::BitFalse{}};
BBUNSUP($<fl>1, "Unsupported: [*] boolean abbrev expression"); }
@@ -6702,12 +6702,12 @@ boolean_abbrev<nodeExprp>: // ==IEEE: boolean_abbrev
| yP_BRAEQ constExpr ']'
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [= boolean abbrev expression"); }
| yP_BRAEQ constExpr ':' constExpr ']'
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [= boolean abbrev expression"); }
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [= boolean abbrev expression"); DEL($4); }
// // IEEE: goto_repetition
| yP_BRAMINUSGT constExpr ']'
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [-> boolean abbrev expression"); }
| yP_BRAMINUSGT constExpr ':' constExpr ']'
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [-> boolean abbrev expression"); }
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [-> boolean abbrev expression"); DEL($4); }
;
//************************************************