From 109b794253eecf9d270d875662835ac5cb72d9a3 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 26 Dec 2022 11:37:44 -0800 Subject: [PATCH] Add regression tests for comments in macros Add regression tests for some corner cases for handling comments in macros. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/macro_comment1.v | 16 ++++++++++++++++ ivtest/ivltests/macro_comment2.v | 17 +++++++++++++++++ ivtest/ivltests/macro_comment3.v | 16 ++++++++++++++++ ivtest/regress-vlg.list | 3 +++ 4 files changed, 52 insertions(+) create mode 100644 ivtest/ivltests/macro_comment1.v create mode 100644 ivtest/ivltests/macro_comment2.v create mode 100644 ivtest/ivltests/macro_comment3.v diff --git a/ivtest/ivltests/macro_comment1.v b/ivtest/ivltests/macro_comment1.v new file mode 100644 index 000000000..c1004fb61 --- /dev/null +++ b/ivtest/ivltests/macro_comment1.v @@ -0,0 +1,16 @@ +// Check that a '*' or '/' following a C-style comment is supported in a macro + +`define x(a, b) a /* comment */ * b +`define y(a, b) a /* comment */ / b + + module test; + + initial begin + if (`x(2, 3) === 6 && `y(8, 2) === 4) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + + endmodule diff --git a/ivtest/ivltests/macro_comment2.v b/ivtest/ivltests/macro_comment2.v new file mode 100644 index 000000000..3908da21b --- /dev/null +++ b/ivtest/ivltests/macro_comment2.v @@ -0,0 +1,17 @@ +// Check that another comment directly following a C-style comment is +// supported in a macro. + +`define x(a, b) a /* comment */// * b +`define y(a, b) a /* comment *//*/ b*/ + + module test; + + initial begin + if (`x(2, 3) === 2 && `y(8, 2) === 8) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + + endmodule diff --git a/ivtest/ivltests/macro_comment3.v b/ivtest/ivltests/macro_comment3.v new file mode 100644 index 000000000..422d0d97f --- /dev/null +++ b/ivtest/ivltests/macro_comment3.v @@ -0,0 +1,16 @@ +// Check that a '/' directly after opening a C-style comment gets handled +// correctly in a macro. + +`define x(a, b) a /*/ b */ + b + + module test; + + initial begin + if (`x(2, 3) === 5) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + + endmodule diff --git a/ivtest/regress-vlg.list b/ivtest/regress-vlg.list index ef165b190..d3fb4870d 100644 --- a/ivtest/regress-vlg.list +++ b/ivtest/regress-vlg.list @@ -635,6 +635,9 @@ localparam_type normal ivltests gold=parameter_type.gold long_div normal ivltests gold=long_div.gold macro2 normal ivltests macro_args CO,-yivltests ivltests +macro_comment1 normal ivltests +macro_comment2 normal ivltests +macro_comment3 normal ivltests macro_redefinition normal,-Wmacro-redefinition ivltests gold=macro_redefinition.gold macro_replacement normal,-Wmacro-replacement ivltests gold=macro_replacement.gold macsub normal ivltests