diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 07b0a4b0b..653e5c1a9 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -268,7 +268,8 @@ keywords (line|include|define|undef|ifdef|ifndef|else|elsif|endif) `[a-zA-Z][a-zA-Z0-9_$]* { if (macro_needs_args(yytext+1)) yy_push_state(MA_START); else do_expand(0); } -`\" { fputc('\"', yyout); } +`\" { if (!istack->file) fputc('"', yyout); else REJECT; } +`\\`\" { if (!istack->file) fputs("\\\"", yyout); else REJECT; } /* Strings do not contain preprocessor directives or macro expansions. */ diff --git a/ivtest/ivltests/attrib_expr.v b/ivtest/ivltests/attrib_expr.v index 537d5bc5c..070ba9aa0 100644 --- a/ivtest/ivltests/attrib_expr.v +++ b/ivtest/ivltests/attrib_expr.v @@ -74,9 +74,9 @@ endfunction (* attr = fn(10) *) reg attr46; -// Macro escaped -`define A_MACRO(arg) (* attr = `"arg`" *) - `A_MACRO(test) reg attr47; +// Macro escape only in a macro declaration +`define MACRO(arg) (* attr = `"`\`"arg`\`"`" *) +`MACRO(test) reg attr47; initial begin $display("PASSED");