mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 14:19:28 +02:00
* fixed checking for defined/undefined macro's in the configuration file
(#undef'ed macro's still caused #ifdef/#ifndef to return resp. true/false) git-svn-id: trunk@10872 -
This commit is contained in:
parent
0919c1112f
commit
a324744cbe
@ -1658,7 +1658,7 @@ begin
|
||||
RemoveSep(opts);
|
||||
s:=upper(GetName(opts));
|
||||
if level=0 then
|
||||
skip[level]:=not (assigned(search_macro(s)) or (s='COMMON'));
|
||||
skip[level]:=not defined_macro(s) or (s='COMMON');
|
||||
end
|
||||
else
|
||||
if (s='IFDEF') then
|
||||
@ -1670,7 +1670,7 @@ begin
|
||||
stopOptions(1);
|
||||
end;
|
||||
inc(Level);
|
||||
skip[level]:=(skip[level-1] or not assigned(search_macro(upper(GetName(opts)))));
|
||||
skip[level]:=(skip[level-1] or not defined_macro(upper(GetName(opts))));
|
||||
end
|
||||
else
|
||||
if (s='IFNDEF') then
|
||||
@ -1682,7 +1682,7 @@ begin
|
||||
stopOptions(1);
|
||||
end;
|
||||
inc(Level);
|
||||
skip[level]:=(skip[level-1] or assigned(search_macro(upper(GetName(opts)))));
|
||||
skip[level]:=(skip[level-1] or defined_macro(upper(GetName(opts))));
|
||||
end
|
||||
else
|
||||
if (s='ELSE') then
|
||||
|
@ -432,10 +432,7 @@ implementation
|
||||
valuedescr:= hs;
|
||||
if hs='' then
|
||||
Message(scan_e_error_in_preproc_expr);
|
||||
mac:=tmacro(search_macro(hs));
|
||||
if assigned(mac) then
|
||||
mac.is_used:=true;
|
||||
isdef:= assigned(mac) and mac.defined;
|
||||
isdef:=defined_macro(hs);
|
||||
end;
|
||||
|
||||
procedure dir_ifdef;
|
||||
@ -453,10 +450,7 @@ implementation
|
||||
valuedescr:= hs;
|
||||
if hs='' then
|
||||
Message(scan_e_error_in_preproc_expr);
|
||||
mac:=tmacro(search_macro(hs));
|
||||
if assigned(mac) then
|
||||
mac.is_used:=true;
|
||||
isnotdef:= not (assigned(mac) and mac.defined);
|
||||
isnotdef:=not defined_macro(hs);
|
||||
end;
|
||||
|
||||
procedure dir_ifndef;
|
||||
|
@ -203,6 +203,9 @@ interface
|
||||
{Looks for macro s (must be given in upper case) in the macrosymbolstack, }
|
||||
{and returns it if found. Returns nil otherwise.}
|
||||
function search_macro(const s : string):tsym;
|
||||
{ Additionally to searching for a macro, also checks whether it's still }
|
||||
{ actually defined (could be disable using "undef") }
|
||||
function defined_macro(const s : string):boolean;
|
||||
|
||||
{*** Object Helpers ***}
|
||||
procedure search_class_overloads(aprocsym : tprocsym);
|
||||
@ -1876,6 +1879,21 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
function defined_macro(const s : string):boolean;
|
||||
var
|
||||
mac: tmacro;
|
||||
begin
|
||||
mac:=tmacro(search_macro(s));
|
||||
if assigned(mac) then
|
||||
begin
|
||||
mac.is_used:=true;
|
||||
defined_macro:=mac.defined;
|
||||
end
|
||||
else
|
||||
defined_macro:=false;
|
||||
end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
Object Helpers
|
||||
****************************************************************************}
|
||||
|
Loading…
Reference in New Issue
Block a user