* mark symbols used in conditional compiling expressions using sizeof, resolves

This commit is contained in:
florian 2024-10-20 14:36:33 +02:00
parent 63d5c0078d
commit 22ec4a2033
2 changed files with 31 additions and 2 deletions
compiler
tests/webtbs

View File

@ -1872,6 +1872,12 @@ type
end;
end;
procedure MarkSymbolAsUsed(sym: tsym);
begin
tabstractvarsym(sym).IncRefCount;
inc(current_module.unitmap[sym.owner.moduleid].refs);
end;
function preproc_factor(eval: Boolean):texprvalue;
var
hs,countstr,storedpattern: string;
@ -2050,9 +2056,15 @@ type
staticvarsym,
localvarsym,
paravarsym :
l:=tabstractvarsym(srsym).getsize;
begin
l:=tabstractvarsym(srsym).getsize;
MarkSymbolAsUsed(srsym);
end;
typesym:
l:=ttypesym(srsym).typedef.size;
begin
l:=ttypesym(srsym).typedef.size;
MarkSymbolAsUsed(srsym);
end;
else
Message(scan_e_error_in_preproc_expr);
end;

17
tests/webtbs/tw40955.pp Normal file
View File

@ -0,0 +1,17 @@
{ %opt=-v -Seh }
program unused;
uses
ctypes;
begin
{$IF SIZEOF(cint) >= 8)}
Writeln('cint is 8 bytes or larger')
{$ELSEIF SIZEOF(cint) >= 4)}
Writeln('cint is 4 bytes or larger')
{$ELSEIF SIZEOF(cint) >= 2)}
Writeln('cint is 2 bytes or larger')
{$ELSE}
Writeln('cint is a puny 1 byte')
{$ENDIF}
end.