From 047597d40b4dbab8608226c6f9e8e6d85495fd33 Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Mon, 29 Jan 2018 10:56:41 +0100 Subject: [PATCH] macroprocessor: fix unhandled case of nested ifdef/ifndef statements. closes #1587 (cherry picked from commit bfe07d389bae4cc5d33d432a3886067d5e28fa28) --- preprocessor/macro/MacroFlex.ll | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/preprocessor/macro/MacroFlex.ll b/preprocessor/macro/MacroFlex.ll index 9c9bc66f7..759b7d3a6 100644 --- a/preprocessor/macro/MacroFlex.ll +++ b/preprocessor/macro/MacroFlex.ll @@ -300,6 +300,16 @@ CONT \\\\ then_body_tmp.append(yytext); yylloc->step(); } +<THEN_BODY>^{SPC}*@#{SPC}*ifdef({SPC}|{CONT}) { + nested_if_nb++; + then_body_tmp.append(yytext); + yylloc->step(); + } +<THEN_BODY>^{SPC}*@#{SPC}*ifndef({SPC}|{CONT}) { + nested_if_nb++; + then_body_tmp.append(yytext); + yylloc->step(); + } <THEN_BODY>. { then_body_tmp.append(yytext); yylloc->step(); } <THEN_BODY><<EOF>> { driver.error(if_stmt_loc_tmp, "@#if/@#ifdef/@#ifndef not matched by an @#endif or file does not end with a new line (unexpected end of file)"); } <THEN_BODY>^{SPC}*@#{SPC}*else{SPC}*(\/\/.*)?{EOL} { -- GitLab