aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/qapi/common.py20
-rw-r--r--tests/qapi-schema/bad-ident.err1
-rw-r--r--tests/qapi-schema/command-int.err1
-rw-r--r--tests/qapi-schema/redefined-builtin.err1
-rw-r--r--tests/qapi-schema/redefined-command.err1
-rw-r--r--tests/qapi-schema/redefined-event.err1
-rw-r--r--tests/qapi-schema/redefined-type.err1
-rw-r--r--tests/qapi-schema/reserved-command-q.err1
-rw-r--r--tests/qapi-schema/reserved-type-kind.err1
-rw-r--r--tests/qapi-schema/reserved-type-list.err1
10 files changed, 25 insertions, 4 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index c909821560..6f35cd131e 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -708,11 +708,22 @@ valid_name = re.compile(r'^(__[a-zA-Z0-9.-]+_)?'
def check_name(name, info, source,
allow_optional=False, enum_member=False, permit_upper=False):
- global valid_name
- membername = name
+ check_name_is_str(name, info, source)
+ check_name_str(name, info, source,
+ allow_optional, enum_member, permit_upper)
+
+def check_name_is_str(name, info, source):
if not isinstance(name, str):
raise QAPISemError(info, "%s requires a string name" % source)
+
+
+def check_name_str(name, info, source,
+ allow_optional=False, enum_member=False,
+ permit_upper=False):
+ global valid_name
+ membername = name
+
if name.startswith('*'):
membername = name[1:]
if not allow_optional:
@@ -734,7 +745,6 @@ def check_name(name, info, source,
def add_name(name, info, meta):
global all_names
- check_name(name, info, "'%s'" % meta, permit_upper=True)
# FIXME should reject names that differ only in '_' vs. '.'
# vs. '-', because they're liable to clash in generated C.
if name in all_names:
@@ -1153,8 +1163,10 @@ def check_exprs(exprs):
raise QAPISemError(info, "expression is missing metatype")
normalize_if(expr)
name = expr[meta]
- add_name(name, info, meta)
+ check_name_is_str(name, info, "'%s'" % meta)
info.set_defn(meta, name)
+ check_name_str(name, info, "'%s'" % meta, permit_upper=True)
+ add_name(name, info, meta)
if doc and doc.symbol != name:
raise QAPISemError(
info,
diff --git a/tests/qapi-schema/bad-ident.err b/tests/qapi-schema/bad-ident.err
index c4190602b5..6878889854 100644
--- a/tests/qapi-schema/bad-ident.err
+++ b/tests/qapi-schema/bad-ident.err
@@ -1 +1,2 @@
+tests/qapi-schema/bad-ident.json: In struct '*oops':
tests/qapi-schema/bad-ident.json:2: 'struct' does not allow optional name '*oops'
diff --git a/tests/qapi-schema/command-int.err b/tests/qapi-schema/command-int.err
index 0f9300679b..56b45bf656 100644
--- a/tests/qapi-schema/command-int.err
+++ b/tests/qapi-schema/command-int.err
@@ -1 +1,2 @@
+tests/qapi-schema/command-int.json: In command 'int':
tests/qapi-schema/command-int.json:2: built-in 'int' is already defined
diff --git a/tests/qapi-schema/redefined-builtin.err b/tests/qapi-schema/redefined-builtin.err
index b2757225c4..67775fdb41 100644
--- a/tests/qapi-schema/redefined-builtin.err
+++ b/tests/qapi-schema/redefined-builtin.err
@@ -1 +1,2 @@
+tests/qapi-schema/redefined-builtin.json: In struct 'size':
tests/qapi-schema/redefined-builtin.json:2: built-in 'size' is already defined
diff --git a/tests/qapi-schema/redefined-command.err b/tests/qapi-schema/redefined-command.err
index 82ae256e63..b77a05d354 100644
--- a/tests/qapi-schema/redefined-command.err
+++ b/tests/qapi-schema/redefined-command.err
@@ -1 +1,2 @@
+tests/qapi-schema/redefined-command.json: In command 'foo':
tests/qapi-schema/redefined-command.json:3: command 'foo' is already defined
diff --git a/tests/qapi-schema/redefined-event.err b/tests/qapi-schema/redefined-event.err
index 35429cb481..fd02d38157 100644
--- a/tests/qapi-schema/redefined-event.err
+++ b/tests/qapi-schema/redefined-event.err
@@ -1 +1,2 @@
+tests/qapi-schema/redefined-event.json: In event 'EVENT_A':
tests/qapi-schema/redefined-event.json:3: event 'EVENT_A' is already defined
diff --git a/tests/qapi-schema/redefined-type.err b/tests/qapi-schema/redefined-type.err
index 06ea78c478..89acc82c2d 100644
--- a/tests/qapi-schema/redefined-type.err
+++ b/tests/qapi-schema/redefined-type.err
@@ -1 +1,2 @@
+tests/qapi-schema/redefined-type.json: In enum 'foo':
tests/qapi-schema/redefined-type.json:3: struct 'foo' is already defined
diff --git a/tests/qapi-schema/reserved-command-q.err b/tests/qapi-schema/reserved-command-q.err
index f939e044eb..0844e14b26 100644
--- a/tests/qapi-schema/reserved-command-q.err
+++ b/tests/qapi-schema/reserved-command-q.err
@@ -1 +1,2 @@
+tests/qapi-schema/reserved-command-q.json: In command 'q-unix':
tests/qapi-schema/reserved-command-q.json:5: 'command' uses invalid name 'q-unix'
diff --git a/tests/qapi-schema/reserved-type-kind.err b/tests/qapi-schema/reserved-type-kind.err
index 0a38efaad8..8d21479000 100644
--- a/tests/qapi-schema/reserved-type-kind.err
+++ b/tests/qapi-schema/reserved-type-kind.err
@@ -1 +1,2 @@
+tests/qapi-schema/reserved-type-kind.json: In enum 'UnionKind':
tests/qapi-schema/reserved-type-kind.json:2: enum 'UnionKind' should not end in 'Kind'
diff --git a/tests/qapi-schema/reserved-type-list.err b/tests/qapi-schema/reserved-type-list.err
index 4510fa6d90..2bdd7d8a06 100644
--- a/tests/qapi-schema/reserved-type-list.err
+++ b/tests/qapi-schema/reserved-type-list.err
@@ -1 +1,2 @@
+tests/qapi-schema/reserved-type-list.json: In struct 'FooList':
tests/qapi-schema/reserved-type-list.json:5: struct 'FooList' should not end in 'List'