From 2e77dbc38a23cfc5b3730595db9e3abeeb5253a0 Mon Sep 17 00:00:00 2001 From: damc Date: Mon, 25 Jul 2022 21:59:40 +0200 Subject: [PATCH] ppTests Extend macro_LINE to catch more unusual behaviour seen in the wild. --- sv-parser-pp/testcases/expected/macro_LINE.sv | 23 ++++++++++--- sv-parser-pp/testcases/macro_LINE.sv | 34 ++++++++++++++++--- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/sv-parser-pp/testcases/expected/macro_LINE.sv b/sv-parser-pp/testcases/expected/macro_LINE.sv index c741818..46752cd 100644 --- a/sv-parser-pp/testcases/expected/macro_LINE.sv +++ b/sv-parser-pp/testcases/expected/macro_LINE.sv @@ -1,6 +1,19 @@ -module a; -initial begin - if (3 == 0) begin - end -end +// __LINE__ = `__LINE__ + +// This block SHOULD be emitted from the preprocessor. + + +// Emitted instead. + + +// The following define should have no effect. +`define __LINE__ -2 + +// The following undef should have no effect. +module M; + initial + if (26 == 28) // Should be "26 == 28". + $display("PASS"); + else if (28 == 28) // Should be "28 == 28". + $display("FAIL"); endmodule diff --git a/sv-parser-pp/testcases/macro_LINE.sv b/sv-parser-pp/testcases/macro_LINE.sv index 911ec70..76de077 100644 --- a/sv-parser-pp/testcases/macro_LINE.sv +++ b/sv-parser-pp/testcases/macro_LINE.sv @@ -1,6 +1,30 @@ -module a; -initial begin - if (`__LINE__ == 0) begin - end -end +// __LINE__ = `__LINE__ + +`ifdef __LINE__ +// This block SHOULD be emitted from the preprocessor. +`elsif UNDEFINED +// NOT emitted. +`endif + +`ifndef __LINE__ +// This block should NOT be emitted from the preprocessor. +// However, following (conditional) definition should make it through the +// preprocessor parsing stage without error. +`define __LINE__ -1 +`elsif UNDEFINED +// Emitted instead. +`endif + +// The following define should have no effect. +`define __LINE__ -2 + +// The following undef should have no effect. +`undef __LINE__ + +module M; + initial + if (`__LINE__ == 28) // Should be "26 == 28". + $display("PASS"); + else if (`__LINE__ == 28) // Should be "28 == 28". + $display("FAIL"); endmodule