]> git.draconx.ca Git - cdecl99.git/commitdiff
Don't generate invalid void function parameters in randomdecl.
authorNick Bowler <nbowler@draconx.ca>
Thu, 1 Mar 2012 01:29:58 +0000 (20:29 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 3 Mar 2012 03:33:32 +0000 (22:33 -0500)
Only parameters that are pointers or functions may have the "void" type
specifier.

This apparently doesn't come up often, so increase the default number of
test iterations to make it more likely.

test/declgen.c
tests/crossparse-c-random.sh

index b9fb733c94b67a5b2b0eefddb31f5fd8bd06a59d..ac9d23e9f185c0c19151837c43ba05ee57bc0cbb 100644 (file)
@@ -306,8 +306,8 @@ static void gen_function(struct gen_rng *rng, struct cdecl_declarator *d)
                        .declarators = gen_declarators(rng),
                };
 
-               if (param->declarators->type == CDECL_DECL_ARRAY
-                   || param->declarators->type == CDECL_DECL_IDENT)
+               if (param->declarators->type != CDECL_DECL_POINTER
+                   && param->declarators->type != CDECL_DECL_FUNCTION)
                        flags |= GEN_NO_VOID;
 
                param->specifiers = gen_declspecs(rng, flags);
index 03ec30f065037c80b9fa1b2f5b92dabefde95405..8fb1b633039d96d2bc39e66fcb9ed2014b5cb5d8 100755 (executable)
@@ -8,7 +8,7 @@
 # This is free software: you are free to do what the fuck you want to.
 # There is NO WARRANTY, to the extent permitted by law.
 
-: "${RANDOMSEED=$RANDOM}" "${TESTITER=100}"
+: "${RANDOMSEED=$RANDOM}" "${TESTITER=500}"
 
 randomdecl=test/randomdecl$EXEEXT
 crossparse=test/crossparse$EXEEXT
@@ -21,7 +21,10 @@ proc() {
        while read decl
        do
                count=`expr $count + 1`
-               $crossparse "$decl" || { result=fail; break; }
+               $crossparse "$decl" || { result=fail
+                       printf 'original input: %s\n' "$decl" 1>&2
+                       break
+                       }
        done
 
        echo "result=$result"