qapi: Tighten checking of unions
authorEric Blake <eblake@redhat.com>
Mon, 4 May 2015 15:05:08 +0000 (09:05 -0600)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 5 May 2015 16:39:00 +0000 (18:39 +0200)
commit44bd1276a7dea747c41f250cb71ab65965343a7f
tree894d69d943b040b621e1eff76edd5532de3e212d
parenta8d4a2e4d7e1a0207699de47142c9bdbf2cc8675
qapi: Tighten checking of unions

Previous commits demonstrated that the generator had several
flaws with less-than-perfect unions:
- a simple union that listed the same branch twice (or two variant
names that map to the same C enumerator, including the implicit
MAX sentinel) ended up generating invalid C code
- an anonymous union that listed two branches with the same qtype
ended up generating invalid C code
- the generator crashed on anonymous union attempts to use an
array type
- the generator was silently ignoring a base type for anonymous
unions
- the generator allowed unknown types or nested anonymous unions
as a branch in an anonymous union

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
48 files changed:
scripts/qapi-types.py
scripts/qapi.py
tests/qapi-schema/alternate-array.err
tests/qapi-schema/alternate-array.exit
tests/qapi-schema/alternate-array.json
tests/qapi-schema/alternate-array.out
tests/qapi-schema/alternate-base.err
tests/qapi-schema/alternate-base.exit
tests/qapi-schema/alternate-base.json
tests/qapi-schema/alternate-base.out
tests/qapi-schema/alternate-clash.err
tests/qapi-schema/alternate-clash.exit
tests/qapi-schema/alternate-clash.json
tests/qapi-schema/alternate-clash.out
tests/qapi-schema/alternate-conflict-dict.err
tests/qapi-schema/alternate-conflict-dict.exit
tests/qapi-schema/alternate-conflict-dict.json
tests/qapi-schema/alternate-conflict-dict.out
tests/qapi-schema/alternate-conflict-string.err
tests/qapi-schema/alternate-conflict-string.exit
tests/qapi-schema/alternate-conflict-string.json
tests/qapi-schema/alternate-conflict-string.out
tests/qapi-schema/alternate-nested.err
tests/qapi-schema/alternate-nested.exit
tests/qapi-schema/alternate-nested.json
tests/qapi-schema/alternate-nested.out
tests/qapi-schema/alternate-unknown.err
tests/qapi-schema/alternate-unknown.exit
tests/qapi-schema/alternate-unknown.json
tests/qapi-schema/alternate-unknown.out
tests/qapi-schema/flat-union-bad-base.err
tests/qapi-schema/flat-union-bad-base.json
tests/qapi-schema/flat-union-bad-discriminator.err
tests/qapi-schema/flat-union-bad-discriminator.exit
tests/qapi-schema/flat-union-bad-discriminator.json
tests/qapi-schema/flat-union-bad-discriminator.out
tests/qapi-schema/flat-union-inline.err
tests/qapi-schema/flat-union-inline.json
tests/qapi-schema/flat-union-no-base.err
tests/qapi-schema/flat-union-no-base.json
tests/qapi-schema/union-bad-branch.err
tests/qapi-schema/union-bad-branch.exit
tests/qapi-schema/union-bad-branch.json
tests/qapi-schema/union-bad-branch.out
tests/qapi-schema/union-max.err
tests/qapi-schema/union-max.exit
tests/qapi-schema/union-max.json
tests/qapi-schema/union-max.out