Add regression tests for enum named constant reference order
Check that a reference before an inner enum declaration resolves to a matching enum named constant in the outer scope, while a reference after the declaration resolves to the inner constant. Also check that `-gno-strict-parameter-declaration` continues to allow a reference to a later enum named constant and identifies it correctly in the declaration-after-use warning. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
f6f7f9d6d7
commit
8e420f56ff
|
|
@ -0,0 +1,2 @@
|
|||
ivltests/sv_enum_reference_order_relaxed.v:7: warning: enum named constant `VALUE` used before declaration.
|
||||
ivltests/sv_enum_reference_order_relaxed.v:10: : the enum named constant is declared here.
|
||||
|
|
@ -0,0 +1 @@
|
|||
PASSED
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Check that enum named constants only affect following references.
|
||||
|
||||
typedef enum logic [1:0] {
|
||||
VALUE = 1
|
||||
} outer_t;
|
||||
|
||||
module test;
|
||||
|
||||
localparam value_before = VALUE;
|
||||
|
||||
typedef enum logic [1:0] {
|
||||
VALUE = 2
|
||||
} inner_t;
|
||||
|
||||
localparam value_after = VALUE;
|
||||
|
||||
reg failed;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \
|
||||
`"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
initial begin
|
||||
failed = 1'b0;
|
||||
|
||||
`check(value_before, 2'd1);
|
||||
`check(value_after, 2'd2);
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// Check relaxed declaration ordering for enum named constants.
|
||||
// This is not valid in strict SystemVerilog and tests
|
||||
// -gno-strict-parameter-declaration.
|
||||
|
||||
module test;
|
||||
|
||||
localparam value_before = VALUE;
|
||||
|
||||
typedef enum logic [1:0] {
|
||||
VALUE = 2
|
||||
} value_t;
|
||||
|
||||
reg failed;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \
|
||||
`"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
initial begin
|
||||
failed = 1'b0;
|
||||
|
||||
`check(value_before, 2'd2);
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -331,6 +331,8 @@ sv_declaration_after_null_statement_fail vvp_tests/sv_declaration_after_null_sta
|
|||
sv_default_port_value1 vvp_tests/sv_default_port_value1.json
|
||||
sv_default_port_value2 vvp_tests/sv_default_port_value2.json
|
||||
sv_default_port_value3 vvp_tests/sv_default_port_value3.json
|
||||
sv_enum_reference_order vvp_tests/sv_enum_reference_order.json
|
||||
sv_enum_reference_order_relaxed vvp_tests/sv_enum_reference_order_relaxed.json
|
||||
sv_foreach9 vvp_tests/sv_foreach9.json
|
||||
sv_foreach10 vvp_tests/sv_foreach10.json
|
||||
sv_fork_prefix_label vvp_tests/sv_fork_prefix_label.json
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_enum_reference_order.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_enum_reference_order_relaxed.v",
|
||||
"iverilog-args" : [ "-g2005-sv", "-gno-strict-parameter-declaration" ],
|
||||
"gold" : "sv_enum_reference_order_relaxed"
|
||||
}
|
||||
Loading…
Reference in New Issue