From a7d7cf85e3dc7406ec408c73a53ed94d4223c2d0 Mon Sep 17 00:00:00 2001 From: Yashas Date: Fri, 19 Jan 2018 22:01:06 +0530 Subject: [PATCH] trigger unused symbol warning for references If a reference argument is not read within the function, the compiler does not trigger an unused symbol warning. This commit modifies the compiler to trigger warnings in such cases. Notes: I spent some time checking through every reference that was made to the `uREAD` flag in the entire codebase. As far as I could see, there would be no side-effects of this commit. --- source/compiler/sc1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index b9260f2..164f031 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -4134,8 +4134,6 @@ static void doarg(char *name,int ident,int offset,int tags[],int numtags, assert(numtags>0); argsym=addvariable(name,offset,ident,sLOCAL,tags[0], arg->dim,arg->numdim,arg->idxtag,0); - if (ident==iREFERENCE) - argsym->usage|=uREAD; /* because references are passed back */ if (fpublic) argsym->usage|=uREAD; /* arguments of public functions are always "used" */ if (fconst) @@ -4811,7 +4809,7 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst) errorset(sSETPOS,sym->lnumber); error(203,sym->name,sym->lnumber); /* symbol isn't used (and not stock) */ errorset(sSETPOS,-1); - } else if ((sym->usage & (uREAD | uSTOCK | uPUBLIC))==0) { + } else if ((sym->usage & (uREAD | uSTOCK | uPUBLIC))==0 && sym->ident!=iREFERENCE) { errorset(sSETPOS,sym->lnumber); error(204,sym->name); /* value assigned to symbol is never used */ errorset(sSETPOS,-1);