]> git.draconx.ca Git - cdecl99.git/commitdiff
Actually generate (void) function parameter lists in randomdecl.
authorNick Bowler <nbowler@draconx.ca>
Mon, 19 Mar 2012 01:44:56 +0000 (21:44 -0400)
committerNick Bowler <nbowler@draconx.ca>
Mon, 19 Mar 2012 01:44:56 +0000 (21:44 -0400)
test/declgen.c

index d7bdbc1a40526c1262fa4b5dc908450b0f9dd739..3f4c3944f613c0c094ee070899a66639d5c8ae6f 100644 (file)
@@ -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;
        }
 }