Skip to content

Commit 2c5084c

Browse files
committed
parallelfor: silence bogus uninitialized warnings
1 parent b48add3 commit 2c5084c

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

compiler/pmodules.pas

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ implementation
4040

4141
uses
4242
SysUtils,
43-
globtype,systems,tokens,
43+
globtype,systems,tokens,constexp,
4444
cutils,cfileutl,cclasses,comphook,
4545
globals,verbose,finput,fppu,globstat,fpcp,fpkg,
4646
symconst,symbase,symtype,symdef,symsym,symtable,defutil,symcreat,
@@ -1206,6 +1206,12 @@ current_module.rtti_directive.options:=class_tobject.rtti.options;
12061206
cderefnode.create(ctypeconvnode.create_internal(
12071207
cloadnode.create(psym,psym.owner),
12081208
cpointerdef.getreusable(tprocvardef(curr.parfor_nested_pvd))))));
1209+
{ the thread return value is never read, but leaving the result
1210+
unassigned makes dfa warn about an uninitialized function result
1211+
at the first parallel loop of the module }
1212+
addstatement(stat,cassignmentnode.create(
1213+
cloadnode.create(thunkpd.funcretsym,thunkpd.funcretsym.owner),
1214+
cordconstnode.create(0,ptrsinttype,false)));
12091215
typecheckpass(body);
12101216
thunkpi.code:=body;
12111217
symtablestack.pop(thunkpd.localst);

compiler/pstatmnt.pas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,6 +2318,9 @@ ((tsubscriptnode(hp).left.resultdef.typ=recorddef) or
23182318
tidarrtype:=carraydef.create(0,255,s32inttype);
23192319
tarraydef(tidarrtype).elementdef:=tidtype;
23202320
partids:=parfor_make_local(old_procinfo.procdef,'$partids'+workerpd.unique_id_str,tidarrtype);
2321+
{ only written element-wise in the spawn loop, which dfa cannot
2322+
prove covers the reads - keep it out of the uninitialized checks }
2323+
include(partids.varoptions,vo_is_internal);
23212324
parkvar:=parfor_make_local(old_procinfo.procdef,'$park'+workerpd.unique_id_str,s32inttype);
23222325

23232326
{ caller side: set up the shared state, size the pool, spawn the

0 commit comments

Comments
 (0)