Skip to content

Commit

Permalink
Report each line that has a var decl in an unnamed block
Browse files Browse the repository at this point in the history
  • Loading branch information
caryr committed Dec 29, 2024
1 parent 788a94b commit 03835c9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ivtest/gold/br_gh1182.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
./ivltests/br_gh1182.v:3: error: Variable declaration in unnamed block requires SystemVerilog.
./ivltests/br_gh1182.v:4: error: Variable declaration in unnamed block requires SystemVerilog.
./ivltests/br_gh1182.v:8: error: Variable declaration in unnamed block requires SystemVerilog.
11 changes: 11 additions & 0 deletions ivtest/ivltests/br_gh1182.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module top;
initial begin
logic [7:0] data;
logic [3:0] tmp;
end

initial begin
logic [3:0] nib;
$display("PASSED");
end
endmodule
1 change: 1 addition & 0 deletions ivtest/regress-fsv.list
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ br1027e normal ivltests gold=br1027e-fsv.gold
br_gh25a normal ivltests
br_gh25b normal ivltests
br_gh567 normal ivltests
br_gh1182 normal ivltests
check_constant_3 normal ivltests
function4 normal ivltests
module_inout_port_type normal ivltests
Expand Down
1 change: 1 addition & 0 deletions ivtest/regress-vlg.list
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ br_gh1175f CE ivltests gold=br_gh1175f.gold
br_gh1178a CE ivltests gold=br_gh1178a.gold
br_gh1178b normal ivltests
br_gh1178c normal ivltests
br_gh1182 CE ivltests gold=br_gh1182.gold
br_ml20150315 normal ivltests gold=br_ml_20150315.gold
br_ml20150321 CE ivltests
br_mw20171108 normal ivltests
Expand Down
2 changes: 1 addition & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -6708,7 +6708,7 @@ statement_item /* This is roughly statement_item in the LRM */
{
if (!$2) {
if ($4) {
pform_requires_sv(@4, "Variable declaration in unnamed block");
pform_block_decls_requires_sv();
} else {
/* If there are no declarations in the scope then just delete it. */
pform_pop_scope();
Expand Down
10 changes: 10 additions & 0 deletions pform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3364,6 +3364,16 @@ bool pform_requires_sv(const struct vlltype&loc, const char *feature)
return false;
}

void pform_block_decls_requires_sv(void)
{
for (auto const& wire : lexical_scope->wires) {
struct vlltype loc;
loc.text = wire.second->get_file();
loc.first_line = wire.second->get_lineno();
pform_requires_sv(loc, "Variable declaration in unnamed block");
}
}

void pform_check_net_data_type(const struct vlltype&loc, NetNet::Type net_type,
const data_type_t *data_type)
{
Expand Down
1 change: 1 addition & 0 deletions pform.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ extern bool allow_timeprec_decl;
void pform_put_enum_type_in_scope(enum_type_t*enum_set);

bool pform_requires_sv(const struct vlltype&loc, const char *feature);
void pform_block_decls_requires_sv(void);

void pform_start_parameter_port_list();
void pform_end_parameter_port_list();
Expand Down

0 comments on commit 03835c9

Please sign in to comment.