Home
cc1: Improve wrong void detection - scc - simple c99 compiler HTML git clone git://git.simple-cc.org/scc DIR Log DIR Files DIR Refs DIR Submodules DIR README DIR LICENSE --- DIR commit be306281fac02e415d76081567520ffecad06adc DIR parent bbc13f1280dc042f22868c2565602f5b01c2873f HTML 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: M src/cmd/cc/cc1/decl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- DIR 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; }