diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-09-19 10:08:36 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-09-19 10:08:36 +0000 |
commit | 4373f54bad038dc3193676fc97203ed0a3cd1bf4 (patch) | |
tree | 66b5d3abab968e84609b49a0c530cc1bd30b69b5 /src | |
parent | 67ab24f60aebc584921ef2baaebcae420700d85f (diff) | |
download | cflow-4373f54bad038dc3193676fc97203ed0a3cd1bf4.tar.gz cflow-4373f54bad038dc3193676fc97203ed0a3cd1bf4.tar.bz2 |
(parse_function_declaration): Put token back after
an error.
(dirdcl): Handle wrappers after function declarations. Useful for
handling __attribute__.
(maybe_parm_list): Fixed counting of parameters. Print error
message on eof.
Diffstat (limited to 'src')
-rw-r--r-- | src/parser.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/parser.c b/src/parser.c index 6cfc51d..d0a7f32 100644 --- a/src/parser.c +++ b/src/parser.c @@ -27,9 +27,6 @@ typedef struct { enum storage storage; } Ident; -#define is_finction(ip) ((ip)->parmcnt >= 0) -#define is_extern_dcl(ip) ((ip)->storage == ExplicitExternStorage) - void parse_declaration(Ident*); void parse_variable_declaration(Ident*); void parse_function_declaration(Ident*); @@ -341,7 +338,7 @@ is_function() void parse_declaration(Ident *ident) { - if (is_function()) + if (is_function()) parse_function_declaration(ident); else parse_variable_declaration(ident); @@ -419,7 +416,7 @@ parse_function_declaration(Ident *ident) default: if (verbose) file_error(_("expected `;'"), 1); - /* should putback() here */ + putback(); /* FALLTHRU */ case ';': break; @@ -572,6 +569,7 @@ parse_knr_dcl(Ident *ident) parse_dcl(ident); if (strict_ansi) return; + switch (tok.type) { case IDENTIFIER: case TYPE: @@ -684,7 +682,7 @@ parse_dcl(Ident *ident) putback(); dcl(ident); save_stack(); - if (ident->name) { + if (ident->name) { declare(ident); } else { finish_save(); @@ -696,7 +694,7 @@ int dcl(Ident *idptr) { int type; - + while (nexttoken() != 0 && tok.type != '(') { if (tok.type == MODIFIER) { if (idptr && idptr->type_end == -1) @@ -759,6 +757,27 @@ dirdcl(Ident *idptr) } if (wrapper) nexttoken(); /* read ')' */ + + if (tok.type == PARM_WRAPPER) { + if (nexttoken() == '(') { + int level = 0; + while (nexttoken()) { + if (tok.type == 0) { + file_error(_("unexpected eof in function declaration"), + 0); + return; + } else if (tok.type == '(') + level++; + else if (tok.type == ')') { + if (level-- == 0) { + nexttoken(); + break; + } + } + } + } else + putback(); + } return 0; } @@ -795,18 +814,18 @@ maybe_parm_list(int *parm_cnt_return) switch (tok.type) { case ')': if (parm_cnt_return) - *parm_cnt_return = parmcnt+1; + *parm_cnt_return = parmcnt; return; case ',': - parmcnt++; break; default: + parmcnt++; putback(); parmdcl(NULL); putback(); } } - /*NOTREACHED*/ + file_error(_("unexpected eof in parameter list"), 0); } void |