scc

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

commit be306281fac02e415d76081567520ffecad06adc
parent bbc13f1280dc042f22868c2565602f5b01c2873f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 16 Oct 2024 10:46:21 +0200

cc1: Improve wrong void detection

In case of appearing must be the first and only parameter of
the prototype, and while the code had checks for it, they were
wrong and they were failling in the majority of cases.

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

diff --git a/src/cmd/cc/cc1/decl.c b/src/cmd/cc/cc1/decl.c @@ -449,8 +449,7 @@ ansifun(struct declarators *dp) sym = NULL; tp = ellipsistype; } else if ((sym = dodcl(NOREP, parameter, NS_IDEN, &type)) == NULL) { - if (type.n.elem == 1 && ntype > 1) - voidpar = 1; + voidpar = 1; sym = NULL; tp = NULL; } else { @@ -480,7 +479,7 @@ ansifun(struct declarators *dp) if (toomany == 1) errorp("too many parameters in function definition"); - if (voidpar && ntype > 1) + if (voidpar && ntype > 0) errorp("'void' must be the only parameter"); return ntype; }