diff --git a/Scanner.pas b/Scanner.pas index 8684a00..f417208 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -3215,7 +3215,9 @@ nextLineNumber := -1; while charKinds[ord(ch)] = ch_white do {skip white space} NextCh; if ch in ['a','d','e','i','l','p','u','w'] then begin + expandMacros := false; NextToken; + expandMacros := true; case token.kind of ifsy: begin if not tSkipping then @@ -3327,12 +3329,19 @@ if ch in ['a','d','e','i','l','p','u','w'] then begin 'p': if token.name^ = 'pragma' then begin if tskipping then goto 2; + expandMacros := false; NextToken; + expandMacros := true; if token.class <> identifier then begin if (lint & lintPragmas) <> 0 then Error(110); goto 2; end; {if} + if token.name^ <> 'STDC' then begin + {Allow macro expansion, other than for STDC } + PutBackToken(token, true); + NextToken; + end; {if} if token.name^ = 'keep' then DoKeep else if token.name^ = 'debug' then begin diff --git a/cc.notes b/cc.notes index 3c3d7d4..62edf0c 100644 --- a/cc.notes +++ b/cc.notes @@ -1946,6 +1946,8 @@ int foo(int[42]); 215. The digit sequence in the #line directive should be interpreted as a decimal number (not octal) even if it begins with a 0. +216. Preprocessing directive names could be subject to macro replacement, potentially altering their behavior (e.g. due to a definition like "#define ifdef ifndef"). Now directive names are not expanded as macros, even if there is a macro of the same name. + -- Bugs from C 2.1.0 that have been fixed ----------------------------------- 1. In some situations, fread() reread the first 1K or so of the file.