don't print warnings about unused variables or arguments in compound
statements which contain asm statements.
This commit is contained in:
parent
5888f3bb16
commit
ffe990841c
@ -1,5 +1,5 @@
|
||||
%{
|
||||
/* $NetBSD: cgram.y,v 1.7 1995/10/02 17:29:45 jpo Exp $ */
|
||||
/* $NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: cgram.y,v 1.7 1995/10/02 17:29:45 jpo Exp $";
|
||||
static char rcsid[] = "$NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -229,11 +229,11 @@ translation_unit:
|
||||
|
||||
ext_decl:
|
||||
func_def {
|
||||
glclrlc(0);
|
||||
glclup(0);
|
||||
clrwflgs();
|
||||
}
|
||||
| data_def {
|
||||
glclrlc(0);
|
||||
glclup(0);
|
||||
clrwflgs();
|
||||
}
|
||||
;
|
||||
@ -1358,8 +1358,13 @@ goto:
|
||||
;
|
||||
|
||||
asm_stmnt:
|
||||
T_ASM T_LPARN read_until_rparn T_SEMI
|
||||
| T_ASM T_QUAL T_LPARN read_until_rparn T_SEMI
|
||||
T_ASM T_LPARN read_until_rparn T_SEMI {
|
||||
setasm();
|
||||
}
|
||||
| T_ASM T_QUAL T_LPARN read_until_rparn T_SEMI {
|
||||
setasm();
|
||||
}
|
||||
| T_ASM error
|
||||
;
|
||||
|
||||
read_until_rparn:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: decl.c,v 1.9 1995/10/02 17:29:48 jpo Exp $ */
|
||||
/* $NetBSD: decl.c,v 1.10 1995/10/02 17:31:37 jpo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: decl.c,v 1.9 1995/10/02 17:29:48 jpo Exp $";
|
||||
static char rcsid[] = "$NetBSD: decl.c,v 1.10 1995/10/02 17:31:37 jpo Exp $";
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -72,8 +72,8 @@ static sym_t *nsfunc __P((sym_t *, sym_t *));
|
||||
static void osfunc __P((sym_t *, sym_t *));
|
||||
static void ledecl __P((sym_t *));
|
||||
static int chkinit __P((sym_t *));
|
||||
static void chkausg __P((sym_t *));
|
||||
static void chkvusg __P((sym_t *));
|
||||
static void chkausg __P((int, sym_t *));
|
||||
static void chkvusg __P((int, sym_t *));
|
||||
static void chklusg __P((sym_t *));
|
||||
static void chktusg __P((sym_t *));
|
||||
static void chkglvar __P((sym_t *));
|
||||
@ -623,7 +623,7 @@ popdecl()
|
||||
break;
|
||||
case AUTO:
|
||||
/* check usage of local vars */
|
||||
chkusage(di->d_dlsyms);
|
||||
chkusage(di);
|
||||
/* FALLTHROUGH */
|
||||
case PARG:
|
||||
/* usage of arguments will be checked by funcend() */
|
||||
@ -635,6 +635,32 @@ popdecl()
|
||||
free(di);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set flag d_asm in all declaration stack elements up to the
|
||||
* outermost one.
|
||||
*
|
||||
* This is used to mark compound statements which have, possibly in
|
||||
* nested compound statements, asm statements. For these compound
|
||||
* statements no warnings about unused or unitialized variables are
|
||||
* printed.
|
||||
*
|
||||
* There is no need to clear d_asm in dinfo structs with context AUTO,
|
||||
* because these structs are freed at the end of the compound statement.
|
||||
* But it must be cleard in the outermost dinfo struct, which has
|
||||
* context EXTERN. This could be done in clrtyp() and would work for
|
||||
* C, but not for C++ (due to mixed statements and declarations). Thus
|
||||
* we clear it in glclup(), which is used to do some cleanup after
|
||||
* global declarations/definitions.
|
||||
*/
|
||||
void
|
||||
setasm()
|
||||
{
|
||||
dinfo_t *di;
|
||||
|
||||
for (di = dcs; di != NULL; di = di->d_nxt)
|
||||
di->d_asm = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean all elements of the top element of declaration stack which
|
||||
* will be used by the next declaration
|
||||
@ -2709,7 +2735,7 @@ globclup()
|
||||
* remove all informations about pending lint directives without
|
||||
* warnings.
|
||||
*/
|
||||
glclrlc(1);
|
||||
glclup(1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2794,8 +2820,8 @@ setuflg(sym, fcall, szof)
|
||||
* with s_dlnxt) if these are not used or only set.
|
||||
*/
|
||||
void
|
||||
chkusage(syms)
|
||||
sym_t *syms;
|
||||
chkusage(di)
|
||||
dinfo_t *di;
|
||||
{
|
||||
sym_t *sym;
|
||||
int mknowarn;
|
||||
@ -2804,8 +2830,8 @@ chkusage(syms)
|
||||
mknowarn = nowarn;
|
||||
nowarn = 0;
|
||||
|
||||
for (sym = syms; sym != NULL; sym = sym->s_dlnxt)
|
||||
chkusg1(sym);
|
||||
for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_dlnxt)
|
||||
chkusg1(di->d_asm, sym);
|
||||
|
||||
nowarn = mknowarn;
|
||||
}
|
||||
@ -2815,7 +2841,8 @@ chkusage(syms)
|
||||
* only set.
|
||||
*/
|
||||
void
|
||||
chkusg1(sym)
|
||||
chkusg1(novar, sym)
|
||||
int novar;
|
||||
sym_t *sym;
|
||||
{
|
||||
pos_t cpos;
|
||||
@ -2827,9 +2854,9 @@ chkusg1(sym)
|
||||
|
||||
if (sym->s_kind == FVFT) {
|
||||
if (sym->s_arg) {
|
||||
chkausg(sym);
|
||||
chkausg(novar, sym);
|
||||
} else {
|
||||
chkvusg(sym);
|
||||
chkvusg(novar, sym);
|
||||
}
|
||||
} else if (sym->s_kind == FLAB) {
|
||||
chklusg(sym);
|
||||
@ -2841,12 +2868,16 @@ chkusg1(sym)
|
||||
}
|
||||
|
||||
static void
|
||||
chkausg(arg)
|
||||
chkausg(novar, arg)
|
||||
int novar;
|
||||
sym_t *arg;
|
||||
{
|
||||
if (!arg->s_set)
|
||||
lerror("chkausg() 1");
|
||||
|
||||
if (novar)
|
||||
return;
|
||||
|
||||
if (!arg->s_used && vflag) {
|
||||
STRUCT_ASSIGN(curr_pos, arg->s_dpos);
|
||||
/* argument %s unused in function %s */
|
||||
@ -2855,7 +2886,8 @@ chkausg(arg)
|
||||
}
|
||||
|
||||
static void
|
||||
chkvusg(sym)
|
||||
chkvusg(novar, sym)
|
||||
int novar;
|
||||
sym_t *sym;
|
||||
{
|
||||
scl_t sc;
|
||||
@ -2869,7 +2901,7 @@ chkvusg(sym)
|
||||
return;
|
||||
|
||||
/*
|
||||
* XXX Only variables are checkd, although types and tags should
|
||||
* XXX Only variables are checkd, although types should
|
||||
* probably also be checked
|
||||
*/
|
||||
if ((sc = sym->s_scl) != EXTERN && sc != STATIC &&
|
||||
@ -2877,6 +2909,9 @@ chkvusg(sym)
|
||||
return;
|
||||
}
|
||||
|
||||
if (novar)
|
||||
return;
|
||||
|
||||
if (sc == EXTERN) {
|
||||
if (!sym->s_used && !sym->s_set) {
|
||||
STRUCT_ASSIGN(curr_pos, sym->s_dpos);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: externs1.h,v 1.6 1995/10/02 17:29:52 jpo Exp $ */
|
||||
/* $NetBSD: externs1.h,v 1.7 1995/10/02 17:31:39 jpo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
@ -137,6 +137,7 @@ extern void addtype __P((type_t *));
|
||||
extern void addqual __P((tqual_t));
|
||||
extern void pushdecl __P((scl_t));
|
||||
extern void popdecl __P((void));
|
||||
extern void setasm __P((void));
|
||||
extern void clrtyp __P((void));
|
||||
extern void deftyp __P((void));
|
||||
extern int length __P((type_t *, const char *));
|
||||
@ -170,8 +171,8 @@ extern sym_t *decl1abs __P((sym_t *));
|
||||
extern void chksz __P((sym_t *));
|
||||
extern void setsflg __P((sym_t *));
|
||||
extern void setuflg __P((sym_t *, int, int));
|
||||
extern void chkusage __P((sym_t *));
|
||||
extern void chkusg1 __P((sym_t *));
|
||||
extern void chkusage __P((dinfo_t *));
|
||||
extern void chkusg1 __P((int, sym_t *));
|
||||
extern void chkglsyms __P((void));
|
||||
extern void prevdecl __P((int, sym_t *));
|
||||
|
||||
@ -244,7 +245,7 @@ extern void dogoto __P((sym_t *));
|
||||
extern void docont __P((void));
|
||||
extern void dobreak __P((void));
|
||||
extern void doreturn __P((tnode_t *));
|
||||
extern void glclrlc __P((int));
|
||||
extern void glclup __P((int));
|
||||
extern void argsused __P((int));
|
||||
extern void constcond __P((int));
|
||||
extern void fallthru __P((int));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: func.c,v 1.6 1995/10/02 17:29:53 jpo Exp $ */
|
||||
/* $NetBSD: func.c,v 1.7 1995/10/02 17:31:40 jpo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: func.c,v 1.6 1995/10/02 17:29:53 jpo Exp $";
|
||||
static char rcsid[] = "$NetBSD: func.c,v 1.7 1995/10/02 17:31:40 jpo Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -359,7 +359,7 @@ funcend()
|
||||
arg = dcs->d_fargs;
|
||||
n = 0;
|
||||
while (arg != NULL && (nargusg == -1 || n < nargusg)) {
|
||||
chkusg1(arg);
|
||||
chkusg1(dcs->d_asm, arg);
|
||||
arg = arg->s_nxt;
|
||||
n++;
|
||||
}
|
||||
@ -1016,11 +1016,11 @@ doreturn(tn)
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove Informations about unused lint comments after extern
|
||||
* definitions/declarations.
|
||||
* Do some cleanup after a global declaration or definition.
|
||||
* Especially remove informations about unused lint comments.
|
||||
*/
|
||||
void
|
||||
glclrlc(silent)
|
||||
glclup(silent)
|
||||
int silent;
|
||||
{
|
||||
pos_t cpos;
|
||||
@ -1061,6 +1061,8 @@ glclrlc(silent)
|
||||
}
|
||||
|
||||
STRUCT_ASSIGN(curr_pos, cpos);
|
||||
|
||||
dcs->d_asm = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lint1.h,v 1.5 1995/10/02 17:21:39 jpo Exp $ */
|
||||
/* $NetBSD: lint1.h,v 1.6 1995/10/02 17:31:41 jpo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
@ -309,6 +309,7 @@ typedef struct dinfo {
|
||||
u_int d_vararg : 1; /* ... in in current function decl. */
|
||||
u_int d_proto : 1; /* current funct. decl. is prototype */
|
||||
u_int d_notyp : 1; /* set if no type specifier was present */
|
||||
u_int d_asm : 1; /* set if d_ctx == AUTO and asm() present */
|
||||
type_t *d_tagtyp; /* tag during member declaration */
|
||||
sym_t *d_fargs; /* list of arguments during function def. */
|
||||
pos_t d_fdpos; /* position of function definition */
|
||||
|
Loading…
Reference in New Issue
Block a user