[hackers] [scc] [cc1] Do not warn about empty declarations in prototypes || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 9 Aug 2016 16:04:17 +0200 (CEST)

commit f49a4097676ab932f00cc302583df4e09f364691
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Aug 9 15:33:35 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Aug 9 15:51:03 2016 +0200

    [cc1] Do not warn about empty declarations in prototypes
    
    It is fine to have prototypes where parameters lack of a name,
    but the current form of the code was giving a warning about
    empty declarations. With this patch we still keep the extension
    of allowing anonymous parameters (the reallity is that it is
    eassier to keep this extension that fordib it :P).

diff --git a/cc1/decl.c b/cc1/decl.c
index 3609c17..20df8fd 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -118,13 +118,15 @@ arydcl(struct declarators *dp)
 }
 
 static int
-empty(Symbol *sym, Type *tp)
+empty(Symbol *sym, Type *tp, int param)
 {
         if (!sym->name) {
                 sym->type = tp;
                 switch (tp->op) {
                 default:
- warn("empty declaration");
+ /* warn if it is not a parameter */
+ if (!param)
+ warn("empty declaration");
                 case STRUCT:
                 case UNION:
                 case ENUM:
_AT_@ -175,7 +177,7 @@ parameter(struct decl *dcl)
                 errorp("incorrect function type for a function parameter");
                 return NULL;
         }
- if (!empty(sym, tp)) {
+ if (!empty(sym, tp, 1)) {
                 Symbol *p = install(NS_IDEN, sym);
                 if (!p && !(funtp->prop & TK_R)) {
                         errorp("redefinition of parameter '%s'", name);
_AT_@ -615,7 +617,7 @@ field(struct decl *dcl)
         TINT n = structp->n.elem;
         int err = 0;
 
- if (empty(sym, tp))
+ if (empty(sym, tp, 0))
                 return sym;
         if (tp->op == FTN) {
                 errorp("invalid type in struct/union");
_AT_@ -724,7 +726,7 @@ identifier(struct decl *dcl)
         int sclass = dcl->sclass;
         char *name = sym->name;
 
- if (empty(sym, tp))
+ if (empty(sym, tp, 0))
                 return sym;
 
         /* TODO: Add warning about ANSI limits */
Received on Tue Aug 09 2016 - 16:04:17 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 09 2016 - 16:12:18 CEST