On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> This demonstrates a bug in the lowering of simple unions: if more than
> one schema uses the same built-in type T for a simple union member,
> they all generate the same q_obj_T_wrapper into their qapi-types.h.
> They clash when you include more than one schema's qapi-types.h.
Ah, I don't remember seeing that when I splitted the schema in my
qapi-if / conditional series.
Could it happen with non-built-in types ?
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> tests/qapi-schema/qapi-schema-test.json | 6 ++++++
> tests/qapi-schema/qapi-schema-test.out | 10 ++++++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
> index c72dbd8050..c091626635 100644
> --- a/tests/qapi-schema/qapi-schema-test.json
> +++ b/tests/qapi-schema/qapi-schema-test.json
> @@ -82,6 +82,12 @@
> 'base': 'UserDefZero',
> 'data': { 'string': 'str', 'enum1': 'EnumOne' } }
>
> +{ 'union': 'UserDefSimpleUnion',
> + 'data': { 'value1': 'UserDefA',
> +# FIXME generated q_obj_int_wrapper clashes with qapi-schema.json's
> +# 'value2': 'int',
> + 'value3': 'UserDefB' } }
> +
> # this variant of UserDefFlatUnion defaults to a union that uses members with
> # allocated types to test corner cases in the cleanup/dealloc visitor
> { 'union': 'UserDefFlatUnion2',
> diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
> index 4b42db23b2..97bb02f2fd 100644
> --- a/tests/qapi-schema/qapi-schema-test.out
> +++ b/tests/qapi-schema/qapi-schema-test.out
> @@ -108,6 +108,12 @@ object UserDefOptions
> member u16: uint16List optional=True
> member i64x: int optional=True
> member u64x: uint64 optional=True
> +object UserDefSimpleUnion
> + member type: UserDefSimpleUnionKind optional=False
> + tag type
> + case value1: q_obj_UserDefA-wrapper
> + case value3: q_obj_UserDefB-wrapper
> +enum UserDefSimpleUnionKind ['value1', 'value3']
> object UserDefTwo
> member string0: str optional=False
> member dict1: UserDefTwoDict optional=False
> @@ -169,6 +175,10 @@ object q_obj_EVENT_D-arg
> member b: str optional=False
> member c: str optional=True
> member enum3: EnumOne optional=True
> +object q_obj_UserDefA-wrapper
> + member data: UserDefA optional=False
> +object q_obj_UserDefB-wrapper
> + member data: UserDefB optional=False
> object q_obj_UserDefFlatUnion2-base
> member integer: int optional=True
> member string: str optional=False
> --
> 2.13.6
>
>
--
Marc-André Lureau