add an optional validation method to external_declaration()
commitd4b88ffd878ca151cd03969d02522c456a264a7a
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Sun, 5 Mar 2017 19:21:50 +0000 (5 20:21 +0100)
committerChristopher Li <sparse@chrisli.org>
Mon, 6 Mar 2017 00:49:15 +0000 (6 08:49 +0800)
tree260eab10a85d6b926bbac4e8469ca0589c005547
parentb3e3bc46550a3904e5ef5e6ce578339c6a3b84ea
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>
lib.c
parse.c
parse.h