This C99 syntax is now almost entirely contained to test programs;
at this point using such syntax is just an obstacle to a successful
build rather than anything useful.
It is now possible to build with gcc in C89 mode, and probably some
other pre-C99 compilers.
One annoyance is the reference code for the RNG uses such declarations.
We avoid changing the reference code and instead arrange for the test
to be skipped unless compiler support is available.
-Subproject commit ed04bed43efece46d2b476fbb0260f1d1b8aa1fe
+Subproject commit 6405aa895740d960d6f6e70976eeb44bd403f952
AC_HEADER_ASSERT
AC_C_FLEXIBLE_ARRAY_MEMBER
AC_HEADER_ASSERT
AC_C_FLEXIBLE_ARRAY_MEMBER
+AC_C_INLINE
+DX_C_FOR_DECLARATIONS
+
+LT_INIT
+gl_INIT
# Work around quoting bug in Gnulib threadlib.m4 which prevents
# correct detection on e.g., Solaris 8. These platforms require
# Work around quoting bug in Gnulib threadlib.m4 which prevents
# correct detection on e.g., Solaris 8. These platforms require
*/
static int valid_typespec(struct cdecl_declspec *s)
{
*/
static int valid_typespec(struct cdecl_declspec *s)
{
+ struct cdecl_declspec *c;
- for (struct cdecl_declspec *c = s; c; c = c->next) {
+ for (c = s; c; c = c->next) {
unsigned long bit;
if (cdecl_spec_kind(c) != CDECL_SPEC_TYPE)
unsigned long bit;
if (cdecl_spec_kind(c) != CDECL_SPEC_TYPE)
*/
static bool valid_declspecs(struct cdecl *decl, bool top)
{
*/
static bool valid_declspecs(struct cdecl *decl, bool top)
{
- struct cdecl_declspec *specs = decl->specifiers;
+ struct cdecl_declspec *c, *specs = decl->specifiers;
struct cdecl_declarator *d = decl->declarators;
bool abstract = cdecl_is_abstract(d);
unsigned num_storage = 0;
struct cdecl_declarator *d = decl->declarators;
bool abstract = cdecl_is_abstract(d);
unsigned num_storage = 0;
if (!valid_typespec(specs))
return false;
if (!valid_typespec(specs))
return false;
- for (struct cdecl_declspec *c = specs; c; c = c->next) {
+ for (c = specs; c; c = c->next) {
switch (cdecl_spec_kind(c)) {
case CDECL_SPEC_TYPE:
if (c->type == CDECL_TYPE_VOID &&
switch (cdecl_spec_kind(c)) {
case CDECL_SPEC_TYPE:
if (c->type == CDECL_TYPE_VOID &&
{
int opt, mode = MODE_CDECL;
int ret = EXIT_SUCCESS;
{
int opt, mode = MODE_CDECL;
int ret = EXIT_SUCCESS;
const char *filename = NULL;
FILE *infile = NULL;
const char *filename = NULL;
FILE *infile = NULL;
free(line);
fclose(infile);
} else if (argv[optind]) {
free(line);
fclose(infile);
} else if (argv[optind]) {
- for (int i = optind; i < argc; i++) {
+ for (i = optind; i < argc; i++) {
if (!test_crossparse(argv[i], mode))
ret = EXIT_FAILURE;
}
if (!test_crossparse(argv[i], mode))
ret = EXIT_FAILURE;
}
char *gen_identifier(struct test_rng *rng)
{
static const char valid[59] = "_bcdefghijklmpqrsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
char *gen_identifier(struct test_rng *rng)
{
static const char valid[59] = "_bcdefghijklmpqrsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
n = test_rng_uniform_int(rng, 10)+1;
str = malloc_nofail(n+1);
/* Exclude 10 digits from the first character. */
str[0] = valid[test_rng_uniform_int(rng, sizeof valid - 10)];
n = test_rng_uniform_int(rng, 10)+1;
str = malloc_nofail(n+1);
/* Exclude 10 digits from the first character. */
str[0] = valid[test_rng_uniform_int(rng, sizeof valid - 10)];
- for (size_t i = 1; i < n; i++)
+ for (i = 1; i < n; i++)
str[i] = valid[test_rng_uniform_int(rng, sizeof valid)];
str[n] = 0;
str[i] = valid[test_rng_uniform_int(rng, sizeof valid)];
str[n] = 0;
struct cdecl_declspec *
gen_randomize_specs(struct test_rng *rng, struct cdecl_declspec *specs)
{
struct cdecl_declspec *
gen_randomize_specs(struct test_rng *rng, struct cdecl_declspec *specs)
{
- struct cdecl_declspec **p;
- size_t n = 0;
+ struct cdecl_declspec *s, **p;
+ size_t i, n = 0;
if (!specs)
return specs;
if (!specs)
return specs;
- for (struct cdecl_declspec *s = specs; s; s = s->next)
+ for (s = specs; s; s = s->next)
n++;
p = malloc_nofail((n+1) * sizeof *p);
n++;
p = malloc_nofail((n+1) * sizeof *p);
/* Build a temporary array for easy element swapping. */
p[0] = specs;
p[n] = NULL;
/* Build a temporary array for easy element swapping. */
p[0] = specs;
p[n] = NULL;
- for (size_t i = 1; i < n; i++)
+ for (i = 1; i < n; i++)
p[i] = p[i-1]->next;
/* Knuth shuffle. */
p[i] = p[i-1]->next;
/* Knuth shuffle. */
- for (size_t i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
struct cdecl_declspec *tmp;
size_t r;
struct cdecl_declspec *tmp;
size_t r;
}
/* Fix up the pointers. */
}
/* Fix up the pointers. */
- for (size_t i = 1; i <= n; i++)
+ for (i = 1; i <= n; i++)
p[i-1]->next = p[i];
specs = p[0];
p[i-1]->next = p[i];
specs = p[0];
{
unsigned char tmp;
uintmax_t ret = 0;
{
unsigned char tmp;
uintmax_t ret = 0;
- for (size_t i = 0; i < sizeof ret; i++) {
+ for (i = 0; i < sizeof ret; i++) {
tmp = test_rng_uniform_int(rng, UCHAR_MAX+1);
ret <<= CHAR_BIT;
ret |= tmp;
tmp = test_rng_uniform_int(rng, UCHAR_MAX+1);
ret <<= CHAR_BIT;
ret |= tmp;
/*
* Generate random C declarations for testing.
/*
* Generate random C declarations for testing.
- * Copyright © 2012, 2020, 2022 Nick Bowler
+ * Copyright © 2012, 2020, 2022-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
*
* 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
int main(int argc, char **argv)
{
const char *seed = "", *count_str = NULL;
int main(int argc, char **argv)
{
const char *seed = "", *count_str = NULL;
+ unsigned long i, count = 0;
+ int opt, mode = MODE_CDECL;
struct test_rng *rng;
struct cdecl *decl;
struct test_rng *rng;
struct cdecl *decl;
- unsigned long count = 0;
- int opt, mode = MODE_CDECL;
if (argc > 0)
progname = argv[0];
if (argc > 0)
progname = argv[0];
if (!rng)
return EXIT_FAILURE;
if (!rng)
return EXIT_FAILURE;
- for (unsigned long i = 0; !count || i < count; i++) {
+ for (i = 0; !count || i < count; i++) {
decl = random_decl(rng);
if (mode == MODE_ENGLISH) {
decl = random_decl(rng);
if (mode == MODE_ENGLISH) {
#include <config.h>
#include "tap.h"
#include <config.h>
#include "tap.h"
+#if !HAVE_FOR_DECLS
+int main(void)
+{
+ tap_skip_all("cannot compile reference xoshiro256+");
+}
+#else
#include "rng.c"
#include "xos256p.c"
#include "rng.c"
#include "xos256p.c"