diff mbox

[v7,39a/39] squash: qapi: Check for member name conflicts with a base class

Message ID 1430512075-20672-1-git-send-email-eblake@redhat.com
State New
Headers show

Commit Message

Eric Blake May 1, 2015, 8:27 p.m. UTC
A conflict must be marked even when the two dictionaries being
compared differ on whether the key is marked optional.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 scripts/qapi.py                                | 4 +++-
 tests/qapi-schema/flat-union-branch-clash.json | 2 +-
 tests/qapi-schema/struct-base-clash-deep.json  | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 4ec8646..ad20d3e 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -419,7 +419,9 @@  def check_member_clash(expr_info, base_name, data, source = ""):
     assert base
     base_members = base['data']
     for key in data.keys():
-        if key in base_members:
+        if key.startswith('*'):
+            key = key[1:]
+        if key in base_members or "*%s" %key in base_members:
             raise QAPIExprError(expr_info,
                                 "Member name '%s'%s clashes with base '%s'"
                                 %(key, source, base_name))
diff --git a/tests/qapi-schema/flat-union-branch-clash.json b/tests/qapi-schema/flat-union-branch-clash.json
index b3c6ffe..8fb054f 100644
--- a/tests/qapi-schema/flat-union-branch-clash.json
+++ b/tests/qapi-schema/flat-union-branch-clash.json
@@ -2,7 +2,7 @@ 
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 { 'struct': 'Base',
-  'data': { 'enum1': 'TestEnum', 'name': 'str' } }
+  'data': { 'enum1': 'TestEnum', '*name': 'str' } }
 { 'struct': 'Branch1',
   'data': { 'name': 'str' } }
 { 'struct': 'Branch2',
diff --git a/tests/qapi-schema/struct-base-clash-deep.json b/tests/qapi-schema/struct-base-clash-deep.json
index 08c8c9c..552fe94 100644
--- a/tests/qapi-schema/struct-base-clash-deep.json
+++ b/tests/qapi-schema/struct-base-clash-deep.json
@@ -6,4 +6,4 @@ 
   'data': { 'value': 'int' } }
 { 'struct': 'Sub',
   'base': 'Mid',
-  'data': { 'name': 'str' } }
+  'data': { '*name': 'str' } }