diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 5fbfd4a19..bc34a1fac 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -1485,8 +1485,10 @@ static void macro_start_args(void) * entry for arg 0. This will be used by macro_finish_arg() to * calculate the buffer location for arg 1. */ - def_buf_free = def_buf_size - 1; - def_buf[0] = 0; + if (def_buf) { + def_buf_free = def_buf_size - 1; + def_buf[0] = 0; + } def_argo[0] = 0; def_argl[0] = 0; def_argc = 1; diff --git a/ivtest/ivltests/macro_args.v b/ivtest/ivltests/macro_args.v new file mode 100644 index 000000000..c23e832c0 --- /dev/null +++ b/ivtest/ivltests/macro_args.v @@ -0,0 +1,8 @@ +`ifndef FOO +`define FOO +`define BAR(x) +`endif + +module macro_args(); + macro_args_sub sub(); +endmodule diff --git a/ivtest/ivltests/macro_args_sub.v b/ivtest/ivltests/macro_args_sub.v new file mode 100644 index 000000000..38241285e --- /dev/null +++ b/ivtest/ivltests/macro_args_sub.v @@ -0,0 +1,3 @@ +module macro_args_sub(); + `BAR(0) +endmodule diff --git a/ivtest/regress-vlg.list b/ivtest/regress-vlg.list index 2b8274d21..df929e4c1 100644 --- a/ivtest/regress-vlg.list +++ b/ivtest/regress-vlg.list @@ -628,6 +628,7 @@ lh_varindx5 normal ivltests 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_redefinition normal,-Wmacro-redefinition ivltests gold=macro_redefinition.gold macro_replacement normal,-Wmacro-replacement ivltests gold=macro_replacement.gold macsub normal ivltests