diff --git a/Expression.pas b/Expression.pas index 405eb9b..6752380 100644 --- a/Expression.pas +++ b/Expression.pas @@ -805,8 +805,14 @@ var fToken := token; NextToken; + {in the preprocessor, all identifiers (post macro replacement) become 0} + if kind = preprocessorExpression then begin + stack^.token.kind := longconst; + stack^.token.lval := 0; + end {if} + {if the id is not declared, create a function returning integer} - if id = nil then begin + else if id = nil then begin if token.kind = lparench then begin fnPtr := pointer(GCalloc(sizeof(typeRecord))); {fnPtr^.size := 0;} @@ -827,10 +833,6 @@ var if ((lint & lintUndefFn) <> 0) or ((lint & lintC99Syntax) <> 0) then Error(51); end {if} - else if kind = preprocessorExpression then begin - stack^.token.kind := intconst; - stack^.token.ival := 0; - end {else if} else begin Error(31); errorFound := true; diff --git a/cc.notes b/cc.notes index 661989e..1be7cbf 100644 --- a/cc.notes +++ b/cc.notes @@ -965,6 +965,8 @@ int foo(int[42]); 125. Within character constants, /* or // should not start a comment. +126. In a proprocessor expression, any identifiers remaining after macro expansion should be replaced with the constant 0. This did not work correctly for declared variable or function names, nor for enumeration constants. + -- Bugs from C 2.1.0 that have been fixed ----------------------------------- 1. In some situations, fread() reread the first 1K or so of the file.