From 2d6ae52d32f42afcc088b95ca4925c110177d7c9 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 29 Dec 2015 23:18:20 -0600 Subject: [PATCH] Fix bug where a preprocessing directive could be mis-evaluated if it occurred immediately after a use of a function-like macro. This occurred because the code to handle the function-like macro use would read the following token, which could prompt processing of the following preprocessing directive in an inappropriate context. The following example illustrates the problem (the error message would be printed): #define A() #define FOO 1 A() #if !FOO # error "shouldn't get here" #endif --- Scanner.pas | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Scanner.pas b/Scanner.pas index 3496219..27c146b 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -1297,18 +1297,17 @@ if macro^.parameters >= 0 then begin {find the values of the parameters} until done; if paramCount <> macro^.parameters then Error(14); - if token.kind = rparench then {insist on a closing ')'} - begin - if not gettingFileName then - NextToken - end {if} - else + if token.kind <> rparench then begin {insist on a closing ')'} + if not gettingFileName then {put back the source stream token} + PutBackToken(token, true); Error(12); + end; end {if} - else + else begin Error(13); - if not gettingFileName then {put back the source stream token} - PutBackToken(token, true); + if not gettingFileName then {put back the source stream token} + PutBackToken(token, true); + end; {else} end; {if} if macro^.readOnly then begin {handle special macros} case macro^.algorithm of