fix sqlite test
[m6w6/ext-psi] / src / types / decl_arg.c
index b4acdb1c2b7aabd688057d3eeec6920d505e1035..9c57168a812ad6d5fbf9f346e1fbcffa554549f1 100644 (file)
@@ -61,6 +61,9 @@ void psi_decl_arg_dump(int fd, struct psi_decl_arg *arg, unsigned level)
 {
        if (arg->type->type == PSI_T_FUNCTION) {
                psi_decl_type_dump(fd, arg->type->real.func->func->type, level);
+               if (arg->type->real.func->func->type->type == PSI_T_FUNCTION) {
+                       dprintf(fd, "(");
+               }
                dprintf(fd, " %s(*%s)",
                                psi_t_indirection(arg->var->pointer_level - !! arg->var->array_size),
                                arg->var->name);
@@ -82,6 +85,26 @@ void psi_decl_arg_dump(int fd, struct psi_decl_arg *arg, unsigned level)
                        }
                }
                dprintf(fd, ")");
+               if (arg->type->real.func->func->type->type == PSI_T_FUNCTION) {
+                       struct psi_decl *decl = arg->type->real.func->func->type->real.func;
+
+                       dprintf(fd, "(");
+                       if (decl->args) {
+                               size_t i;
+                               struct psi_decl_arg *arg;
+
+                               for (i = 0; psi_plist_get(decl->args, i, &arg); ++i) {
+                                       if (i) {
+                                               dprintf(fd, ", ");
+                                       }
+                                       psi_decl_arg_dump(fd, arg, 0);
+                               }
+                               if (decl->varargs) {
+                                       dprintf(fd, ", ...");
+                               }
+                       }
+                       dprintf(fd, "))");
+               }
                if (arg->var->array_size) {
                        dprintf(fd, "[%u]", arg->var->array_size);
                }
@@ -93,9 +116,9 @@ void psi_decl_arg_dump(int fd, struct psi_decl_arg *arg, unsigned level)
 }
 
 bool psi_decl_arg_validate(struct psi_data *data, struct psi_decl_arg *arg,
-               struct psi_validate_stack *type_stack)
+               struct psi_validate_scope *scope)
 {
-       if (!psi_decl_type_validate(data, arg->type, arg->var->pointer_level, type_stack)) {
+       if (!psi_decl_type_validate(data, arg->type, arg, scope)) {
                 if (!arg->var->pointer_level) {
                        data->error(data, arg->type->token, PSI_WARNING,
                                        "Cannot use '%s' as type for '%s'%s%s", arg->type->name,
@@ -107,12 +130,12 @@ bool psi_decl_arg_validate(struct psi_data *data, struct psi_decl_arg *arg,
 }
 
 bool psi_decl_arg_validate_typedef(struct psi_data *data,
-               struct psi_decl_arg *def, struct psi_validate_stack *type_stack)
+               struct psi_decl_arg *def, struct psi_validate_scope *scope)
 {
-       if (psi_validate_stack_has_type(type_stack, def->var->name)) {
+       if (psi_validate_scope_has_type(scope, def->var->name)) {
                return true;
        }
-       psi_validate_stack_add_type(type_stack, def->var->name, def);
+       psi_validate_scope_add_type(scope, def->var->name, def);
 
        if (def->type->type == PSI_T_VOID) {
                if (def->var->pointer_level) {
@@ -122,7 +145,7 @@ bool psi_decl_arg_validate_typedef(struct psi_data *data,
                                        "Type '%s' cannot be aliased to 'void'", def->type->name);
                        return false;
                }
-       } else if (!psi_decl_type_validate(data, def->type, def->var->pointer_level, type_stack)) {
+       } else if (!psi_decl_type_validate(data, def->type, def, scope)) {
                const char *pre;
 
                switch (def->type->type) {