On Fri, Apr 15, 2005 at 10:36:52AM +0200, Michael Stefaniuc wrote:
> Christopher Li wrote:
> >>while trying to run sparse on the Wine sources I got a segfault which
> >>can be reproduced with following code:
> >>
> >>int (*oink)() = (void *)0;
> >>
> >>
> >
> I know that works, I used an analog patch to keep going, but is this the 
> correct fix or only a quick workaround?
> 
> >-                    warning(token->pos, "non-ANSI function declaration 
> >of function '%s'", show_ident(*p));
> >+                    warning(token->pos, "non-ANSI function declaration 

Well, it is a lazy fix. I am not sure about that is the best fix.

I think "p" the place holder for return idents, which is the ident of the symbol
get created.

int a;

eventually (*p) will set to a point of ident which is "a".
There is code set p to NULL when after a grouping, e.g. "(a)"
so after ")" there is no more ident expect from the group.

the p for parameter_type_list is just for print out warning.
But the ident can still be NULL. e.g.

void foo(void(*)(void));

so if you want to see the symbol name that is causing the warning,
I have the following patch will show the "oink" instead of "<noident>"
in the warning.

I dunno.

Chris


Index: sparse/parse.c
===================================================================
--- sparse.orig/parse.c 2005-04-11 16:15:52.000000000 -0400
+++ sparse/parse.c      2005-04-15 14:11:12.000000000 -0400
@@ -762,6 +762,7 @@
 static struct token *direct_declarator(struct token *token, struct symbol 
*decl, struct ident **p)
 {
        struct ctype *ctype = &decl->ctype;
+       struct ident **ident = p;
 
        if (p && token_type(token) == TOKEN_IDENT) {
                *p = token->ident;
@@ -797,7 +798,7 @@
                        }
 
                        sym = indirect(token->pos, ctype, SYM_FN);
-                       token = parameter_type_list(next, sym, p);
+                       token = parameter_type_list(next, sym, ident);
                        token = expect(token, ')', "in function declarator");
                        continue;
                }
@@ -1355,7 +1356,7 @@
                // No warning for "void oink ();"
                // Bug or feature: warns for "void oink () __attribute__ 
((noreturn));"
                if (!match_op(token->next, ';'))
-                       warning(token->pos, "non-ANSI function declaration of 
function '%s'", show_ident(*p));
+                       warning(token->pos, "non-ANSI function declaration of 
function '%s'", show_ident(p ? *p : NULL));
                return token;
        }
 


-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to