aboutsummaryrefslogtreecommitdiff
path: root/tests/qapi-schema
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-03-01 16:40:51 +0100
committerMarkus Armbruster <armbru@redhat.com>2019-03-05 14:43:11 +0100
commit56a4689582433125d7042ba506a081e08dc264d4 (patch)
tree014c10ef50a1c9ac64768c1091b443d8fdd7ba5d /tests/qapi-schema
parent5e12eb987b3299a5da4172fe744e91dbd00b6516 (diff)
qapi: Fix array first used in a different module
We generally put implicitly defined types in whatever module triggered their definition. This is wrong for array types, as the included test case demonstrates. Let's have a closer look at it. Type 'Status' is defined sub-sub-module.json. Array type ['Status'] occurs in main module qapi-schema-test.json and in include/sub-module.json. The main module's use is first, so the array type gets put into the main module. The generated C headers define StatusList in qapi-types.h. But include/qapi-types-sub-module.h uses it without including qapi-types.h. Oops. To fix that, put the array type into its element type's module. Now StatusList gets generated into qapi-types-sub-module.h, which all its users include. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190301154051.23317-8-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/qapi-schema')
-rw-r--r--tests/qapi-schema/include/sub-module.json2
-rw-r--r--tests/qapi-schema/qapi-schema-test.out5
2 files changed, 7 insertions, 0 deletions
diff --git a/tests/qapi-schema/include/sub-module.json b/tests/qapi-schema/include/sub-module.json
index f2bdbd3990..afdb267228 100644
--- a/tests/qapi-schema/include/sub-module.json
+++ b/tests/qapi-schema/include/sub-module.json
@@ -3,3 +3,5 @@
# Sub-module of ../qapi-schema-test.json
{ 'include': '../sub-sub-module.json' }
+
+{ 'struct': 'SecondArrayRef', 'data': { 's': ['Status'] } }
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 38c1de70d8..77fb1e1aa9 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -144,7 +144,9 @@ object q_obj_sizeList-wrapper
member data: sizeList optional=False
object q_obj_anyList-wrapper
member data: anyList optional=False
+module sub-sub-module.json
array StatusList Status
+module qapi-schema-test.json
object q_obj_StatusList-wrapper
member data: StatusList optional=False
enum UserDefListUnionKind
@@ -189,6 +191,9 @@ enum Status
member good
member bad
member ugly
+module include/sub-module.json
+object SecondArrayRef
+ member s: StatusList optional=False
module qapi-schema-test.json
command user_def_cmd None -> None
gen=True success_response=True boxed=False oob=False preconfig=False