scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 8b555b36347c56f242c3c6e7c3c039ff48b84d28
parent 33b8acf5a29c62a275af1ea8209694ebd43660de
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon,  1 Nov 2021 19:54:50 +0100

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.

Diffstat:
Msrc/cmd/cc/cc1/decl.c | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/cmd/cc/cc1/decl.c b/src/cmd/cc/cc1/decl.c @@ -169,6 +169,16 @@ redcl(Symbol *sym, Type *tp, int sclass) 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;