Nested generate regions are illegal

This commit is contained in:
Cary R 2024-12-28 18:29:06 -08:00
parent d484cb63d6
commit 788a94b310
4 changed files with 38 additions and 9 deletions

View File

@ -0,0 +1 @@
./ivltests/br_gh1117.v:10: error: generate/endgenerate regions cannot nest.

View File

@ -0,0 +1,25 @@
module top;
wire x, y, z;
reg in;
genvar i;
generate
for (i=0; i<1; i=i+1) begin
assign x = in;
end
generate // This should be an error
for (i=0; i<1; i=i+1) begin
assign y = in;
end
endgenerate
endgenerate
generate // This is ok
for (i=0; i<1; i=i+1) begin
assign z = in;
end
endgenerate
initial $display("Failed: should be a compile error!");
endmodule

View File

@ -353,6 +353,7 @@ br_gh788 normal,-gno-io-range-error,-Wno-anachronisms ivltests gold=br_gh788.go
br_gh793 normal ivltests
br_gh827 normal ivltests gold=br_gh827.gold
br_gh889 normal,-gspecify ivltests gold=br_gh889.gold
br_gh1117 CE ivltests gold=br_gh1117.gold
br_gh1175a CE ivltests gold=br_gh1175a.gold
br_gh1175b CE ivltests gold=br_gh1175b.gold
br_gh1175c CE ivltests gold=br_gh1175c.gold

20
parse.y
View File

@ -45,6 +45,7 @@ extern void lex_end_table();
static data_type_t* param_data_type = 0;
static bool param_is_local = false;
static bool param_is_type = false;
static bool in_gen_region = false;
static std::list<pform_range_t>* specparam_active_range = 0;
/* Port declaration lists use this structure for context. */
@ -74,6 +75,15 @@ static stack<PBlock*> current_block_stack;
specified. */
static LexicalScope::lifetime_t var_lifetime;
static void check_in_gen_region(const struct vlltype &loc)
{
if (in_gen_region) {
cerr << loc << ": error: generate/endgenerate regions cannot nest." << endl;
error_count += 1;
}
in_gen_region = true;
}
static pform_name_t* pform_create_this(void)
{
name_component_t name (perm_string::literal(THIS_TOKEN));
@ -5208,15 +5218,7 @@ module_item
generate/endgenerate regions do not nest. Generate schemes nest,
but generate regions do not. */
| K_generate generate_item_list_opt K_endgenerate
{ // Test for bad nesting. I understand it, but it is illegal.
if (pform_parent_generate()) {
cerr << @1 << ": error: Generate/endgenerate regions cannot nest." << endl;
cerr << @1 << ": : Try removing optional generate/endgenerate keywords," << endl;
cerr << @1 << ": : or move them to surround the parent generate scheme." << endl;
error_count += 1;
}
}
| K_generate { check_in_gen_region(@1); } generate_item_list_opt K_endgenerate { in_gen_region = false; }
| K_genvar list_of_identifiers ';'
{ pform_genvars(@1, $2); }