ref: 2a5f32b8f028d8cfbc221bbccd6624f323de6825
parent: 563f6cff7bec0a6c084721d6a46bdd0e88d6d78c
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Mar 9 01:41:49 EST 2017
[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.
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -360,7 +360,6 @@
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 @@
funbody(Symbol *sym, Symbol *pars[])
{
Type *tp;
+ Symbol **bp, *p;
if (!sym)
return 0;
@@ -493,6 +493,12 @@
while (yytoken != '{') {
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)