From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWPg2-0005XC-47 for qemu-devel@nongnu.org; Thu, 18 Feb 2016 09:35:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWPfx-000817-Qr for qemu-devel@nongnu.org; Thu, 18 Feb 2016 09:35:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWPfx-00080j-Kk for qemu-devel@nongnu.org; Thu, 18 Feb 2016 09:35:25 -0500 From: Markus Armbruster References: <1455778109-6278-1-git-send-email-eblake@redhat.com> <1455778109-6278-11-git-send-email-eblake@redhat.com> Date: Thu, 18 Feb 2016 15:35:23 +0100 In-Reply-To: <1455778109-6278-11-git-send-email-eblake@redhat.com> (Eric Blake's message of "Wed, 17 Feb 2016 23:48:24 -0700") Message-ID: <877fi2dr2s.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v11 10/15] qapi: Emit structs used as variants in topological order List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Michael Roth Eric Blake writes: > Right now, we emit the branches of union types as a boxed pointer, > and it suffices to have a forward declaration of the type. However, > a future patch will swap things to directly use the branch type, > instead of hiding it behind a pointer. For this to work, the > compiler needs the full definition of the type, not just a forward > declaration, prior to the union that is including the branch type. > This patch just adds topological sorting to hoist all types > mentioned in a branch of a union to be fully declared before the > union itself. The sort is always possible, because we do not > allow circular union types that include themselves as a direct > branch When a patch makes a "can't happen" claim, I normally ask for assertions to make sure we go down in flames should it happen anyway. But in this case, the C compiler will shoot us down then, and that'll do nicely. > (it is, however, still possible to include a branch type > that itself has a pointer to the union, for a type that can > indirectly recursively nest itself - that remains safe, because > that the member of the branch type will remain a pointer, and the > QMP representation of such a type adds another {} for each recurring > layer of the union type). > > Signed-off-by: Eric Blake