shithub: scc

Download patch

ref: d1ad7cfaec448eca408a0226f6b956cdddeee34c
parent: 05cbd37b24f18d713c5632cb2639bc38eaab13ec
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Aug 9 11:33:35 EDT 2016

[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).

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -118,13 +118,15 @@
 }
 
 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 @@
 		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 @@
 	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 @@
 	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 */