scc

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

commit 46304892ba34a7e74a604095bf375207d39e33f9
parent a04925b020bd4f1a0bef424ddde7448d3bc5d670
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;