qapi-visit: Fix generated code when schema has forward refs
commit8c3f8e77215bfedb7854221868f655e148506936
authorMarkus Armbruster <armbru@redhat.com>
Fri, 26 Jun 2015 08:19:11 +0000 (26 10:19 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 4 Sep 2015 13:47:13 +0000 (4 15:47 +0200)
treec49d6c7672d25980dec64b31e2aebe9aa8d8f154
parent1e6c1616a91cdcbe9a8387541f7689b8c11632aa
qapi-visit: Fix generated code when schema has forward refs

The visit_type_implicit_FOO() are generated on demand, right before
their first use.  Used by visit_type_STRUCT_fields() when STRUCT has
base FOO, and by visit_type_UNION() when flat UNION has member a FOO.

If the schema defines FOO after its first use as struct base or flat
union member, visit_type_implicit_FOO() calls
visit_type_implicit_FOO() before its definition, which doesn't
compile.

Rearrange qapi-schema-test.json to demonstrate the bug.

Fix by generating the necessary forward declaration.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
scripts/qapi-visit.py
tests/qapi-schema/qapi-schema-test.json
tests/qapi-schema/qapi-schema-test.out