diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-05 20:21:50 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-03-06 08:49:15 +0800 |
| commit | d4b88ffd878ca151cd03969d02522c456a264a7a (patch) | |
| tree | 260eab10a85d6b926bbac4e8469ca0589c005547 /parse.h | |
| parent | b3e3bc46550a3904e5ef5e6ce578339c6a3b84ea (diff) | |
| download | sparse-dev-d4b88ffd878ca151cd03969d02522c456a264a7a.tar.gz | |
add an optional validation method to external_declaration()
After parsing and validation, the symbols in the declaration
are added to the list given in argument, *if* they are not extern
symbols. The symbols that are extern are them not added to the list.
This is what is needed for usual declarations but ignoring extern
symbols make it impossible to emit a diagnostic in less usual
situation.
This is motivated by the validation of variable declaration inside
a for-loop initializer, which is valid in C99 but only for variable
with local storage.
The change consists in adding to external_declaration() an optional
callback 'validate_decl()' which, if present (non-null), is called
just before adding the declaration to the list.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'parse.h')
| -rw-r--r-- | parse.h | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -129,7 +129,8 @@ extern int show_statement(struct statement *); extern void show_statement_list(struct statement_list *, const char *); extern int show_expression(struct expression *); -extern struct token *external_declaration(struct token *token, struct symbol_list **list); +typedef void (*validate_decl_t)(struct symbol *decl); +extern struct token *external_declaration(struct token *, struct symbol_list **, validate_decl_t); extern struct symbol *ctype_integer(int size, int want_unsigned); |
