From: Nick Bowler Date: Mon, 19 Mar 2012 01:44:56 +0000 (-0400) Subject: Actually generate (void) function parameter lists in randomdecl. X-Git-Tag: v1~50 X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/commitdiff_plain/fc955dfd8cbcfd7a1a9570371381560cd0e9d73d Actually generate (void) function parameter lists in randomdecl. --- diff --git a/test/declgen.c b/test/declgen.c index d7bdbc1..3f4c394 100644 --- a/test/declgen.c +++ b/test/declgen.c @@ -337,6 +337,24 @@ static void gen_function(struct gen_rng *rng, struct cdecl_declarator *d) if (d->u.function.parameters) { d->u.function.variadic = gsl_rng_uniform(rng->rng) < 0.5; + } else if (gsl_rng_uniform(rng->rng) < 0.5) { + struct cdecl *param; + + /* We will never generate (void) above; do it here. */ + param = malloc_nofail(sizeof *param); + *param = (struct cdecl) { 0 }; + + param->declarators = malloc_nofail(sizeof *param->declarators); + *param->declarators = (struct cdecl_declarator) { + .type = CDECL_DECL_NULL, + }; + + param->specifiers = malloc_nofail(sizeof *param->specifiers); + *param->specifiers = (struct cdecl_declspec) { + .type = CDECL_TYPE_VOID, + }; + + d->u.function.parameters = param; } }