mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 17:59:27 +02:00
Merged revision(s) 32515, 32573, 32575, 32579 from branches/svenbarth/packages:
Report a warning if a unit is used from an indirectly used package. We are doing this only for the units used in contained units though as in the "contains" section there can't be such units anyway (and just checking all loaded units would lead to false positives). pkgutil.pas: + new procedure check_for_indirect_package_usages() which walks a TLinkedList of used units and warns on every unit that is from an indirectly imported package pmodules.pas, proc_package: * when checking all loaded units whether they are from a package or not also check for indirect package usages using the new procedure ........ pkgutil.pas, exportprocsym: * use a temporary variable for the procdef * restructure the if-expression a bit to make it better readable ........ pmodules.pas, finish_unit: * also release the generated proc symbol if the init function isn't needed ........ pkgutil.pas, add_package_libs: * fix exit condition (on Linux it probably worked by accident :/ ) ........ git-svn-id: trunk@33518 -
This commit is contained in:
parent
e8ede4c3e2
commit
1824a945cf
@ -27,7 +27,7 @@ unit pkgutil;
|
||||
interface
|
||||
|
||||
uses
|
||||
fmodule,fpkg,link,cstreams;
|
||||
fmodule,fpkg,link,cstreams,cclasses;
|
||||
|
||||
procedure createimportlibfromexternals;
|
||||
Function RewritePPU(const PPUFn:String;OutStream:TCStream):Boolean;
|
||||
@ -36,13 +36,14 @@ interface
|
||||
procedure add_package(const name:string;ignoreduplicates:boolean;direct:boolean);
|
||||
procedure add_package_unit_ref(package:tpackage);
|
||||
procedure add_package_libs(l:tlinker);
|
||||
procedure check_for_indirect_package_usages(modules:tlinkedlist);
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
sysutils,
|
||||
globtype,systems,
|
||||
cutils,cclasses,
|
||||
cutils,
|
||||
globals,verbose,
|
||||
symtype,symconst,symsym,symdef,symbase,symtable,
|
||||
ppu,entfile,fpcp,
|
||||
@ -74,20 +75,22 @@ implementation
|
||||
var
|
||||
i : longint;
|
||||
item : TCmdStrListItem;
|
||||
pd : tprocdef;
|
||||
begin
|
||||
for i:=0 to tprocsym(sym).ProcdefList.Count-1 do
|
||||
begin
|
||||
if not(tprocdef(tprocsym(sym).ProcdefList[i]).proccalloption in [pocall_internproc]) and
|
||||
((tprocdef(tprocsym(sym).ProcdefList[i]).procoptions*[po_external])=[]) and
|
||||
pd:=tprocdef(tprocsym(sym).procdeflist[i]);
|
||||
if not(pd.proccalloption in [pocall_internproc]) and
|
||||
((pd.procoptions*[po_external])=[]) and
|
||||
(
|
||||
(symtable.symtabletype in [globalsymtable,recordsymtable,objectsymtable]) or
|
||||
(
|
||||
(symtable.symtabletype=staticsymtable) and
|
||||
([po_public,po_has_public_name]*tprocdef(tprocsym(sym).ProcdefList[i]).procoptions<>[])
|
||||
([po_public,po_has_public_name]*pd.procoptions<>[])
|
||||
)
|
||||
) then
|
||||
begin
|
||||
exportallprocdefnames(tprocsym(sym),tprocdef(tprocsym(sym).ProcdefList[i]),[]);
|
||||
exportallprocdefnames(tprocsym(sym),pd,[]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -480,7 +483,8 @@ implementation
|
||||
i : longint;
|
||||
pkgname : tpathstr;
|
||||
begin
|
||||
if not (target_info.system in systems_indirect_var_imports) then
|
||||
if target_info.system in systems_indirect_var_imports then
|
||||
{ we're using import libraries anyway }
|
||||
exit;
|
||||
for i:=0 to packagelist.count-1 do
|
||||
begin
|
||||
@ -502,6 +506,28 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
procedure check_for_indirect_package_usages(modules:tlinkedlist);
|
||||
var
|
||||
uu : tused_unit;
|
||||
pentry : ppackageentry;
|
||||
begin
|
||||
uu:=tused_unit(modules.first);
|
||||
while assigned(uu) do
|
||||
begin
|
||||
if assigned(uu.u.package) then
|
||||
begin
|
||||
pentry:=ppackageentry(packagelist.find(uu.u.package.packagename^));
|
||||
if not assigned(pentry) then
|
||||
internalerror(2015112304);
|
||||
if not pentry^.direct then
|
||||
Message2(package_w_unit_from_indirect_package,uu.u.realmodulename^,uu.u.package.realpackagename^);
|
||||
end;
|
||||
|
||||
uu:=tused_unit(uu.Next);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure createimportlibfromexternals;
|
||||
var
|
||||
alreadyloaded : tfpobjectlist;
|
||||
|
@ -1141,7 +1141,10 @@ type
|
||||
begin
|
||||
{ first release the not used init procinfo }
|
||||
if assigned(init_procinfo) then
|
||||
release_main_proc(init_procinfo);
|
||||
begin
|
||||
release_proc_symbol(init_procinfo.procdef);
|
||||
release_main_proc(init_procinfo);
|
||||
end;
|
||||
init_procinfo:=gen_implicit_initfinal(uf_init,current_module.localsymtable);
|
||||
end;
|
||||
{ finalize? }
|
||||
@ -1725,7 +1728,10 @@ type
|
||||
if (hp<>current_module) then
|
||||
begin
|
||||
if not assigned(hp.package) then
|
||||
pkg.addunit(hp)
|
||||
begin
|
||||
pkg.addunit(hp);
|
||||
check_for_indirect_package_usages(hp.used_units);
|
||||
end
|
||||
else
|
||||
begin
|
||||
pentry:=ppackageentry(packagelist.find(hp.package.packagename^));
|
||||
|
Loading…
Reference in New Issue
Block a user