shithub: scc

Download patch

ref: 46304892ba34a7e74a604095bf375207d39e33f9
parent: a04925b020bd4f1a0bef424ddde7448d3bc5d670
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Nov 1 15:54:50 EDT 2021

cc1: Merge k&r and ansi function definitions

If a function is defined with a k&r prototype then it does not
collide with other ansi definitions.

--- a/src/cmd/cc/cc1/decl.c
+++ b/src/cmd/cc/cc1/decl.c
@@ -169,6 +169,16 @@
 	int flags;
 	char *name = sym->name;
 
+	if (sym->type->op == FTN && tp->op == FTN) {
+		Type *ntp = sym->type;
+		if (eqtype(ntp->type, tp->type, 1) {
+			if (tp->prop & TK_R)
+				tp = ntp;
+			if (sym->type->prop & TK_R)
+				sym->type = tp;
+		}
+	}
+
 	if (!eqtype(sym->type, tp, 1)) {
 		errorp("conflicting types for '%s'", name);
 		return sym;