/*
* Generate random C declarations for testing.
- * Copyright © 2012, 2021-2022 Nick Bowler
+ * Copyright © 2012, 2021-2023 Nick Bowler
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
{
struct cdecl_declspec *s = NULL;
- while (test_rng_uniform(rng) < 0.5) {
+ while (test_rng_50_50(rng)) {
s = new_specifier(s);
switch (test_rng_uniform_int(rng, 2+restrictqual)) {
{
struct cdecl_declspec *s = NULL;
- while (test_rng_uniform(rng) < 0.5) {
+ while (test_rng_50_50(rng)) {
s = new_specifier(s);
s->type = CDECL_FUNC_INLINE;
}
{
struct cdecl_declspec *s;
- if (test_rng_uniform(rng) < 0.5)
+ if (test_rng_50_50(rng))
return NULL;
s = new_specifier(NULL);
d->type = CDECL_DECL_FUNCTION;
d->u.function.parameters = NULL;
- while (test_rng_uniform(rng) < 0.5) {
+ while (test_rng_50_50(rng)) {
unsigned flags = GEN_ONLY_REGISTER | GEN_NO_FUNCTION;
struct cdecl *param;
}
if (d->u.function.parameters) {
- d->u.function.variadic = test_rng_uniform(rng) < 0.5;
- } else if (test_rng_uniform(rng) < 0.5) {
+ d->u.function.variadic = test_rng_50_50(rng);
+ } else if (test_rng_50_50(rng)) {
struct cdecl *param;
/* We will never generate (void) above; do it here. */
unsigned limit = 3;
d = new_declarator(NULL);
- if (test_rng_uniform(rng) < 0.5) {
+ if (test_rng_50_50(rng)) {
d->type = CDECL_DECL_IDENT;
d->u.ident = gen_identifier(rng);
}
- while (test_rng_uniform(rng) < 0.5) {
+ while (test_rng_50_50(rng)) {
d = new_declarator((p = d));
switch (test_rng_uniform_int(rng, limit)) {