From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHiCr-0000tr-4A for qemu-devel@nongnu.org; Mon, 27 Jun 2016 21:52:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHiCm-0000ta-Vv for qemu-devel@nongnu.org; Mon, 27 Jun 2016 21:52:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHiCm-0000tW-Nd for qemu-devel@nongnu.org; Mon, 27 Jun 2016 21:52:48 -0400 References: <1463784024-17242-1-git-send-email-eblake@redhat.com> <1463784024-17242-4-git-send-email-eblake@redhat.com> <87porjdht3.fsf@dusky.pond.sub.org> <57600A99.7030209@redhat.com> From: Eric Blake Message-ID: <5771D86E.7050101@redhat.com> Date: Mon, 27 Jun 2016 19:52:46 -0600 MIME-Version: 1.0 In-Reply-To: <57600A99.7030209@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="stp1MlK5FXBoEIBAsUS96Cpmg1GW9WcKR" Subject: Re: [Qemu-devel] [PATCH v7 03/15] qapi: Require all branches of flat union enum to be covered List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --stp1MlK5FXBoEIBAsUS96Cpmg1GW9WcKR From: Eric Blake To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth Message-ID: <5771D86E.7050101@redhat.com> Subject: Re: [Qemu-devel] [PATCH v7 03/15] qapi: Require all branches of flat union enum to be covered References: <1463784024-17242-1-git-send-email-eblake@redhat.com> <1463784024-17242-4-git-send-email-eblake@redhat.com> <87porjdht3.fsf@dusky.pond.sub.org> <57600A99.7030209@redhat.com> In-Reply-To: <57600A99.7030209@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/14/2016 07:46 AM, Eric Blake wrote: > On 06/14/2016 07:24 AM, Markus Armbruster wrote: >> Eric Blake writes: >> >>> We were previously enforcing that all flat union branches were >>> found in the corresponding enum, but not that all enum values >>> were covered by branches. The resulting generated code would >>> abort() if the user passes the uncovered enum value. >>> >>> Signed-off-by: Eric Blake >> >> I'd let the cases not mentioned default to the empty type (ample >> precedence in other languages), but I can live with making the user as= k >> for the empty type explicitly. But we should then make that less >> cumbersome than now: you have to define an empty struct type, and use >> that. Examples of such hoop-jumping: CpuInfoOther, Abort, >> NetdevNoneOptions. >=20 > Later in the series, I do just that, so that we can write 'other':{} > instead of 'other':'CpuInfoOther'. >=20 > What I did not do (but maybe should) is make that short syntax possible= > on simple unions (so that we could do 'abort':{} rather than > 'abort':'Abort') - and merely distinguish that simple unions cannot > stick anything within the {}, thus leaving non-empty anonymous branches= > only for discriminated unions. Can do that as a followup or if this > series needs a respin. In fact, simple unions can't omit branches (the enum is generated from the branch names that are explicitly mentioned); so for symmetry, an explicit empty branch in a flat union is nicer than an omitted branch. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --stp1MlK5FXBoEIBAsUS96Cpmg1GW9WcKR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXcdhuAAoJEKeha0olJ0NqLZoH/iV7EjC5Ug9+cT1EIauA5/Tu X9QxNK9mBBSmPT1ikFGa2vNTs8UtwbrS2kRqoh4poyK9B9Y2AlUnBD/SEcji5Al6 WIj7sqfHEu6H8U0h0sqQ27Po5T2bybpuU7VhDg5hYkHpHQHolpx1J6bueqjS7zp8 Mnl0qJ85Muhsw8nty8IcYLeYzHlEiOBXzGH7+xWwVqfeHlfXLbg3oGzTg1Uhkoa4 3BuoXFkfhKCJRHlgRldEh4fPZWOOxd11Qczux6kzA0LxDIHYegQxXC5N/Bde+D6X gjEYzto8W1imItLt++oJXyAXlhplxEB3bOeh7NRz4B18I+bGiaQzWS2SpFMCcOY= =wu5j -----END PGP SIGNATURE----- --stp1MlK5FXBoEIBAsUS96Cpmg1GW9WcKR--