mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-17 03:39:28 +02:00
* for symbols used in preprocessor expressions, we don't want to increase references count (for smaller final binaries). Partial fix for problem presented in mantis 31675. Preprocessor functions like declared() in uses section will work only for symbols declared in implicytly included modules (for example like for heaptrc by option -gh, see example/test tw31675.pp)
+ added tests git-svn-id: trunk@36128 -
This commit is contained in:
parent
fef47e05e0
commit
6d1ad52dc5
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -15479,6 +15479,7 @@ tests/webtbs/tw3160b.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3160c.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3161.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3165.pp svneol=native#text/plain
|
||||
tests/webtbs/tw31675.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw3168.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3170.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3172.pp svneol=native#text/plain
|
||||
@ -16141,6 +16142,7 @@ tests/webtbs/uw2956.pp svneol=native#text/plain
|
||||
tests/webtbs/uw2984.pp svneol=native#text/plain
|
||||
tests/webtbs/uw3103.pp svneol=native#text/plain
|
||||
tests/webtbs/uw31431.pp svneol=native#text/pascal
|
||||
tests/webtbs/uw31675.pp svneol=native#text/pascal
|
||||
tests/webtbs/uw3179a.pp svneol=native#text/plain
|
||||
tests/webtbs/uw3179b.pp svneol=native#text/plain
|
||||
tests/webtbs/uw3184a.pp svneol=native#text/plain
|
||||
|
@ -238,6 +238,9 @@ interface
|
||||
{$endif PREPROCWRITE}
|
||||
|
||||
var
|
||||
{ true, if we are parsing preprocessor expressions }
|
||||
in_preproc_comp_expr: boolean = false;
|
||||
|
||||
{ read strings }
|
||||
c : char;
|
||||
orgpattern,
|
||||
@ -2117,10 +2120,12 @@ type
|
||||
end;
|
||||
|
||||
begin
|
||||
in_preproc_comp_expr:=true;
|
||||
current_scanner.skipspace;
|
||||
{ start preproc expression scanner }
|
||||
current_scanner.preproc_token:=current_scanner.readpreproc;
|
||||
preproc_comp_expr:=preproc_sub_expr(opcompare,true);
|
||||
in_preproc_comp_expr:=false;
|
||||
end;
|
||||
|
||||
function boolean_compile_time_expr(var valuedescr: string): Boolean;
|
||||
|
@ -459,7 +459,9 @@ implementation
|
||||
{ codegen }
|
||||
procinfo,
|
||||
{ ppu }
|
||||
entfile
|
||||
entfile,
|
||||
{ parser }
|
||||
scanner
|
||||
;
|
||||
|
||||
|
||||
@ -2795,6 +2797,10 @@ implementation
|
||||
var
|
||||
owner: tsymtable;
|
||||
begin
|
||||
{ for symbols used in preprocessor expressions, we don't want to
|
||||
increase references count (for smaller final binaries) }
|
||||
if in_preproc_comp_expr then
|
||||
exit;
|
||||
{ symbol uses count }
|
||||
sym.IncRefCount;
|
||||
owner:=sym.owner;
|
||||
|
25
tests/webtbs/tw31675.pp
Normal file
25
tests/webtbs/tw31675.pp
Normal file
@ -0,0 +1,25 @@
|
||||
{ %opt=-gh }
|
||||
|
||||
program tw31675;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Classes,
|
||||
{$if declared(useheaptrace)}
|
||||
uw31675,
|
||||
{$endif}
|
||||
SysUtils
|
||||
;
|
||||
|
||||
var
|
||||
i: Boolean = false;
|
||||
begin
|
||||
{$if declared(foo)}
|
||||
i := true;
|
||||
{$endif}
|
||||
if not i then
|
||||
Halt(1);
|
||||
WriteLn('ok');
|
||||
end.
|
||||
|
13
tests/webtbs/uw31675.pp
Normal file
13
tests/webtbs/uw31675.pp
Normal file
@ -0,0 +1,13 @@
|
||||
unit uw31675;
|
||||
|
||||
{$MODE DELPHI}
|
||||
|
||||
interface
|
||||
|
||||
var
|
||||
foo: boolean;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user