summaryrefslogtreecommitdiff
path: root/usr.bin/xlint/lint1/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/xlint/lint1/decl.c')
-rw-r--r--usr.bin/xlint/lint1/decl.c225
1 files changed, 70 insertions, 155 deletions
diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c
index ad43b68b55d..3965f62a3f1 100644
--- a/usr.bin/xlint/lint1/decl.c
+++ b/usr.bin/xlint/lint1/decl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: decl.c,v 1.11 2005/08/14 11:02:33 miod Exp $ */
+/* $OpenBSD: decl.c,v 1.12 2005/11/19 03:35:27 cloder Exp $ */
/* $NetBSD: decl.c,v 1.11 1995/10/02 17:34:16 jpo Exp $ */
/*
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: decl.c,v 1.11 2005/08/14 11:02:33 miod Exp $";
+static char rcsid[] = "$OpenBSD: decl.c,v 1.12 2005/11/19 03:35:27 cloder Exp $";
#endif
#include <sys/param.h>
@@ -84,7 +84,7 @@ static void glchksz(sym_t *);
* initializes all global vars used in declarations
*/
void
-initdecl()
+initdecl(void)
{
int i;
static struct {
@@ -209,15 +209,13 @@ initdecl()
* if it is to be modified (adding qualifiers or anything else).
*/
type_t *
-gettyp(t)
- tspec_t t;
+gettyp(tspec_t t)
{
return (&typetab[t]);
}
type_t *
-duptyp(tp)
- const type_t *tp;
+duptyp(const type_t *tp)
{
type_t *ntp;
@@ -231,8 +229,7 @@ duptyp(tp)
* allocated memory should be freed after the expr).
*/
type_t *
-tduptyp(tp)
- const type_t *tp;
+tduptyp(const type_t *tp)
{
type_t *ntp;
@@ -246,8 +243,7 @@ tduptyp(tp)
* struct, union or enum type.
*/
int
-incompl(tp)
- type_t *tp;
+incompl(type_t *tp)
{
tspec_t t;
@@ -268,9 +264,7 @@ incompl(tp)
* types.
*/
void
-setcompl(tp, ic)
- type_t *tp;
- int ic;
+setcompl(type_t *tp, int ic)
{
tspec_t t;
@@ -291,8 +285,7 @@ setcompl(tp, ic)
* storage classes.
*/
void
-addscl(sc)
- scl_t sc;
+addscl(scl_t sc)
{
if (sc == INLINE) {
if (dcs->d_inline)
@@ -328,8 +321,7 @@ addscl(sc)
* struct/union/enum tag.
*/
void
-addtype(tp)
- type_t *tp;
+addtype(type_t *tp)
{
tspec_t t;
@@ -426,9 +418,7 @@ addtype(tp)
* and other specifiers (except struct, union, enum, typedef name)
*/
static type_t *
-tdeferr(td, t)
- type_t *td;
- tspec_t t;
+tdeferr(type_t *td, tspec_t t)
{
tspec_t t2;
@@ -498,9 +488,7 @@ tdeferr(td, t)
* if the tag is unnamed.
*/
static void
-settdsym(tp, sym)
- type_t *tp;
- sym_t *sym;
+settdsym(type_t *tp, sym_t *sym)
{
tspec_t t;
@@ -522,8 +510,7 @@ settdsym(tp, sym)
* for all declarators.
*/
void
-addqual(q)
- tqual_t q;
+addqual(tqual_t q)
{
if (q == CONST) {
if (dcs->d_const) {
@@ -547,8 +534,7 @@ addqual(q)
* argument declaration lists ...)
*/
void
-pushdecl(sc)
- scl_t sc;
+pushdecl(scl_t sc)
{
dinfo_t *di;
@@ -567,7 +553,7 @@ pushdecl(sc)
* Go back to previous declaration level
*/
void
-popdecl()
+popdecl(void)
{
dinfo_t *di;
@@ -652,7 +638,7 @@ popdecl()
* global declarations/definitions.
*/
void
-setasm()
+setasm(void)
{
dinfo_t *di;
@@ -665,7 +651,7 @@ setasm()
* will be used by the next declaration
*/
void
-clrtyp()
+clrtyp(void)
{
dcs->d_atyp = dcs->d_smod = dcs->d_lmod = NOTSPEC;
dcs->d_scl = NOSCL;
@@ -684,7 +670,7 @@ clrtyp()
* context.
*/
void
-deftyp()
+deftyp(void)
{
tspec_t t, s, l;
type_t *tp;
@@ -800,8 +786,7 @@ deftyp()
* Merge type specifiers (char, ..., long long, signed, unsigned).
*/
static tspec_t
-mrgtspec(t, s)
- tspec_t t, s;
+mrgtspec(tspec_t t, tspec_t s)
{
if (s == SIGNED || s == UNSIGN) {
if (t == CHAR) {
@@ -828,9 +813,7 @@ mrgtspec(t, s)
* if name is not NULL.
*/
int
-length(tp, name)
- type_t *tp;
- const char *name;
+length(type_t *tp, const char *name)
{
int elem, elsz;
@@ -871,8 +854,7 @@ length(tp, name)
* Get the alignment of the given Type in bits.
*/
int
-getbound(tp)
- type_t *tp;
+getbound(type_t *tp)
{
int a;
tspec_t t;
@@ -903,8 +885,7 @@ getbound(tp)
* struct/union/enum elements and parameters.
*/
sym_t *
-lnklst(l1, l2)
- sym_t *l1, *l2;
+lnklst(sym_t *l1, sym_t *l2)
{
sym_t *l;
@@ -926,8 +907,7 @@ lnklst(l1, l2)
* - void types other than type of function or pointer
*/
void
-chktyp(sym)
- sym_t *sym;
+chktyp(sym_t *sym)
{
tspec_t to, t;
type_t **tpp, *tp;
@@ -1019,8 +999,7 @@ chktyp(sym)
* Process the declarator of a struct/union element.
*/
sym_t *
-decl1str(dsym)
- sym_t *dsym;
+decl1str(sym_t *dsym)
{
type_t *tp;
tspec_t t;
@@ -1138,8 +1117,7 @@ decl1str(dsym)
* al contains the required alignment, len the length of a bit-field.
*/
static void
-align(al, len)
- int al, len;
+align(int al, int len)
{
int no;
@@ -1160,9 +1138,7 @@ align(al, len)
* Remember the width of the field in its type structure.
*/
sym_t *
-bitfield(dsym, len)
- sym_t *dsym;
- int len;
+bitfield(sym_t *dsym, int len)
{
if (dsym == NULL) {
dsym = getblk(sizeof (sym_t));
@@ -1186,8 +1162,7 @@ bitfield(dsym, len)
* will be at the top of the list.
*/
pqinf_t *
-mergepq(p1, p2)
- pqinf_t *p1, *p2;
+mergepq(pqinf_t *p1, pqinf_t *p2)
{
pqinf_t *p;
@@ -1225,9 +1200,7 @@ mergepq(p1, p2)
* declarator. The new type extension is inserted between both.
*/
sym_t *
-addptr(decl, pi)
- sym_t *decl;
- pqinf_t *pi;
+addptr(sym_t *decl, pqinf_t *pi)
{
type_t **tpp, *tp;
pqinf_t *npi;
@@ -1254,9 +1227,7 @@ addptr(decl, pi)
* n is the specified dimension
*/
sym_t *
-addarray(decl, dim, n)
- sym_t *decl;
- int dim, n;
+addarray(sym_t *decl, int dim, int n)
{
type_t **tpp, *tp;
@@ -1285,8 +1256,7 @@ addarray(decl, dim, n)
}
sym_t *
-addfunc(decl, args)
- sym_t *decl, *args;
+addfunc(sym_t *decl, sym_t *args)
{
type_t **tpp, *tp;
@@ -1334,8 +1304,7 @@ addfunc(decl, args)
*/
/* ARGSUSED */
static sym_t *
-nsfunc(decl, args)
- sym_t *decl, *args;
+nsfunc(sym_t *decl, sym_t *args)
{
sym_t *arg, *sym;
scl_t sc;
@@ -1373,8 +1342,7 @@ nsfunc(decl, args)
* Called for old style function declarations.
*/
static void
-osfunc(decl, args)
- sym_t *decl, *args;
+osfunc(sym_t *decl, sym_t *args)
{
/*
* Remember list of params only if this is really seams to be
@@ -1403,9 +1371,7 @@ osfunc(decl, args)
* error message.
*/
void
-chkfdef(sym, msg)
- sym_t *sym;
- int msg;
+chkfdef(sym_t *sym, int msg)
{
if (sym->s_osdef) {
if (msg) {
@@ -1425,8 +1391,7 @@ chkfdef(sym, msg)
* s_def and s_reg are valid after dname().
*/
sym_t *
-dname(sym)
- sym_t *sym;
+dname(sym_t *sym)
{
scl_t sc = NOSCL;
@@ -1524,8 +1489,7 @@ dname(sym)
* definition.
*/
sym_t *
-iname(sym)
- sym_t *sym;
+iname(sym_t *sym)
{
if (sym->s_scl != NOSCL) {
if (blklev == sym->s_blklev) {
@@ -1553,10 +1517,7 @@ iname(sym)
* semi is 1 if the following token is T_SEMI
*/
type_t *
-mktag(tag, kind, decl, semi)
- sym_t *tag;
- tspec_t kind;
- int decl, semi;
+mktag(sym_t *tag, tspec_t kind, int decl, int semi)
{
scl_t scl = NOSCL;
type_t *tp;
@@ -1624,10 +1585,7 @@ mktag(tag, kind, decl, semi)
* semi is 1 if T_SEMI follows
*/
static sym_t *
-newtag(tag, scl, decl, semi)
- sym_t *tag;
- scl_t scl;
- int decl, semi;
+newtag(sym_t *tag, scl_t scl, int decl, int semi)
{
if (tag->s_blklev < blklev) {
if (semi) {
@@ -1679,8 +1637,7 @@ newtag(tag, scl, decl, semi)
}
const char *
-scltoa(sc)
- scl_t sc;
+scltoa(scl_t sc)
{
const char *s;
@@ -1703,9 +1660,7 @@ scltoa(sc)
* tp points to the type of the, tag, fmem to the list of members/enums.
*/
type_t *
-compltag(tp, fmem)
- type_t *tp;
- sym_t *fmem;
+compltag(type_t *tp, sym_t *fmem)
{
tspec_t t;
str_t *sp;
@@ -1750,9 +1705,7 @@ compltag(tp, fmem)
* impl is 1 if the the value of the enumerator was not explicit specified.
*/
sym_t *
-ename(sym, val, impl)
- sym_t *sym;
- int val, impl;
+ename(sym_t *sym, int val, int impl)
{
if (sym->s_scl) {
if (sym->s_blklev == blklev) {
@@ -1794,9 +1747,7 @@ ename(sym, val, impl)
* Process a single external declarator.
*/
void
-decl1ext(dsym, initflg)
- sym_t *dsym;
- int initflg;
+decl1ext(sym_t *dsym, int initflg)
{
int warn, rval, redec;
sym_t *rdsym;
@@ -1915,8 +1866,7 @@ decl1ext(dsym, initflg)
* the same symbol.
*/
void
-cpuinfo(sym, rdsym)
- sym_t *sym, *rdsym;
+cpuinfo(sym_t *sym, sym_t *rdsym)
{
sym->s_spos = rdsym->s_spos;
sym->s_upos = rdsym->s_upos;
@@ -1930,9 +1880,7 @@ cpuinfo(sym, rdsym)
* a warning.
*/
int
-isredec(dsym, warn)
- sym_t *dsym;
- int *warn;
+isredec(sym_t *dsym, int *warn)
{
sym_t *rsym;
@@ -2011,9 +1959,7 @@ isredec(dsym, warn)
* compatible with a prototype
*/
int
-eqtype(tp1, tp2, ignqual, promot, warn)
- type_t *tp1, *tp2;
- int ignqual, promot, *warn;
+eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int *warn)
{
tspec_t t;
@@ -2079,9 +2025,7 @@ eqtype(tp1, tp2, ignqual, promot, warn)
* Compares the parameter types of two prototypes.
*/
static int
-eqargs(tp1, tp2, warn)
- type_t *tp1, *tp2;
- int *warn;
+eqargs(type_t *tp1, type_t *tp2, int *warn)
{
sym_t *a1, *a2;
@@ -2115,9 +2059,7 @@ eqargs(tp1, tp2, warn)
* is applied on it
*/
static int
-mnoarg(tp, warn)
- type_t *tp;
- int *warn;
+mnoarg(type_t *tp, int *warn)
{
sym_t *arg;
tspec_t t;
@@ -2142,8 +2084,7 @@ mnoarg(tp, warn)
* a previous old style function definition.
*/
static int
-chkosdef(rdsym, dsym)
- sym_t *rdsym, *dsym;
+chkosdef(sym_t *rdsym, sym_t *dsym)
{
sym_t *args, *pargs, *arg, *parg;
int narg, nparg, n;
@@ -2204,8 +2145,7 @@ chkosdef(rdsym, dsym)
* be duplicated.
*/
void
-compltyp(dsym, ssym)
- sym_t *dsym, *ssym;
+compltyp(sym_t *dsym, sym_t *ssym)
{
type_t **dstp, *src;
type_t *dst;
@@ -2239,9 +2179,7 @@ compltyp(dsym, ssym)
* Completes the declaration of a single argument.
*/
sym_t *
-decl1arg(sym, initflg)
- sym_t *sym;
- int initflg;
+decl1arg(sym_t *sym, int initflg)
{
tspec_t t;
@@ -2305,7 +2243,7 @@ decl1arg(sym, initflg)
* prototype.
*/
void
-cluparg()
+cluparg(void)
{
sym_t *args, *arg, *pargs, *parg;
int narg, nparg, n, msg;
@@ -2430,8 +2368,7 @@ cluparg()
* Returns 1 if the position of the previous declaration should be reported.
*/
static int
-chkptdecl(arg, parg)
- sym_t *arg, *parg;
+chkptdecl(sym_t *arg, sym_t *parg)
{
type_t *tp, *ptp;
int warn, msg;
@@ -2464,9 +2401,7 @@ chkptdecl(arg, parg)
* Completes a single local declaration/definition.
*/
void
-decl1loc(dsym, initflg)
- sym_t *dsym;
- int initflg;
+decl1loc(sym_t *dsym, int initflg)
{
/* Correct a mistake done in dname(). */
if (dsym->s_type->t_tspec == FUNC) {
@@ -2606,8 +2541,7 @@ decl1loc(dsym, initflg)
* Processes (re)declarations of external Symbols inside blocks.
*/
static void
-ledecl(dsym)
- sym_t *dsym;
+ledecl(sym_t *dsym)
{
int eqt, warn;
sym_t *esym;
@@ -2662,8 +2596,7 @@ ledecl(dsym)
* detected.
*/
static int
-chkinit(sym)
- sym_t *sym;
+chkinit(sym_t *sym)
{
int err;
@@ -2694,7 +2627,7 @@ chkinit(sym)
* Create a symbole for an abstract declaration.
*/
sym_t *
-aname()
+aname(void)
{
sym_t *sym;
@@ -2722,7 +2655,7 @@ aname()
* Removes anything which has nothing to do on global level.
*/
void
-globclup()
+globclup(void)
{
while (dcs->d_nxt != NULL)
popdecl();
@@ -2742,8 +2675,7 @@ globclup()
* Process an abstract type declaration
*/
sym_t *
-decl1abs(sym)
- sym_t *sym;
+decl1abs(sym_t *sym)
{
chkfdef(sym, 1);
chktyp(sym);
@@ -2754,8 +2686,7 @@ decl1abs(sym)
* Checks size after declarations of variables and their initialisation.
*/
void
-chksz(dsym)
- sym_t *dsym;
+chksz(sym_t *dsym)
{
/*
* check size only for symbols which are defined and no function and
@@ -2783,8 +2714,7 @@ chksz(dsym)
* Mark an object as set if it is not already
*/
void
-setsflg(sym)
- sym_t *sym;
+setsflg(sym_t *sym)
{
if (!sym->s_set) {
sym->s_set = 1;
@@ -2796,9 +2726,7 @@ setsflg(sym)
* Mark an object as used if it is not already
*/
void
-setuflg(sym, fcall, szof)
- sym_t *sym;
- int fcall, szof;
+setuflg(sym_t *sym, int fcall, int szof)
{
if (!sym->s_used) {
sym->s_used = 1;
@@ -2820,8 +2748,7 @@ setuflg(sym, fcall, szof)
* with s_dlnxt) if these are not used or only set.
*/
void
-chkusage(di)
- dinfo_t *di;
+chkusage(dinfo_t *di)
{
sym_t *sym;
int mknowarn;
@@ -2841,9 +2768,7 @@ chkusage(di)
* only set.
*/
void
-chkusg1(novar, sym)
- int novar;
- sym_t *sym;
+chkusg1(int novar, sym_t *sym)
{
pos_t cpos;
@@ -2868,9 +2793,7 @@ chkusg1(novar, sym)
}
static void
-chkausg(novar, arg)
- int novar;
- sym_t *arg;
+chkausg(int novar, sym_t *arg)
{
if (!arg->s_set)
lerror("chkausg() 1");
@@ -2886,9 +2809,7 @@ chkausg(novar, arg)
}
static void
-chkvusg(novar, sym)
- int novar;
- sym_t *sym;
+chkvusg(int novar, sym_t *sym)
{
scl_t sc;
sym_t *xsym;
@@ -2955,8 +2876,7 @@ chkvusg(novar, sym)
}
static void
-chklusg(lab)
- sym_t *lab;
+chklusg(sym_t *lab)
{
if (blklev != 1 || lab->s_blklev != 1)
lerror("chklusg() 1");
@@ -2973,8 +2893,7 @@ chklusg(lab)
}
static void
-chktusg(sym)
- sym_t *sym;
+chktusg(sym_t *sym)
{
if (!incompl(sym->s_type))
return;
@@ -3011,7 +2930,7 @@ chktusg(sym)
* - static symbols which are never used
*/
void
-chkglsyms()
+chkglsyms(void)
{
sym_t *sym;
pos_t cpos;
@@ -3038,8 +2957,7 @@ chkglsyms()
}
static void
-chkglvar(sym)
- sym_t *sym;
+chkglvar(sym_t *sym)
{
if (sym->s_scl == TYPEDEF || sym->s_scl == ENUMCON)
return;
@@ -3085,8 +3003,7 @@ chkglvar(sym)
}
static void
-glchksz(sym)
- sym_t *sym;
+glchksz(sym_t *sym)
{
if (sym->s_def == TDEF) {
if (sym->s_type->t_tspec == FUNC)
@@ -3112,9 +3029,7 @@ glchksz(sym)
* Prints information about location of previous definition/declaration.
*/
void
-prevdecl(msg, psym)
- int msg;
- sym_t *psym;
+prevdecl(int msg, sym_t *psym)
{
pos_t cpos;