[hackers] [scc] [cc1] Warn in default int of k&r parameters || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 9 Mar 2017 06:43:58 +0100 (CET)

commit a0d7cc8700a2c88a9e5ac89fc0a542e3a6bb0ac9
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Mar 9 06:41:49 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Mar 9 06:41:49 2017 +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.

diff --git a/cc1/decl.c b/cc1/decl.c
index 0066589..a7973cf 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -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'",
_AT_@ -466,6 +465,7 @@ static int
 funbody(Symbol *sym, Symbol *pars[])
 {
         Type *tp;
+ Symbol **bp, *p;
 
         if (!sym)
                 return 0;
_AT_@ -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'");
Received on Thu Mar 09 2017 - 06:43:58 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 09 2017 - 06:48:20 CET