commit f49a4097676ab932f00cc302583df4e09f364691
parent 6957ea7d188f40a31b98ac98d304673346199282
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 9 Aug 2016 15:33:35 +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).
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git 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 */