qapi script: check correctness of union
authorWenchao Xia <>
Wed, 5 Mar 2014 02:44:34 +0000 (18:44 -0800)
committerLuiz Capitulino <>
Tue, 11 Mar 2014 13:07:41 +0000 (09:07 -0400)
qapi script: check correctness of union

Since line info is remembered as QAPISchema.line now, this patch
uses it as additional info for every expr in QAPISchema inside,
then improves error message with it in checking of exprs.

For common union the patch will check whether base is a valid complex
type if specified. For flat union it will check whether base presents,
whether discriminator is found in base, whether the key of every branch
is correct when discriminator is an enum type.

Signed-off-by: Wenchao Xia <>
Reviewed-by: Markus Armbruster <>
Signed-off-by: Luiz Capitulino <>
18 files changed:
tests/qapi-schema/flat-union-invalid-branch-key.err [new file with mode: 0644]
tests/qapi-schema/flat-union-invalid-branch-key.exit [new file with mode: 0644]
tests/qapi-schema/flat-union-invalid-branch-key.json [new file with mode: 0644]
tests/qapi-schema/flat-union-invalid-branch-key.out [new file with mode: 0644]
tests/qapi-schema/flat-union-invalid-discriminator.err [new file with mode: 0644]
tests/qapi-schema/flat-union-invalid-discriminator.exit [new file with mode: 0644]
tests/qapi-schema/flat-union-invalid-discriminator.json [new file with mode: 0644]
tests/qapi-schema/flat-union-invalid-discriminator.out [new file with mode: 0644]
tests/qapi-schema/flat-union-no-base.err [new file with mode: 0644]
tests/qapi-schema/flat-union-no-base.exit [new file with mode: 0644]
tests/qapi-schema/flat-union-no-base.json [new file with mode: 0644]
tests/qapi-schema/flat-union-no-base.out [new file with mode: 0644]
tests/qapi-schema/union-invalid-base.err [new file with mode: 0644]
tests/qapi-schema/union-invalid-base.exit [new file with mode: 0644]
tests/qapi-schema/union-invalid-base.json [new file with mode: 0644]
tests/qapi-schema/union-invalid-base.out [new file with mode: 0644]