Skip to content

Commit

Permalink
Fix over-permissive parsing of UDPs without identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
wsnyder committed Sep 24, 2024
1 parent 5a65d27 commit 4ec75b2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/V3ParseImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,8 @@ int V3ParseImp::tokenToBison() {
m_bisonLastFileline = yylval.fl;

// yylval.scp = nullptr; // Symbol table not yet needed - no packages
if (debugFlex() >= 6 || debugBison() >= 6) { // --debugi-flex and --debugi-bison
if (debug() >= 6 || debugFlex() >= 6
|| debugBison() >= 6) { // --debugi-flex and --debugi-bison
cout << "tokenToBison " << yylval << endl;
}
return yylval.token;
Expand Down
20 changes: 14 additions & 6 deletions src/verilog.y
Original file line number Diff line number Diff line change
Expand Up @@ -3242,7 +3242,9 @@ instDecl<nodep>:
// // Currently disambiguated from data_declaration based on
// // VARs being type, and cells non-type.
// // IEEE requires a '(' to disambiguate, we need TODO force this
id parameter_value_assignmentE {INSTPREP($<fl>1, *$1, $2);} instnameList ';'
id parameter_value_assignmentE
/*mid*/ { INSTPREP($<fl>1, *$1, $2); }
/*cont*/ instnameList ';'
{ $$ = $4;
GRAMMARP->m_impliedDecl = false;
if (GRAMMARP->m_instParamp) {
Expand All @@ -3257,6 +3259,12 @@ instDecl<nodep>:
/*cont*/ mpInstnameList ';'
{ $$ = VARDONEP($5, nullptr, nullptr); }
//UNSUP: strengthSpecE for udp_instantiations
// // IEEE: part of udp_instance when no name_of_instance
// // Note no unpacked dimension nor list of instances
| id
/*mid*/ { INSTPREP($<fl>1, *$1, nullptr); }
/*cont*/ instnameParenUdpn ';'
{ $$ = $3; GRAMMARP->m_impliedDecl = false; }
;

mpInstnameList<nodep>: // Similar to instnameList, but for modport instantiations which have no parenthesis
Expand All @@ -3278,7 +3286,10 @@ instnameParen<nodep>:
{ $$ = GRAMMARP->createCellOrIfaceRef($<fl>1, *$1, $4, $2, true); }
| id instRangeListE
{ $$ = GRAMMARP->createCellOrIfaceRef($<fl>1, *$1, nullptr, $2, false); }
| '(' cellpinListE ')' // When UDP has empty name, unpacked dimensions must not be used
;

instnameParenUdpn<nodep>: // IEEE: part of udp_instance when no name_of_instance
'(' cellpinListE ')' // When UDP has empty name, unpacked dimensions must not be used
{ $$ = GRAMMARP->createCellOrIfaceRef($<fl>1, "", $2, nullptr, true); }
;

Expand Down Expand Up @@ -4607,7 +4618,7 @@ taskId<nodeFTaskp>:
SYMP->pushNewUnderNodeOrCurrent($$, $<scp>1); }
;

funcId<nodeFTaskp>: // IEEE: function_data_type_or_implicit + part of function_body_declaration
funcId<nodeFTaskp>: // IEEE: function_data_type_or_implicit + part of function_body_declaration
// // IEEE: function_data_type_or_implicit must be expanded here to prevent conflict
// // function_data_type expanded here to prevent conflicts with
// // implicit_type:empty vs data_type:ID
Expand Down Expand Up @@ -6552,9 +6563,6 @@ boolean_abbrev<nodeExprp>: // ==IEEE: boolean_abbrev
{ $$ = $2; BBUNSUP($<fl>1, "Unsupported: [-> boolean abbrev expression"); }
;

//************************************************
// Let

//************************************************
// Covergroup

Expand Down
2 changes: 1 addition & 1 deletion test_regress/t/t_preproc_inc_bad.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%Error: t/t_preproc_inc_inc_bad.vh:11:1: syntax error, unexpected endmodule, expecting IDENTIFIER or '(' or randomize
%Error: t/t_preproc_inc_inc_bad.vh:11:1: syntax error, unexpected endmodule, expecting IDENTIFIER or randomize
11 | endmodule
| ^~~~~~~~~
t/t_preproc_inc_bad.v:10:1: ... note: In file included from 't_preproc_inc_bad.v'
Expand Down
2 changes: 1 addition & 1 deletion test_regress/t/t_vams_kwd_bad.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
12 | int above;
| ^~~~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error: t/t_vams_kwd_bad.v:12:13: syntax error, unexpected ';', expecting IDENTIFIER or '(' or randomize
%Error: t/t_vams_kwd_bad.v:12:13: syntax error, unexpected ';', expecting IDENTIFIER or randomize
12 | int above;
| ^
%Error-UNSUPPORTED: t/t_vams_kwd_bad.v:13:8: Unsupported: AMS reserved word not implemented: 'abs'
Expand Down

0 comments on commit 4ec75b2

Please sign in to comment.