]> git.ozlabs.org Git - ccan/blobdiff - tools/configurator/configurator.c
configurator: more robust test for HAVE_NESTED_FUNCTIONS
[ccan] / tools / configurator / configurator.c
index 4972e9e198bb56a4ed5bc910722a9d9b8625ce7c..837ef8ce00ee9302605682bb27748287a369a4da 100644 (file)
@@ -38,6 +38,14 @@ struct test {
 static struct test tests[] = {
        { "HAVE_ALIGNOF", INSIDE_MAIN, NULL,
          "return __alignof__(double) > 0 ? 0 : 1;" },
+       { "HAVE_ASPRINTF", DEFINES_FUNC, NULL,
+         "#define _GNU_SOURCE\n"
+         "#include <stdio.h>\n"
+         "static char *func(int x) {"
+         "     char *p;\n"
+         "     if (asprintf(&p, \"%u\", x) == -1) p = NULL;"
+         "     return p;\n"
+         "}" },
        { "HAVE_ATTRIBUTE_COLD", DEFINES_FUNC, NULL,
          "static int __attribute__((cold)) func(int x) { return x; }" },
        { "HAVE_ATTRIBUTE_CONST", DEFINES_FUNC, NULL,
@@ -103,12 +111,12 @@ static struct test tests[] = {
          "     return mmap(0, 65536, PROT_READ, MAP_SHARED, fd, 0);\n"
          "}" },
        { "HAVE_NESTED_FUNCTIONS", DEFINES_FUNC, NULL,
-         "static int func(int val) {\n"
+         "void (*func(int val))(int);\n"
+         "void (*func(int val))(int) {\n"
          "     auto void add(int val2);\n"
          "     void add(int val2) { val += val2; }\n"
-         "     add(7);\n"
-         "     return val;\n"
-         "}" },
+         "     return add;\n"
+         "}\n" },
        { "HAVE_STATEMENT_EXPR", INSIDE_MAIN, NULL,
          "return ({ int x = argc; x == argc ? 0 : 1; });" },
        { "HAVE_TYPEOF", INSIDE_MAIN, NULL,