Received: from eggs.gnu.org ([2001:4830:134:3::10]:56023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKi0D-0006Du-3u for qemu-devel@nongnu.org; Thu, 30 Jul 2015 03:11:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKi08-0008W3-6n for qemu-devel@nongnu.org; Thu, 30 Jul 2015 03:11:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKi08-0008Vk-0y for qemu-devel@nongnu.org; Thu, 30 Jul 2015 03:11:36 -0400 From: Markus Armbruster References: <1435782155-31412-1-git-send-email-armbru@redhat.com> <1435782155-31412-8-git-send-email-armbru@redhat.com> <55B7E15D.50902@redhat.com> <87lhdzju4i.fsf@blackfin.pond.sub.org> <55B93445.9060104@redhat.com> Date: Thu, 30 Jul 2015 09:11:32 +0200 In-Reply-To: <55B93445.9060104@redhat.com> (Eric Blake's message of "Wed, 29 Jul 2015 14:15:01 -0600") Message-ID: <87io923ysb.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com Eric Blake writes: > On 07/29/2015 01:33 AM, Markus Armbruster wrote: >> Eric Blake writes: >> >>> On 07/01/2015 02:21 PM, Markus Armbruster wrote: >>>> The struct generated for a flat union is weird: the members of its >>>> base are at the end, except for the union tag, which is renamed to >>>> 'kind' and put at the beginning. >>> > >>> Therefore, it might be worth mentioning that avoiding the rename to >>> 'kind' is a bug fix, not just a nicer struct :) >> >> Cool! I'll work (a variation of) this test case into my series. > > Another name collision bug: our code generates flat unions as: > > struct BlockdevOptions { > BlockdevDriver driver; > ... > /* End fields inherited from BlockdevOptionsBase. */ > /* union tag is BlockdevDriver driver */ > union { > void *data; > BlockdevOptionsArchipelago *archipelago; > ... > > which means that if we name any of the branches 'data' (that is, if > 'data' is a member of the enum discriminator), things fail to compile. > We could probably fix that by naming our dummy branch '_data'. I wonder whether member data is actually used. I'll find out.