From 7951c557ad4c84823ea5f03d645bced5a24fe7b6 Mon Sep 17 00:00:00 2001 From: Stanislav Gromov Date: Fri, 2 Oct 2020 23:11:31 +0800 Subject: [PATCH 1/2] Do not track unused assignments for static local variables --- source/compiler/sc2.c | 2 +- source/compiler/sc3.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index f186785a..65cfaa72 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -3208,7 +3208,7 @@ SC_FUNC void markinitialized(symbol *sym,int assignment) return; if (sc_status==statFIRST && (sym->vclass==sLOCAL || sym->vclass==sSTATIC)) return; - if (assignment && sym->vclass!=sGLOBAL && (sym->ident==iVARIABLE || sym->ident==iREFERENCE)) { + if (assignment && sym->vclass==sLOCAL && (sym->ident==iVARIABLE || sym->ident==iREFERENCE)) { sym->usage |= uASSIGNED; sym->assignlevel=pc_nestlevel; } /* if */ diff --git a/source/compiler/sc3.c b/source/compiler/sc3.c index f7697974..0daaa78f 100644 --- a/source/compiler/sc3.c +++ b/source/compiler/sc3.c @@ -1083,8 +1083,7 @@ static int hier14(value *lval1) if (oper==NULL) { symbol *sym=lval3.sym; assert(sym!=NULL); - if ((sym->usage & uASSIGNED)!=0 && sym->assignlevel>=pc_nestlevel - && (sym->vclass==sLOCAL || sym->vclass==sSTATIC)) + if ((sym->usage & uASSIGNED)!=0 && sym->assignlevel>=pc_nestlevel && sym->vclass==sLOCAL) error(240,sym->name); /* previously assigned value is unused */ markinitialized(sym,TRUE); if (pc_ovlassignment) From ffac185bf9560a448f809dd1e98b2187cdee4c9d Mon Sep 17 00:00:00 2001 From: Stanislav Gromov Date: Fri, 2 Oct 2020 23:16:26 +0800 Subject: [PATCH 2/2] Update tests --- source/compiler/tests/warning_240.meta | 1 - 1 file changed, 1 deletion(-) diff --git a/source/compiler/tests/warning_240.meta b/source/compiler/tests/warning_240.meta index 1d6fbe3d..3b58bc4c 100644 --- a/source/compiler/tests/warning_240.meta +++ b/source/compiler/tests/warning_240.meta @@ -12,7 +12,6 @@ warning_240.pwn(97) : warning 240: previously assigned value is never used (symb warning_240.pwn(109) : warning 240: previously assigned value is never used (symbol "local_var") warning_240.pwn(120) : warning 240: previously assigned value is never used (symbol "local_var") warning_240.pwn(139) : warning 240: previously assigned value is never used (symbol "local_var") -warning_240.pwn(148) : warning 240: previously assigned value is never used (symbol "local_static_var") warning_240.pwn(174) : warning 240: previously assigned value is never used (symbol "arg") warning_240.pwn(178) : warning 240: previously assigned value is never used (symbol "arg") warning_240.pwn(183) : warning 240: previously assigned value is never used (symbol "refarg")