Op 24-08-2025 om 15:01 schreef Herman ten Brugge:
I tried to compile openssl with head.

I found a problem with (reduced case):

#include <stdio.h>

static void func(char *(*md)(char *md))
{
   (*md)("test");
}

static char *a(char *a)
{
    printf("%s\n", a);
    return a;
}

int main(void)
{
    func(a);
}
I could fix this with attached patch.
Probably not the best fix 🙂

    Herman
diff --git a/tccgen.c b/tccgen.c
index 67cf6b9..f97b116 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -4992,7 +4992,7 @@ static int post_type(CType *type, AttributeDef *ad, int 
storage, int td)
                     type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT | 
TYPE_PARAM);
                     if ((pt.t & VT_BTYPE) == VT_VOID)
                         tcc_error("parameter declared as void");
-                    if (n == 0)
+                    if (local_scope > 1 || n == 0)
                         n = SYM_FIELD;
                 } else {
                     n = tok;
@@ -5000,7 +5000,7 @@ static int post_type(CType *type, AttributeDef *ad, int 
storage, int td)
                     pt.ref = NULL;
                     next();
                 }
-                if (n < TOK_UIDENT)
+                if (local_scope == 1 && n < TOK_UIDENT)
                     expect("identifier");
                 convert_parameter_type(&pt);
                 arg_size += (type_size(&pt, &align) + PTR_SIZE - 1) / PTR_SIZE;
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to