]> git.proxmox.com Git - mirror_qemu.git/commit
qapi: Permit flat union members for any tag value
authorMarkus Armbruster <armbru@redhat.com>
Tue, 23 Mar 2021 09:40:05 +0000 (10:40 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 23 Mar 2021 21:30:08 +0000 (22:30 +0100)
commit5fbc78dd3675832062894aeca89a52c90a96f954
tree05f136dbec6beab05b69343344c51f18049cccde
parentdbfe3c7c289c6b95a920b4e2a178e583c17c62a8
qapi: Permit flat union members for any tag value

Flat union branch names match the tag enum's member names.  Omitted
branches default to "no members for this tag value".

Branch names starting with a digit get rejected like "'data' member
'0' has an invalid name".  However, omitting the branch works.

This is because flat union tag values get checked twice: as enum
member name, and as union branch name.  The former accepts leading
digits, the latter doesn't.

Branches whose names start with a digit therefore cannot have members.
Feels wrong.  Get rid of the restriction by skipping the latter check.

This can expose c_name() to input it can't handle: a name starting
with a digit.  Improve it to return a valid C identifier for any
input.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-9-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Commit message rewritten]
scripts/qapi/common.py
scripts/qapi/expr.py