prototypes override old style function definitions

this is a gnu extension to ansi c
This commit is contained in:
jpo 1995-10-02 17:21:24 +00:00
parent ef83266200
commit 6910cf7927
8 changed files with 117 additions and 130 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: decl.c,v 1.5 1995/10/02 17:18:57 jpo Exp $ */ /* $NetBSD: decl.c,v 1.6 1995/10/02 17:21:24 jpo Exp $ */
/* /*
* Copyright (c) 1994, 1995 Jochen Pohl * Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/ */
#ifndef lint #ifndef lint
static char rcsid[] = "$NetBSD: decl.c,v 1.5 1995/10/02 17:18:57 jpo Exp $"; static char rcsid[] = "$NetBSD: decl.c,v 1.6 1995/10/02 17:21:24 jpo Exp $";
#endif #endif
#include <sys/param.h> #include <sys/param.h>
@ -66,7 +66,7 @@ static void align __P((int, int));
static sym_t *newtag __P((sym_t *, scl_t, int, int)); static sym_t *newtag __P((sym_t *, scl_t, int, int));
static int eqargs __P((type_t *, type_t *, int *)); static int eqargs __P((type_t *, type_t *, int *));
static int mnoarg __P((type_t *, int *)); static int mnoarg __P((type_t *, int *));
static void chkosdef __P((sym_t *, sym_t *)); static int chkosdef __P((sym_t *, sym_t *));
static int chkptdecl __P((sym_t *, sym_t *)); static int chkptdecl __P((sym_t *, sym_t *));
static sym_t *nsfunc __P((sym_t *, sym_t *)); static sym_t *nsfunc __P((sym_t *, sym_t *));
static void osfunc __P((sym_t *, sym_t *)); static void osfunc __P((sym_t *, sym_t *));
@ -295,7 +295,7 @@ addscl(sc)
{ {
if (sc == INLINE) { if (sc == INLINE) {
/* syntax error */ /* syntax error */
gnuism(249); (void)gnuism(249);
if (dcs->d_inline) if (dcs->d_inline)
/* duplicate '%s' */ /* duplicate '%s' */
warning(10, "inline"); warning(10, "inline");
@ -380,6 +380,8 @@ addtype(tp)
/* "long long" or "long ... long" */ /* "long long" or "long ... long" */
t = QUAD; t = QUAD;
dcs->d_lmod = NOTSPEC; dcs->d_lmod = NOTSPEC;
/* %s C does not support 'long long' */
(void)gnuism(265, tflag ? "traditional" : "ANSI");
} }
if (dcs->d_type != NULL && dcs->d_type->t_typedef) { if (dcs->d_type != NULL && dcs->d_type->t_typedef) {
@ -1273,8 +1275,8 @@ addfunc(decl, args)
* The symbols are removed from the symbol table by popdecl() after * The symbols are removed from the symbol table by popdecl() after
* addfunc(). To be able to restore them if this is a function * addfunc(). To be able to restore them if this is a function
* definition, a pointer to the list of all symbols is stored in * definition, a pointer to the list of all symbols is stored in
* dcs->d_nxt->fpsyms. Also a list of the arguments (concatenated * dcs->d_nxt->d_fpsyms. Also a list of the arguments (concatenated
* by s_nxt) is stored in dcs->d_nxt->f_args. * by s_nxt) is stored in dcs->d_nxt->d_fargs.
* (dcs->d_nxt must be used because *dcs is the declaration stack * (dcs->d_nxt must be used because *dcs is the declaration stack
* element created for the list of params and is removed after * element created for the list of params and is removed after
* addfunc()) * addfunc())
@ -1632,13 +1634,13 @@ newtag(tag, scl, decl, semi)
if (tag->s_scl != scl) { if (tag->s_scl != scl) {
/* (%s) tag redeclared */ /* (%s) tag redeclared */
error(46, scltoa(tag->s_scl)); error(46, scltoa(tag->s_scl));
prevdecl(tag); prevdecl(-1, tag);
tag = pushdown(tag); tag = pushdown(tag);
dcs->d_nxt->d_nedecl = 1; dcs->d_nxt->d_nedecl = 1;
} else if (decl && !incompl(tag->s_type)) { } else if (decl && !incompl(tag->s_type)) {
/* (%s) tag redeclared */ /* (%s) tag redeclared */
error(46, scltoa(tag->s_scl)); error(46, scltoa(tag->s_scl));
prevdecl(tag); prevdecl(-1, tag);
tag = pushdown(tag); tag = pushdown(tag);
dcs->d_nxt->d_nedecl = 1; dcs->d_nxt->d_nedecl = 1;
} else if (semi || decl) { } else if (semi || decl) {
@ -1693,7 +1695,7 @@ compltag(tp, fmem)
sp->memb = fmem; sp->memb = fmem;
if (sp->size == 0) { if (sp->size == 0) {
/* zero sized %s */ /* zero sized %s */
gnuism(47, ttab[t].tt_name); (void)gnuism(47, ttab[t].tt_name);
} else { } else {
n = 0; n = 0;
for (mem = fmem; mem != NULL; mem = mem->s_nxt) { for (mem = fmem; mem != NULL; mem = mem->s_nxt) {
@ -1739,7 +1741,7 @@ ename(sym, val, impl)
* declaration * declaration
*/ */
if (blklev == 0) if (blklev == 0)
prevdecl(sym); prevdecl(-1, sym);
} }
} else { } else {
if (hflag) if (hflag)
@ -1768,7 +1770,7 @@ decl1ext(dsym, initflg)
sym_t *dsym; sym_t *dsym;
int initflg; int initflg;
{ {
int warn, rval; int warn, rval, redec;
sym_t *rdsym; sym_t *rdsym;
chkfdef(dsym, 1); chkfdef(dsym, 1);
@ -1803,7 +1805,7 @@ decl1ext(dsym, initflg)
* written as a function definition to the output file. * written as a function definition to the output file.
*/ */
rval = dsym->s_type->t_subt->t_tspec != VOID; rval = dsym->s_type->t_subt->t_tspec != VOID;
outfdef(dsym, dsym->s_type, &dsym->s_dpos, rval, 0, NULL); outfdef(dsym, &dsym->s_dpos, rval, 0, NULL);
} else { } else {
outsym(dsym, dsym->s_scl, dsym->s_def); outsym(dsym, dsym->s_scl, dsym->s_def);
} }
@ -1815,15 +1817,18 @@ decl1ext(dsym, initflg)
* we have remembered the params in rdsmy->s_args and compare * we have remembered the params in rdsmy->s_args and compare
* them with the params of the prototype. * them with the params of the prototype.
*/ */
if (rdsym->s_osdef && dsym->s_type->t_proto) if (rdsym->s_osdef && dsym->s_type->t_proto) {
chkosdef(rdsym, dsym); redec = chkosdef(rdsym, dsym);
} else {
redec = 0;
}
if (!isredec(dsym, (warn = 0, &warn))) { if (!redec && !isredec(dsym, (warn = 0, &warn))) {
if (warn) { if (warn) {
/* redeclaration of %s */ /* redeclaration of %s */
warning(27, dsym->s_name); (*(sflag ? error : warning))(27, dsym->s_name);
prevdecl(rdsym); prevdecl(-1, rdsym);
} }
/* /*
@ -1906,31 +1911,31 @@ isredec(dsym, warn)
if ((rsym = dcs->d_rdcsym)->s_scl == ENUMCON) { if ((rsym = dcs->d_rdcsym)->s_scl == ENUMCON) {
/* redeclaration of %s */ /* redeclaration of %s */
error(27, dsym->s_name); error(27, dsym->s_name);
prevdecl(rsym); prevdecl(-1, rsym);
return (1); return (1);
} }
if (rsym->s_scl == TYPEDEF) { if (rsym->s_scl == TYPEDEF) {
/* typedef redeclared: %s */ /* typedef redeclared: %s */
error(89, dsym->s_name); error(89, dsym->s_name);
prevdecl(rsym); prevdecl(-1, rsym);
return (1); return (1);
} }
if (dsym->s_scl == TYPEDEF) { if (dsym->s_scl == TYPEDEF) {
/* redeclaration of %s */ /* redeclaration of %s */
error(27, dsym->s_name); error(27, dsym->s_name);
prevdecl(rsym); prevdecl(-1, rsym);
return (1); return (1);
} }
if (rsym->s_def == DEF && dsym->s_def == DEF) { if (rsym->s_def == DEF && dsym->s_def == DEF) {
/* redefinition of %s */ /* redefinition of %s */
error(28, dsym->s_name); error(28, dsym->s_name);
prevdecl(rsym); prevdecl(-1, rsym);
return(1); return(1);
} }
if (!eqtype(rsym->s_type, dsym->s_type, 0, 0, warn)) { if (!eqtype(rsym->s_type, dsym->s_type, 0, 0, warn)) {
/* redeclaration of %s */ /* redeclaration of %s */
error(27, dsym->s_name); error(27, dsym->s_name);
prevdecl(rsym); prevdecl(-1, rsym);
return(1); return(1);
} }
if (rsym->s_scl == EXTERN && dsym->s_scl == EXTERN) if (rsym->s_scl == EXTERN && dsym->s_scl == EXTERN)
@ -1946,13 +1951,13 @@ isredec(dsym, warn)
*/ */
/* redeclaration of %s */ /* redeclaration of %s */
error(27, dsym->s_name); error(27, dsym->s_name);
prevdecl(rsym); prevdecl(-1, rsym);
return(1); return(1);
} }
if (rsym->s_scl == EXTERN) { if (rsym->s_scl == EXTERN) {
/* previously declared extern, becomes static: %s */ /* previously declared extern, becomes static: %s */
warning(29, dsym->s_name); warning(29, dsym->s_name);
prevdecl(rsym); prevdecl(-1, rsym);
return(0); return(0);
} }
/* /*
@ -1962,7 +1967,7 @@ isredec(dsym, warn)
/* redeclaration of %s; ANSI C requires "static" */ /* redeclaration of %s; ANSI C requires "static" */
if (sflag) { if (sflag) {
warning(30, dsym->s_name); warning(30, dsym->s_name);
prevdecl(rsym); prevdecl(-1, rsym);
} }
dsym->s_scl = STATIC; dsym->s_scl = STATIC;
return (0); return (0);
@ -2043,9 +2048,7 @@ eqtype(tp1, tp2, ignqual, promot, warn)
} }
/* /*
* Compares the parameters types of two prototypes. * Compares the parameter types of two prototypes.
*
* It seams to be usual to ignore type qualifiers of the parameters.
*/ */
static int static int
eqargs(tp1, tp2, warn) eqargs(tp1, tp2, warn)
@ -2092,21 +2095,15 @@ mnoarg(tp, warn)
tspec_t t; tspec_t t;
if (tp->t_vararg) { if (tp->t_vararg) {
if (sflag) { if (warn != NULL)
return (0);
} else if (warn != NULL) {
*warn = 1; *warn = 1;
}
} }
for (arg = tp->t_args; arg != NULL; arg = arg->s_nxt) { for (arg = tp->t_args; arg != NULL; arg = arg->s_nxt) {
if ((t = arg->s_type->t_tspec) == FLOAT || if ((t = arg->s_type->t_tspec) == FLOAT ||
t == CHAR || t == SCHAR || t == UCHAR || t == CHAR || t == SCHAR || t == UCHAR ||
t == SHORT || t == USHORT) { t == SHORT || t == USHORT) {
if (sflag) { if (warn != NULL)
return (0);
} else if (warn != NULL) {
*warn = 1; *warn = 1;
}
} }
} }
return (1); return (1);
@ -2116,19 +2113,19 @@ mnoarg(tp, warn)
* Compares a prototype declaration with the remembered arguments of * Compares a prototype declaration with the remembered arguments of
* a previous old style function definition. * a previous old style function definition.
*/ */
static void static int
chkosdef(rdsym, dsym) chkosdef(rdsym, dsym)
sym_t *rdsym, *dsym; sym_t *rdsym, *dsym;
{ {
sym_t *args, *pargs, *arg, *parg; sym_t *args, *pargs, *arg, *parg;
int narg, nparg, n; int narg, nparg, n;
int warn, ptpos; int warn, msg;
pos_t cpos; pos_t cpos;
args = rdsym->s_args; args = rdsym->s_args;
pargs = dsym->s_type->t_args; pargs = dsym->s_type->t_args;
ptpos = 0; msg = 0;
narg = nparg = 0; narg = nparg = 0;
for (arg = args; arg != NULL; arg = arg->s_nxt) for (arg = args; arg != NULL; arg = arg->s_nxt)
@ -2138,7 +2135,7 @@ chkosdef(rdsym, dsym)
if (narg != nparg) { if (narg != nparg) {
/* prototype does not match old-style definition */ /* prototype does not match old-style definition */
error(63); error(63);
ptpos = 1; msg = 1;
goto end; goto end;
} }
@ -2151,14 +2148,10 @@ chkosdef(rdsym, dsym)
* If it does not match due to promotion and sflag is * If it does not match due to promotion and sflag is
* not set we print only a warning. * not set we print only a warning.
*/ */
if (!eqtype(arg->s_type, parg->s_type, 1, 1, &warn)) { if (!eqtype(arg->s_type, parg->s_type, 1, 1, &warn) || warn) {
/* prototype does not match old-style def., arg #%d */ /* prototype does not match old-style def., arg #%d */
error(299, n); error(299, n);
ptpos = 1; msg = 1;
} else if (warn) {
/* prototype does not match old-style def., arg #%d */
warning(299, n);
ptpos = 1;
} }
arg = arg->s_nxt; arg = arg->s_nxt;
parg = parg->s_nxt; parg = parg->s_nxt;
@ -2166,21 +2159,10 @@ chkosdef(rdsym, dsym)
} }
end: end:
if (ptpos && rflag) { if (msg)
/* prevdecl(-1, rdsym);
* print position only if it will not be printed by a
* complaint about redeclaration return (msg);
*/
warn = 0;
if (eqtype(rdsym->s_type, dsym->s_type, 0, 0, &warn) &&
warn == 0) {
STRUCT_ASSIGN(cpos, curr_pos);
STRUCT_ASSIGN(curr_pos, rdsym->s_dpos);
/* old style definition */
message(300);
STRUCT_ASSIGN(curr_pos, cpos);
}
}
} }
/* /*
@ -2298,8 +2280,7 @@ void
cluparg() cluparg()
{ {
sym_t *args, *arg, *pargs, *parg; sym_t *args, *arg, *pargs, *parg;
int narg, nparg, n; int narg, nparg, n, msg;
int ptpos;
pos_t cpos; pos_t cpos;
tspec_t t; tspec_t t;
@ -2351,7 +2332,9 @@ cluparg()
} }
if (prflstrg != -1 || scflstrg != -1) { if (prflstrg != -1 || scflstrg != -1) {
narg = prflstrg != -1 ? prflstrg : scflstrg; narg = prflstrg != -1 ? prflstrg : scflstrg;
for (arg = dcs->d_fargs, n = 1; n < narg; arg = arg->s_nxt, n++); arg = dcs->d_fargs;
for (n = 1; n < narg; n++)
arg = arg->s_nxt;
if (arg->s_type->t_tspec != PTR || if (arg->s_type->t_tspec != PTR ||
((t = arg->s_type->t_subt->t_tspec) != CHAR && ((t = arg->s_type->t_subt->t_tspec) != CHAR &&
t != UCHAR && t != SCHAR)) { t != UCHAR && t != SCHAR)) {
@ -2384,7 +2367,7 @@ cluparg()
* continue. * continue.
*/ */
narg = nparg = 0; narg = nparg = 0;
ptpos = 0; msg = 0;
for (parg = pargs; parg != NULL; parg = parg->s_nxt) for (parg = pargs; parg != NULL; parg = parg->s_nxt)
nparg++; nparg++;
for (arg = args; arg != NULL; arg = arg->s_nxt) for (arg = args; arg != NULL; arg = arg->s_nxt)
@ -2392,23 +2375,24 @@ cluparg()
if (narg != nparg) { if (narg != nparg) {
/* parameter mismatch: %d declared, %d defined */ /* parameter mismatch: %d declared, %d defined */
error(51, nparg, narg); error(51, nparg, narg);
ptpos = 1; msg = 1;
} else { } else {
parg = pargs; parg = pargs;
arg = args; arg = args;
while (narg--) { while (narg--) {
ptpos |= chkptdecl(arg, parg); msg |= chkptdecl(arg, parg);
parg = parg->s_nxt; parg = parg->s_nxt;
arg = arg->s_nxt; arg = arg->s_nxt;
} }
} }
if (ptpos && rflag) { if (msg)
STRUCT_ASSIGN(cpos, curr_pos);
STRUCT_ASSIGN(curr_pos, dcs->d_rdcsym->s_dpos);
/* prototype declaration */ /* prototype declaration */
message(285); prevdecl(285, dcs->d_rdcsym);
STRUCT_ASSIGN(curr_pos, cpos);
} /* from now the prototype is valid */
funcsym->s_osdef = 0;
funcsym->s_args = NULL;
} }
} }
@ -2423,21 +2407,30 @@ chkptdecl(arg, parg)
sym_t *arg, *parg; sym_t *arg, *parg;
{ {
type_t *tp, *ptp; type_t *tp, *ptp;
int warn; int warn, msg;
tp = arg->s_type; tp = arg->s_type;
ptp = parg->s_type; ptp = parg->s_type;
if (!eqtype(tp, ptp, 1, 1, (warn = 0, &warn))) { msg = 0;
/* type does not match prototype: %s */ warn = 0;
error(58, arg->s_name);
return (1); if (!eqtype(tp, ptp, 1, 1, &warn)) {
if (eqtype(tp, ptp, 1, 0, &warn)) {
/* type does not match prototype: %s */
msg = gnuism(58, arg->s_name);
} else {
/* type does not match prototype: %s */
error(58, arg->s_name);
msg = 1;
}
} else if (warn) { } else if (warn) {
/* type does not match prototype: %s */ /* type does not match prototype: %s */
warning(58, arg->s_name); (*(sflag ? error : warning))(58, arg->s_name);
return (1); msg = 1;
} }
return (0);
return (msg);
} }
/* /*
@ -2601,7 +2594,7 @@ ledecl(dsym)
/* gcc accepts this without a warning, pcc prints an error. */ /* gcc accepts this without a warning, pcc prints an error. */
/* redeclaration of %s */ /* redeclaration of %s */
warning(27, dsym->s_name); warning(27, dsym->s_name);
prevdecl(esym); prevdecl(-1, esym);
return; return;
} }
@ -2612,11 +2605,11 @@ ledecl(dsym)
if (esym->s_scl == EXTERN) { if (esym->s_scl == EXTERN) {
/* inconsistent redeclaration of extern: %s */ /* inconsistent redeclaration of extern: %s */
warning(90, dsym->s_name); warning(90, dsym->s_name);
prevdecl(esym); prevdecl(-1, esym);
} else { } else {
/* inconsistent redeclaration of static: %s */ /* inconsistent redeclaration of static: %s */
warning(92, dsym->s_name); warning(92, dsym->s_name);
prevdecl(esym); prevdecl(-1, esym);
} }
} }
@ -3076,7 +3069,8 @@ glchksz(sym)
* Prints information about location of previous definition/declaration. * Prints information about location of previous definition/declaration.
*/ */
void void
prevdecl(psym) prevdecl(msg, psym)
int msg;
sym_t *psym; sym_t *psym;
{ {
pos_t cpos; pos_t cpos;
@ -3086,7 +3080,9 @@ prevdecl(psym)
STRUCT_ASSIGN(cpos, curr_pos); STRUCT_ASSIGN(cpos, curr_pos);
STRUCT_ASSIGN(curr_pos, psym->s_dpos); STRUCT_ASSIGN(curr_pos, psym->s_dpos);
if (psym->s_def == DEF || psym->s_def == TDEF) { if (msg != -1) {
message(msg, psym->s_name);
} else if (psym->s_def == DEF || psym->s_def == TDEF) {
/* previous definition of %s */ /* previous definition of %s */
message(261, psym->s_name); message(261, psym->s_name);
} else { } else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: emit1.c,v 1.3 1995/10/02 17:14:14 jpo Exp $ */ /* $NetBSD: emit1.c,v 1.4 1995/10/02 17:21:28 jpo Exp $ */
/* /*
* Copyright (c) 1994, 1995 Jochen Pohl * Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/ */
#ifndef lint #ifndef lint
static char rcsid[] = "$NetBSD: emit1.c,v 1.3 1995/10/02 17:14:14 jpo Exp $"; static char rcsid[] = "$NetBSD: emit1.c,v 1.4 1995/10/02 17:21:28 jpo Exp $";
#endif #endif
#include <ctype.h> #include <ctype.h>
@ -277,9 +277,8 @@ outsym(sym, sc, def)
* they are called with proper argument types * they are called with proper argument types
*/ */
void void
outfdef(fsym, tp, posp, rval, osdef, args) outfdef(fsym, posp, rval, osdef, args)
sym_t *fsym, *args; sym_t *fsym, *args;
type_t *tp;
pos_t *posp; pos_t *posp;
int rval, osdef; int rval, osdef;
{ {
@ -362,9 +361,9 @@ outfdef(fsym, tp, posp, rval, osdef, args)
outint(narg); outint(narg);
for (arg = args; arg != NULL; arg = arg->s_nxt) for (arg = args; arg != NULL; arg = arg->s_nxt)
outtype(arg->s_type); outtype(arg->s_type);
outtype(tp->t_subt); outtype(fsym->s_type->t_subt);
} else { } else {
outtype(tp); outtype(fsym->s_type);
} }
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.4 1995/10/02 17:19:01 jpo Exp $ */ /* $NetBSD: err.c,v 1.5 1995/10/02 17:21:30 jpo Exp $ */
/* /*
* Copyright (c) 1994, 1995 Jochen Pohl * Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/ */
#ifndef lint #ifndef lint
static char rcsid[] = "$NetBSD: err.c,v 1.4 1995/10/02 17:19:01 jpo Exp $"; static char rcsid[] = "$NetBSD: err.c,v 1.5 1995/10/02 17:21:30 jpo Exp $";
#endif #endif
/* number of errors found */ /* number of errors found */
@ -321,7 +321,7 @@ const char *msgs[] = {
"\\\" inside character constants undefined in traditional C", /* 262 */ "\\\" inside character constants undefined in traditional C", /* 262 */
"\\? undefined in traditional C", /* 263 */ "\\? undefined in traditional C", /* 263 */
"\\v undefined in traditional C", /* 264 */ "\\v undefined in traditional C", /* 264 */
"", /* 265 */ "%s C does not support 'long long'", /* 265 */
"'long double' is illegal in traditional C", /* 266 */ "'long double' is illegal in traditional C", /* 266 */
"shift equal to size of object", /* 267 */ "shift equal to size of object", /* 267 */
"variable declared inline: %s", /* 268 */ "variable declared inline: %s", /* 268 */
@ -511,7 +511,7 @@ message(n, va_alist)
va_end(ap); va_end(ap);
} }
void int
#ifdef __STDC__ #ifdef __STDC__
gnuism(int n, ...) gnuism(int n, ...)
#else #else
@ -521,6 +521,7 @@ gnuism(n, va_alist)
#endif #endif
{ {
va_list ap; va_list ap;
int msg;
#ifdef __STDC__ #ifdef __STDC__
va_start(ap, n); va_start(ap, n);
@ -529,8 +530,14 @@ gnuism(n, va_alist)
#endif #endif
if (sflag && !gflag) { if (sflag && !gflag) {
verror(n, ap); verror(n, ap);
} else if (!(!sflag && gflag)) { msg = 1;
} else if (!sflag && gflag) {
msg = 0;
} else {
vwarning(n, ap); vwarning(n, ap);
msg = 1;
} }
va_end(ap); va_end(ap);
return (msg);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: externs1.h,v 1.3 1995/10/02 17:14:22 jpo Exp $ */ /* $NetBSD: externs1.h,v 1.4 1995/10/02 17:21:33 jpo Exp $ */
/* /*
* Copyright (c) 1994, 1995 Jochen Pohl * Copyright (c) 1994, 1995 Jochen Pohl
@ -115,7 +115,7 @@ extern const char *msgs[];
extern void error __P((int, ...)); extern void error __P((int, ...));
extern void warning __P((int, ...)); extern void warning __P((int, ...));
extern void message __P((int, ...)); extern void message __P((int, ...));
extern void gnuism __P((int, ...)); extern int gnuism __P((int, ...));
extern void lerror __P((const char *, ...)); extern void lerror __P((const char *, ...));
/* /*
@ -172,7 +172,7 @@ extern void setuflg __P((sym_t *, int, int));
extern void chkusage __P((sym_t *)); extern void chkusage __P((sym_t *));
extern void chkusg1 __P((sym_t *)); extern void chkusg1 __P((sym_t *));
extern void chkglsyms __P((void)); extern void chkglsyms __P((void));
extern void prevdecl __P((sym_t *)); extern void prevdecl __P((int, sym_t *));
/* /*
* tree.c * tree.c
@ -272,6 +272,6 @@ extern void mkinit __P((tnode_t *));
extern void outtype __P((type_t *)); extern void outtype __P((type_t *));
extern const char *ttos __P((type_t *)); extern const char *ttos __P((type_t *));
extern void outsym __P((sym_t *, scl_t, def_t)); extern void outsym __P((sym_t *, scl_t, def_t));
extern void outfdef __P((sym_t *, type_t *, pos_t *, int, int, sym_t *)); extern void outfdef __P((sym_t *, pos_t *, int, int, sym_t *));
extern void outcall __P((tnode_t *, int, int)); extern void outcall __P((tnode_t *, int, int));
extern void outusg __P((sym_t *)); extern void outusg __P((sym_t *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: func.c,v 1.4 1995/10/02 17:14:26 jpo Exp $ */ /* $NetBSD: func.c,v 1.5 1995/10/02 17:21:35 jpo Exp $ */
/* /*
* Copyright (c) 1994, 1995 Jochen Pohl * Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/ */
#ifndef lint #ifndef lint
static char rcsid[] = "$NetBSD: func.c,v 1.4 1995/10/02 17:14:26 jpo Exp $"; static char rcsid[] = "$NetBSD: func.c,v 1.5 1995/10/02 17:21:35 jpo Exp $";
#endif #endif
#include <stdlib.h> #include <stdlib.h>
@ -264,14 +264,6 @@ funcdef(fsym)
n++; n++;
} }
/*
* Remember the type before it is completet with previous
* declarations. We need it at the end of the function when
* the record for the function definition is written to the
* output file.
*/
dcs->d_ftype = fsym->s_type;
/* /*
* We must also remember the position. s_dpos is overwritten * We must also remember the position. s_dpos is overwritten
* if this is an old style definition and we had already a * if this is an old style definition and we had already a
@ -284,14 +276,14 @@ funcdef(fsym)
if (!isredec(fsym, (warn = 0, &warn))) { if (!isredec(fsym, (warn = 0, &warn))) {
/* /*
* Print no warning if the newly defined function * Print nothing if the newly defined function
* is defined in old style. A better warning will * is defined in old style. A better warning will
* be printed in cluparg(). * be printed in cluparg().
*/ */
if (warn && !fsym->s_osdef) { if (warn && !fsym->s_osdef) {
/* redeclaration of %s */ /* redeclaration of %s */
warning(27, fsym->s_name); (*(sflag ? error : warning))(27, fsym->s_name);
prevdecl(rdsym); prevdecl(-1, rdsym);
} }
/* copy usage information */ /* copy usage information */
@ -378,16 +370,10 @@ funcend()
if (dcs->d_scl == EXTERN && funcsym->s_inline) { if (dcs->d_scl == EXTERN && funcsym->s_inline) {
outsym(funcsym, funcsym->s_scl, DECL); outsym(funcsym, funcsym->s_scl, DECL);
} else { } else {
outfdef(funcsym, dcs->d_ftype, &dcs->d_fdpos, cstk->c_retval, outfdef(funcsym, &dcs->d_fdpos, cstk->c_retval,
funcsym->s_osdef, dcs->d_fargs); funcsym->s_osdef, dcs->d_fargs);
} }
if (funcsym->s_type->t_proto) {
/* from now the prototype is valid */
funcsym->s_osdef = 0;
funcsym->s_args = NULL;
}
/* /*
* remove all symbols declared during argument declaration from * remove all symbols declared during argument declaration from
* the symbol table * the symbol table

View File

@ -1,4 +1,4 @@
/* $NetBSD: init.c,v 1.3 1995/10/02 17:14:31 jpo Exp $ */ /* $NetBSD: init.c,v 1.4 1995/10/02 17:21:37 jpo Exp $ */
/* /*
* Copyright (c) 1994, 1995 Jochen Pohl * Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/ */
#ifndef lint #ifndef lint
static char rcsid[] = "$NetBSD: init.c,v 1.3 1995/10/02 17:14:31 jpo Exp $"; static char rcsid[] = "$NetBSD: init.c,v 1.4 1995/10/02 17:21:37 jpo Exp $";
#endif #endif
#include <stdlib.h> #include <stdlib.h>
@ -432,7 +432,7 @@ mkinit(tn)
if (conaddr(tn, &sym, &offs) == -1) { if (conaddr(tn, &sym, &offs) == -1) {
if (sc == AUTO || sc == REG) { if (sc == AUTO || sc == REG) {
/* non-constant initializer */ /* non-constant initializer */
gnuism(177); (void)gnuism(177);
} else { } else {
/* non-constant initializer */ /* non-constant initializer */
error(177); error(177);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lint1.h,v 1.4 1995/10/02 17:14:35 jpo Exp $ */ /* $NetBSD: lint1.h,v 1.5 1995/10/02 17:21:39 jpo Exp $ */
/* /*
* Copyright (c) 1994, 1995 Jochen Pohl * Copyright (c) 1994, 1995 Jochen Pohl
@ -311,7 +311,6 @@ typedef struct dinfo {
u_int d_notyp : 1; /* set if no type specifier was present */ u_int d_notyp : 1; /* set if no type specifier was present */
type_t *d_tagtyp; /* tag during member declaration */ type_t *d_tagtyp; /* tag during member declaration */
sym_t *d_fargs; /* list of arguments during function def. */ sym_t *d_fargs; /* list of arguments during function def. */
type_t *d_ftype; /* type as specified in function def. */
pos_t d_fdpos; /* position of function definition */ pos_t d_fdpos; /* position of function definition */
sym_t *d_dlsyms; /* first symbol declared at this level */ sym_t *d_dlsyms; /* first symbol declared at this level */
sym_t **d_ldlsym; /* points to s_dlnxt in last symbol decl. sym_t **d_ldlsym; /* points to s_dlnxt in last symbol decl.

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.5 1995/10/02 17:14:44 jpo Exp $ */ /* $NetBSD: tree.c,v 1.6 1995/10/02 17:21:42 jpo Exp $ */
/* /*
* Copyright (c) 1994, 1995 Jochen Pohl * Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/ */
#ifndef lint #ifndef lint
static char rcsid[] = "$NetBSD: tree.c,v 1.5 1995/10/02 17:14:44 jpo Exp $"; static char rcsid[] = "$NetBSD: tree.c,v 1.6 1995/10/02 17:21:42 jpo Exp $";
#endif #endif
#include <stdlib.h> #include <stdlib.h>
@ -730,7 +730,7 @@ cconv(tn)
if (!tn->tn_lvalue) { if (!tn->tn_lvalue) {
/* %soperand of '%s' must be lvalue */ /* %soperand of '%s' must be lvalue */
/* XXX print correct operator */ /* XXX print correct operator */
gnuism(114, "", modtab[AMPER].m_name); (void)gnuism(114, "", modtab[AMPER].m_name);
} }
tn = mktnode(AMPER, tincref(tn->tn_type->t_subt, PTR), tn = mktnode(AMPER, tincref(tn->tn_type->t_subt, PTR),
tn, NULL); tn, NULL);
@ -2622,7 +2622,7 @@ plength(tp)
break; break;
case VOID: case VOID:
/* cannot do pointer arithmetic on operand of ... */ /* cannot do pointer arithmetic on operand of ... */
gnuism(136); (void)gnuism(136);
break; break;
case STRUCT: case STRUCT:
case UNION: case UNION: