mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-24 11:09:15 +02:00
* mark symbols used in conditional compiling expressions using sizeof, resolves #40955
This commit is contained in:
parent
63d5c0078d
commit
22ec4a2033
@ -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
17
tests/webtbs/tw40955.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user