From ad1ef0d8562cfb1b85ae90bdb82fc3fab5b71b83 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 --- macro/MacroFlex.ll | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/macro/MacroFlex.ll b/macro/MacroFlex.ll index 57776709..21a35a1c 100644 --- a/macro/MacroFlex.ll +++ b/macro/MacroFlex.ll @@ -305,6 +305,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