]> xenbits.xensource.com Git - qemu-xen-unstable.git/commitdiff
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)
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

index f6fb93027954a6e71b33081de80a08f19163a48f..2390887f2812edce620bf024509d408c67b44683 100644 (file)
@@ -181,17 +181,8 @@ const int %(name)s_qtypes[QTYPE_MAX] = {
     name=name)
 
     for key in members:
-        qapi_type = members[key]
-        if builtin_types.has_key(qapi_type):
-            qtype = builtin_types[qapi_type]
-        elif find_struct(qapi_type):
-            qtype = "QTYPE_QDICT"
-        elif find_union(qapi_type):
-            qtype = "QTYPE_QDICT"
-        elif find_enum(qapi_type):
-            qtype = "QTYPE_QSTRING"
-        else:
-            assert False, "Invalid anonymous union member"
+        qtype = find_anonymous_member_qtype(members[key])
+        assert qtype, "Invalid anonymous union member"
 
         ret += mcgen('''
     [ %(qtype)s ] = %(abbrev)s_KIND_%(enum)s,
index 438468e3aa4ab36a46fe8923ed1eb46a95647b4a..5f0f699994eb853203287c91f549b82b7fbd1136 100644 (file)
@@ -224,6 +224,23 @@ def find_base_fields(base):
         return None
     return base_struct_define['data']
 
+# Return the qtype of an anonymous union branch, or None on error.
+def find_anonymous_member_qtype(qapi_type):
+    if builtin_types.has_key(qapi_type):
+        return builtin_types[qapi_type]
+    elif find_struct(qapi_type):
+        return "QTYPE_QDICT"
+    elif find_enum(qapi_type):
+        return "QTYPE_QSTRING"
+    else:
+        union = find_union(qapi_type)
+        if union:
+            discriminator = union.get('discriminator')
+            if discriminator == {}:
+                return None
+            return "QTYPE_QDICT"
+    return None
+
 # Return the discriminator enum define if discriminator is specified as an
 # enum type, otherwise return None.
 def discriminator_find_enum_define(expr):
@@ -258,6 +275,8 @@ def check_union(expr, expr_info):
     base = expr.get('base')
     discriminator = expr.get('discriminator')
     members = expr['data']
+    values = { 'MAX': '(automatic)' }
+    types_seen = {}
 
     # If the object has a member 'base', its value must name a complex type,
     # and there must be a discriminator.
@@ -266,26 +285,35 @@ def check_union(expr, expr_info):
             raise QAPIExprError(expr_info,
                                 "Union '%s' requires a discriminator to go "
                                 "along with base" %name)
-        base_fields = find_base_fields(base)
-        if not base_fields:
-            raise QAPIExprError(expr_info,
-                                "Base '%s' is not a valid type"
-                                % base)
 
     # If the union object has no member 'discriminator', it's a
     # simple union. If 'discriminator' is {}, it is an anonymous union.
-    if not discriminator or discriminator == {}:
+    if discriminator is None or discriminator == {}:
         enum_define = None
+        if base is not None:
+            raise QAPIExprError(expr_info,
+                                "Union '%s' must not have a base"
+                                % name)
 
     # Else, it's a flat union.
     else:
-        # The object must have a member 'base'.
-        if not base:
+        # The object must have a string member 'base'.
+        if not isinstance(base, str):
             raise QAPIExprError(expr_info,
-                                "Flat union '%s' must have a base field"
+                                "Flat union '%s' must have a string base field"
                                 % name)
+        base_fields = find_base_fields(base)
+        if not base_fields:
+            raise QAPIExprError(expr_info,
+                                "Base '%s' is not a valid type"
+                                % base)
+
         # The value of member 'discriminator' must name a member of the
         # base type.
+        if not isinstance(discriminator, str):
+            raise QAPIExprError(expr_info,
+                                "Flat union '%s' discriminator must be a string"
+                                % name)
         discriminator_type = base_fields.get(discriminator)
         if not discriminator_type:
             raise QAPIExprError(expr_info,
@@ -301,15 +329,42 @@ def check_union(expr, expr_info):
 
     # Check every branch
     for (key, value) in members.items():
-        # If this named member's value names an enum type, then all members
+        # If the discriminator names an enum type, then all members
         # of 'data' must also be members of the enum type.
-        if enum_define and not key in enum_define['enum_values']:
-            raise QAPIExprError(expr_info,
-                                "Discriminator value '%s' is not found in "
-                                "enum '%s'" %
-                                (key, enum_define["enum_name"]))
-        # Todo: add checking for values. Key is checked as above, value can be
-        # also checked here, but we need more functions to handle array case.
+        if enum_define:
+            if not key in enum_define['enum_values']:
+                raise QAPIExprError(expr_info,
+                                    "Discriminator value '%s' is not found in "
+                                    "enum '%s'" %
+                                    (key, enum_define["enum_name"]))
+
+        # Otherwise, check for conflicts in the generated enum
+        else:
+            c_key = _generate_enum_string(key)
+            if c_key in values:
+                raise QAPIExprError(expr_info,
+                                    "Union '%s' member '%s' clashes with '%s'"
+                                    % (name, key, values[c_key]))
+            values[c_key] = key
+
+        # Ensure anonymous unions have no type conflicts.
+        if discriminator == {}:
+            if isinstance(value, list):
+                raise QAPIExprError(expr_info,
+                                    "Anonymous union '%s' member '%s' must "
+                                    "not be array type" % (name, key))
+            qtype = find_anonymous_member_qtype(value)
+            if not qtype:
+                raise QAPIExprError(expr_info,
+                                    "Anonymous union '%s' member '%s' has "
+                                    "invalid type '%s'" % (name, key, value))
+            if qtype in types_seen:
+                raise QAPIExprError(expr_info,
+                                    "Anonymous union '%s' member '%s' can't "
+                                    "be distinguished from member '%s'"
+                                    % (name, key, types_seen[qtype]))
+            types_seen[qtype] = key
+
 
 def check_enum(expr, expr_info):
     name = expr['enum']
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8d6ccc7325c961b26e91f403688acb14948949af 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/alternate-array.json:5: Anonymous union 'MyUnion' member 'two' must not be array type
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index 25224c6c52824e82f3f72e8c3c9591b9d3b28e2a..0da1a641b37cbe903ea6516898c4cedf025259d9 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: we should not allow array branches in anonymous unions
+# we do not allow array branches in anonymous unions
 # TODO: should we support this?
 { 'type': 'One',
   'data': { 'name': 'str' } }
index 90dc22c460324e75e563d783631c3e657f619b20..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,4 +0,0 @@
-[OrderedDict([('type', 'One'), ('data', OrderedDict([('name', 'str')]))]),
- OrderedDict([('union', 'MyUnion'), ('discriminator', OrderedDict()), ('data', OrderedDict([('one', 'One'), ('two', ['int'])]))])]
-[{'enum_name': 'MyUnionKind', 'enum_values': None}]
-[OrderedDict([('type', 'One'), ('data', OrderedDict([('name', 'str')]))])]
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..85595b28a6caf70b37119daf7af79394947a852d 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/alternate-base.json:4: Union 'MyUnion' must not have a base
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index 2d36db1835ff6fcf19741c3f07e25c7e744b0bce..dad7f029981b46c835b6eae1eb8439f4f3f15fab 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: we should reject anonymous union with base type
+# we reject anonymous union with base type
 { 'type': 'Base',
   'data': { 'string': 'str' } }
 { 'union': 'MyUnion',
index 7fb31f53aa866e7006d0db5ffdc8b9ba680e126d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,4 +0,0 @@
-[OrderedDict([('type', 'Base'), ('data', OrderedDict([('string', 'str')]))]),
- OrderedDict([('union', 'MyUnion'), ('base', 'Base'), ('discriminator', OrderedDict()), ('data', OrderedDict([('number', 'int')]))])]
-[{'enum_name': 'MyUnionKind', 'enum_values': None}]
-[OrderedDict([('type', 'Base'), ('data', OrderedDict([('string', 'str')]))])]
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1130c12834600b434b2336490857d0f4710cd8a7 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/alternate-clash.json:2: Union 'Union1' member 'ONE' clashes with 'one'
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index 7e2ef23f0d74574d6f467871b8e9e0183fda9fd5..fa2d27ed5e7b51a09b6d0c916b389cd634216313 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: we should detect C enum collisions in an anonymous union
+# we detect C enum collisions in an anonymous union
 { 'union': 'Union1',
   'discriminator': {},
   'data': { 'one': 'str', 'ONE': 'int' } }
index c6687fa98a898b156bbb25eab2e2ce382bd4ff7c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,3 +0,0 @@
-[OrderedDict([('union', 'Union1'), ('discriminator', OrderedDict()), ('data', OrderedDict([('one', 'str'), ('ONE', 'int')]))])]
-[{'enum_name': 'Union1Kind', 'enum_values': None}]
-[]
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2d4550c5654ba389b9b16c60416cb94c227cfda9 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/alternate-conflict-dict.json:6: Anonymous union 'MyUnion' member 'two' can't be distinguished from member 'one'
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index d2ed9de2727cadbbfc48bbd7a22514e6931cae06..ded302edae19733b72bca566b56d9fbf460b79cd 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: we should reject anonymous unions with multiple object branches
+# we reject anonymous unions with multiple object branches
 { 'type': 'One',
   'data': { 'name': 'str' } }
 { 'type': 'Two',
index b9ac945f5a7cbfabd67026ccd0a7ff0d085691b8..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,6 +0,0 @@
-[OrderedDict([('type', 'One'), ('data', OrderedDict([('name', 'str')]))]),
- OrderedDict([('type', 'Two'), ('data', OrderedDict([('value', 'int')]))]),
- OrderedDict([('union', 'MyUnion'), ('discriminator', OrderedDict()), ('data', OrderedDict([('one', 'One'), ('two', 'Two')]))])]
-[{'enum_name': 'MyUnionKind', 'enum_values': None}]
-[OrderedDict([('type', 'One'), ('data', OrderedDict([('name', 'str')]))]),
- OrderedDict([('type', 'Two'), ('data', OrderedDict([('value', 'int')]))])]
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..271ddcdec8abaa5ec70ac7cd804e7dbeef817ac2 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/alternate-conflict-string.json:4: Anonymous union 'MyUnion' member 'two' can't be distinguished from member 'one'
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index 35245a30e6e5bd2c4a517986313137cd911457dd..3834a3ddfe1ea992f9bd829eb0ab82f359fd7252 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: we should reject anonymous unions with multiple string-like branches
+# we reject anonymous unions with multiple string-like branches
 { 'enum': 'Enum',
   'data': [ 'hello', 'world' ] }
 { 'union': 'MyUnion',
index e7b39a2117d12a94585d6d12cf7bbd587cf82123..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,5 +0,0 @@
-[OrderedDict([('enum', 'Enum'), ('data', ['hello', 'world'])]),
- OrderedDict([('union', 'MyUnion'), ('discriminator', OrderedDict()), ('data', OrderedDict([('one', 'str'), ('two', 'Enum')]))])]
-[{'enum_name': 'Enum', 'enum_values': ['hello', 'world']},
- {'enum_name': 'MyUnionKind', 'enum_values': None}]
-[]
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..59df96e1329b055cad4c26ec31564ef4550b8d29 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/alternate-nested.json:5: Anonymous union 'Union2' member 'nested' has invalid type 'Union1'
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index d5812bf7adb6080b5ce2d368901c21c8e1fecace..ed2b6b70550099f355300a59db23e415a153b638 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: we should reject a nested anonymous union branch
+# we reject a nested anonymous union branch
 { 'union': 'Union1',
   'discriminator': {},
   'data': { 'name': 'str', 'value': 'int' } }
index 0137c1f984825b044030bda52258af26ab61e822..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,5 +0,0 @@
-[OrderedDict([('union', 'Union1'), ('discriminator', OrderedDict()), ('data', OrderedDict([('name', 'str'), ('value', 'int')]))]),
- OrderedDict([('union', 'Union2'), ('discriminator', OrderedDict()), ('data', OrderedDict([('nested', 'Union1')]))])]
-[{'enum_name': 'Union1Kind', 'enum_values': None},
- {'enum_name': 'Union2Kind', 'enum_values': None}]
-[]
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..bf8e9aef6483b6caba83439e17569b80a73a93d1 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/alternate-unknown.json:2: Anonymous union 'Union' member 'unknown' has invalid type 'MissingType'
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index 0bab9c2c588232e0e3e6cc837032da4a7f343d3c..0c305c282c686683010c515e1f0afa565e91c8be 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: we should reject an anonymous union with unknown type in branch
+# we reject an anonymous union with unknown type in branch
 { 'union': 'Union',
   'discriminator': {},
   'data': { 'unknown': 'MissingType' } }
index 0911cdc978cbd75be6392941a195b4301aee0f39..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,3 +0,0 @@
-[OrderedDict([('union', 'Union'), ('discriminator', OrderedDict()), ('data', OrderedDict([('unknown', 'MissingType')]))])]
-[{'enum_name': 'UnionKind', 'enum_values': None}]
-[]
index 5962ff4f749fc83326f933ce8187c90bec5edd26..f9c31b2bf57a91a2cb66a374c1c84e14ce31adc3 100644 (file)
@@ -1 +1 @@
-tests/qapi-schema/flat-union-bad-base.json:9: Base 'OrderedDict([('enum1', 'TestEnum'), ('kind', 'str')])' is not a valid type
+tests/qapi-schema/flat-union-bad-base.json:9: Flat union 'TestUnion' must have a string base field
index 6c141320dce216c237281341d0d8552ffd4ef655..bb0f02d298a14515df1eec12a735ef7df5bb71af 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: poor message: we require the base to be an existing complex type
+# we require the base to be an existing complex type
 # TODO: should we allow an anonymous inline base type?
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1661c52b03fb8732b07d5566aa91eebfaaa7a26a 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/flat-union-bad-discriminator.json:10: Flat union 'TestUnion' discriminator must be a string
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index 1599a5945443417a236510b16eba321e2f3d6257..3ce43e8356c19cb8cd1486a39f65c496efdfbef7 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: we should require the discriminator to be a string naming a base-type member
+# we require the discriminator to be a string naming a base-type member
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 { 'type': 'TestBase',
index b6ce2171ba94b0a471c45ec71e765afb675e83c9..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,10 +0,0 @@
-[OrderedDict([('enum', 'TestEnum'), ('data', ['value1', 'value2'])]),
- OrderedDict([('type', 'TestBase'), ('data', OrderedDict([('enum1', 'TestEnum'), ('kind', 'str')]))]),
- OrderedDict([('type', 'TestTypeA'), ('data', OrderedDict([('string', 'str')]))]),
- OrderedDict([('type', 'TestTypeB'), ('data', OrderedDict([('integer', 'int')]))]),
- OrderedDict([('union', 'TestUnion'), ('base', 'TestBase'), ('discriminator', []), ('data', OrderedDict([('kind1', 'TestTypeA'), ('kind2', 'TestTypeB')]))])]
-[{'enum_name': 'TestEnum', 'enum_values': ['value1', 'value2']},
- {'enum_name': 'TestUnionKind', 'enum_values': None}]
-[OrderedDict([('type', 'TestBase'), ('data', OrderedDict([('enum1', 'TestEnum'), ('kind', 'str')]))]),
- OrderedDict([('type', 'TestTypeA'), ('data', OrderedDict([('string', 'str')]))]),
- OrderedDict([('type', 'TestTypeB'), ('data', OrderedDict([('integer', 'int')]))])]
index 51fbe54350cd3c4a5376c1056c492e9f9ca5889c..ec586277b72b686aa3e0f861b1a2db46e938ab13 100644 (file)
@@ -1 +1 @@
-tests/qapi-schema/flat-union-inline.json:7: Base 'OrderedDict([('enum1', 'TestEnum'), ('kind', 'str')])' is not a valid type
+tests/qapi-schema/flat-union-inline.json:7: Flat union 'TestUnion' must have a string base field
index 2bdffeb248c31cbcb1b6fac611a273bc0f459417..f3da1175f885e9f38dd9742d6119d323a3b9bcaf 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: poor message: we require branches to be a complex type name
+# we require branches to be a complex type name
 # TODO: should we allow anonymous inline types?
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
index 97323a043204f27345a83d0843c3a862e12303f2..bb3f70874763fddea29e249f3acb2f4d8ab34fc0 100644 (file)
@@ -1 +1 @@
-tests/qapi-schema/flat-union-no-base.json:9: Flat union 'TestUnion' must have a base field
+tests/qapi-schema/flat-union-no-base.json:9: Flat union 'TestUnion' must have a string base field
index 08a02476a309b67f1dff452e5ac20d44ffd11770..9547bb8988d8fbf8a275b93cc13d86f9168bac4a 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: flat unions should require a base
+# flat unions require a base
 # TODO: simple unions should be able to use an enum discriminator
 { 'type': 'TestTypeA',
   'data': { 'string': 'str' } }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8822735561034dc2c1de4cae3b33db33ca7c0c78 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/union-bad-branch.json:6: Union 'MyUnion' member 'ONE' clashes with 'one'
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index 11e46de565e24d67558290f15e59a30756ef72ed..4303666bb505d9e30fae44b4354d3530b0467093 100644 (file)
@@ -1,4 +1,4 @@
-# FIXME: we should reject normal unions where branches would collide in C
+# we reject normal unions where branches would collide in C
 { 'type': 'One',
   'data': { 'string': 'str' } }
 { 'type': 'Two',
index 6baf01be797880923fa06314dd9b42b5097b364d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,6 +0,0 @@
-[OrderedDict([('type', 'One'), ('data', OrderedDict([('string', 'str')]))]),
- OrderedDict([('type', 'Two'), ('data', OrderedDict([('number', 'int')]))]),
- OrderedDict([('union', 'MyUnion'), ('data', OrderedDict([('one', 'One'), ('ONE', 'Two')]))])]
-[{'enum_name': 'MyUnionKind', 'enum_values': None}]
-[OrderedDict([('type', 'One'), ('data', OrderedDict([('string', 'str')]))]),
- OrderedDict([('type', 'Two'), ('data', OrderedDict([('number', 'int')]))])]
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..55ce4399d67d7f2a6da4f842a307f6134d2ce6b3 100644 (file)
@@ -0,0 +1 @@
+tests/qapi-schema/union-max.json:2: Union 'Union' member 'max' clashes with '(automatic)'
index 573541ac9702dd3969c9bc859d2b91ec1f7e6e56..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 (file)
@@ -1 +1 @@
-0
+1
index 45648c474bebcba5bb864a8368939d4c2c5cf9a7..d6ad986999bbe7de24afa0eebf792dda6c2a9684 100644 (file)
@@ -1,3 +1,3 @@
-# FIXME: we should reject 'max' branch in a union, for collision with C enum
+# we reject 'max' branch in a union, for collision with C enum
 { 'union': 'Union',
   'data': { 'max': 'int' } }
index 2757d367f0332727bde30dae2ec4cebde8ec4e2a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,3 +0,0 @@
-[OrderedDict([('union', 'Union'), ('data', OrderedDict([('max', 'int')]))])]
-[{'enum_name': 'UnionKind', 'enum_values': None}]
-[]