Merge pull request #982 from larsclausen/const-var-fix

Make sure `const var` variables are constant
This commit is contained in:
Cary R 2023-08-05 18:27:34 -07:00 committed by GitHub
commit 0651e0be17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,13 @@
// Check that blocking assignment to a const variable fails, when the variable is
// declared with the `var` keyword.
module test;
const var integer x = 10;
initial begin
x = 20; // Error: Assignment to const variable
$display("FAILED");
end
endmodule

View File

@ -74,6 +74,7 @@ sv_const_fail5 vvp_tests/sv_const_fail5.json
sv_const_fail6 vvp_tests/sv_const_fail6.json
sv_const_fail7 vvp_tests/sv_const_fail7.json
sv_const_fail8 vvp_tests/sv_const_fail8.json
sv_const_fail9 vvp_tests/sv_const_fail9.json
sv_foreach9 vvp_tests/sv_foreach9.json
sv_foreach10 vvp_tests/sv_foreach10.json
sv_module_port1 vvp_tests/sv_module_port1.json

View File

@ -0,0 +1,5 @@
{
"type" : "CE",
"source" : "sv_const_fail9.v",
"iverilog-args" : [ "-g2005-sv" ]
}

View File

@ -2738,7 +2738,7 @@ block_item_decl
data_type = new vector_type_t(IVL_VT_LOGIC, false, 0);
FILE_NAME(data_type, @2);
}
pform_make_var(@2, $5, data_type, attributes_in_context);
pform_make_var(@2, $5, data_type, attributes_in_context, $1);
var_lifetime = LexicalScope::INHERITED;
}