commit a0d7cc8700a2c88a9e5ac89fc0a542e3a6bb0ac9
parent 6bc2930486765b080a04c22fdc380a1f985c67e9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 9 Mar 2017 06:41:49 +0100
[cc1] Warn in default int of k&r parameters
C99 removed the default int rule even in k&r parameter list,
but it allows to accept it after giving a warning.
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -360,7 +360,6 @@ krpars(Symbol *pars[], unsigned *nparsp)
do {
sym = yylval.sym;
expect(IDEN);
- sym->type = inttype;
sym->flags |= SAUTO;
if ((sym = install(NS_IDEN, sym)) == NULL) {
errorp("redefinition of parameter '%s'",
@@ -466,6 +465,7 @@ static int
funbody(Symbol *sym, Symbol *pars[])
{
Type *tp;
+ Symbol **bp, *p;
if (!sym)
return 0;
@@ -494,6 +494,12 @@ funbody(Symbol *sym, Symbol *pars[])
dodcl(REP, parameter, NS_IDEN, sym->type);
expect(';');
}
+ for (bp = pars; p = *bp; ++bp) {
+ if (p->type == NULL) {
+ warn("type of '%s' defaults to int", p->name);
+ p->type = inttype;
+ }
+ }
}
if (sym->flags & STYPEDEF)
errorp("function definition declared 'typedef'");