mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-03 10:29:41 +00:00
In preprocessor expressions, always replace identifiers with constant 0.
This was not happening for declared identifiers (variables and functions) or for enum constants, as demonstrated in the following example: enum {a,b,c}; #if b #error "bad b" #endif int x = 0; #if x #error "bad x" #endif
This commit is contained in:
parent
c7371b6709
commit
41cb879936
@ -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;
|
||||
|
2
cc.notes
2
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.
|
||||
|
Loading…
Reference in New Issue
Block a user