aboutsummaryrefslogtreecommitdiffstats
path: root/parse.c
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2009-02-14 12:25:15 +0000
committerChristopher Li <sparse@chrisli.org>2009-07-17 23:06:22 +0000
commit9151897c4a2557382b4a4a64e1e3a0fae41747e0 (patch)
tree31b3563c8f6bcac673057eb60e38e13a13d47aba /parse.c
parent65f354637410d2c5d33a6ca425a67ceacdd7cea0 (diff)
downloadsparse-9151897c4a2557382b4a4a64e1e3a0fae41747e0.tar.gz
Separate parsing of identifier-list (in K&R-style declarations)
Don't mix it with parameter-type-list, add saner checks. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/parse.c b/parse.c
index 99e1899a..27338355 100644
--- a/parse.c
+++ b/parse.c
@@ -1834,12 +1834,36 @@ static struct token *parameter_type_list(struct token *token, struct symbol *fn,
return token;
}
+ if (match_op(token, SPECIAL_ELLIPSIS)) {
+ warning(token->pos, "variadic functions must have one named argument");
+ fn->variadic = 1;
+ return token->next;
+ }
+
+ if (token_type(token) != TOKEN_IDENT)
+ return token;
+
+ if (!lookup_type(token)) {
+ /* K&R */
+ for (;;) {
+ struct symbol *sym = alloc_symbol(token->pos, SYM_NODE);
+ sym->ident = token->ident;
+ token = token->next;
+ sym->endpos = token->pos;
+ add_symbol(list, sym);
+ if (!match_op(token, ',') ||
+ token_type(token->next) != TOKEN_IDENT ||
+ lookup_type(token->next))
+ break;
+ token = token->next;
+ }
+ return token;
+ }
+
for (;;) {
struct symbol *sym;
if (match_op(token, SPECIAL_ELLIPSIS)) {
- if (!*list)
- warning(token->pos, "variadic functions must have one named argument");
fn->variadic = 1;
token = token->next;
break;