commit f49a4097676ab932f00cc302583df4e09f364691
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Tue Aug 9 15:33:35 2016 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
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
@@ -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:
@@ -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);
@@ -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");
@@ -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 */

Reply via email to