From: Nick Bowler Date: Sun, 18 Mar 2012 20:54:43 +0000 (-0400) Subject: Fix bogus switch cases in declgen. X-Git-Tag: v1~54 X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/commitdiff_plain/ddbdd8cec2a54faef7b3a25d998ba350ec026cfe Fix bogus switch cases in declgen. One of the switch statements in declgen has completely bogus case labels: '0', '1', ... instead of 0, 1, ... Fix this up and also add a default: assert(0); which would have caught this earlier. Improve the test case output when a randomdecl failure causes the test to fail. Also add a comment to the one switch statement in this file which intentionally does not have a default: assert(0). --- diff --git a/test/declgen.c b/test/declgen.c index 9c774ff..af7dd8d 100644 --- a/test/declgen.c +++ b/test/declgen.c @@ -178,6 +178,10 @@ retry: case CDECL_TYPE_IDENT: assert(!specs->next); specs->ident = gen_identifier(rng); + break; + default: + /* Nothing to be done. */ + ; } return specs; @@ -274,19 +278,21 @@ static void gen_array(struct gen_rng *rng, struct cdecl_declarator *d) d->u.array = (struct cdecl_array){0}; switch (gsl_rng_uniform_int(rng->rng, 4)) { - case '0': + case 0: d->u.array.vla = malloc_nofail(1); d->u.array.vla[0] = 0; break; - case '1': + case 1: d->u.array.vla = gen_identifier(rng); break; - case '2': + case 2: d->u.array.length = 0; break; - case '3': + case 3: d->u.array.length = gsl_rng_uniform_int(rng->rng, -1); break; + default: + assert(0); } } diff --git a/tests/crossparse-c-random.sh b/tests/crossparse-c-random.sh index 9fc45fb..a800f3f 100755 --- a/tests/crossparse-c-random.sh +++ b/tests/crossparse-c-random.sh @@ -72,6 +72,12 @@ eval_cmd=`exec 3>&1 } | proc >&3` eval "$eval_cmd" +if test x"$gen_status" != x"0"; then + printf '%s: %s failed with status=%d\n' \ + "$0" "$randomdecl" "$gen_status" 1>&2 + exit 1 +fi + expected_count=`expr "$TESTITER" + 0` if test x"$count" != x"$expected_count"; then printf '%s: failed after %d successful tests (out of %d)\n' \ @@ -79,5 +85,5 @@ if test x"$count" != x"$expected_count"; then exit 1 fi -test x"$result" = x"pass" && test x"$gen_status" = x"0" && exit 0 +test x"$result" = x"pass" && exit 0 exit 1