From nobody Tue Feb 10 02:42:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630698929; cv=none; d=zohomail.com; s=zohoarc; b=BdDpk+s7aiO87FtMp5OW3trk2X+RenJ65fY4VJ2OMNqZiqSLQs7SxO1VDhTfbhT9xfMjvrbLPjt1jsKAds1CT/mGfu9/rvSaAikEE4rZUYUuNcP4KXzV19sAGpGkn/xJUEU/heLo3KMnr3IyVLwZs8Yhi2d7rB3pCZdg2Mr/mHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630698929; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kVe53MQsH80erQi3iInFDsoE4RGwLmE6RkRir1nu14w=; b=l4KAtSN9kTslykIKna9Q+9TgfsZENHfyRR8xvFEfEW5KgGDYqE604rzUq2eeWm4yF3KZJvnmkpKeJ63DeqNORh5XBmys4oYPbO/pU4883Uh239w/KjKq2WylYRSbYPEMXD8W/F5ZUTB0lAJJ5OgQxwFrjDPodrQdsuG3Lb3p8EI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630698929864510.1355712252623; Fri, 3 Sep 2021 12:55:29 -0700 (PDT) Received: from localhost ([::1]:46454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMFHc-0007sU-Qv for importer@patchew.org; Fri, 03 Sep 2021 15:55:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMEvE-0005l8-Dj for qemu-devel@nongnu.org; Fri, 03 Sep 2021 15:32:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59582) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMEvC-0003ad-Mb for qemu-devel@nongnu.org; Fri, 03 Sep 2021 15:32:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-CjAXF4FoMmSkj9hWtLLekg-1; Fri, 03 Sep 2021 15:32:16 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0B3C1854E2A; Fri, 3 Sep 2021 19:32:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-13.ams2.redhat.com [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D74619D9B; Fri, 3 Sep 2021 19:32:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CF5F41138222; Fri, 3 Sep 2021 21:32:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630697538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kVe53MQsH80erQi3iInFDsoE4RGwLmE6RkRir1nu14w=; b=QM3T1rLddrbG3Y5mYur2C+BsAvFR8oi/EYOlqKZ6/WeBZn9P2ratqeGFYo5aHW41qnGIUv m2qmxsk83mJLc54Y/iDWIiBj4Qxhxno1FWQTmzxl+a6TAB5aS6MdGV7JOsuWe2rJUEJEu4 KfvSGBdhrtwcveJF5AAYydtbL0F+nag= X-MC-Unique: CjAXF4FoMmSkj9hWtLLekg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 05/13] tests/qapi-schema: Demonstrate broken C code for 'if' Date: Fri, 3 Sep 2021 21:32:01 +0200 Message-Id: <20210903193209.1426791-6-armbru@redhat.com> In-Reply-To: <20210903193209.1426791-1-armbru@redhat.com> References: <20210903193209.1426791-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630698930446100001 The C code generated for 'if' conditionals is incorrectly parenthesized. For instance, 'if': { 'not': { 'any': [ { 'not': 'TEST_IF_EVT' }, { 'not': 'TEST_IF_STRUCT' } ] } } } generates #if !(!defined(TEST_IF_EVT)) || (!defined(TEST_IF_STRUCT)) This is wrong. Correct would be: #if !(!defined(TEST_IF_EVT) || !defined(TEST_IF_STRUCT)) Cover the issue in qapi-schema-test.json. This generates bad #if in tests/test-qapi-events.h and other files. Add a similar condition to doc-good.json. The generated documentation is fine. Signed-off-by: Markus Armbruster Message-Id: <20210831123809.1107782-5-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/qapi-schema/doc-good.json | 2 +- tests/qapi-schema/doc-good.out | 2 +- tests/qapi-schema/doc-good.txt | 2 +- tests/qapi-schema/qapi-schema-test.json | 5 +++++ tests/qapi-schema/qapi-schema-test.out | 3 +++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index 5e30790730..e0027e4cf6 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -127,7 +127,7 @@ { 'alternate': 'Alternate', 'features': [ 'alt-feat' ], 'data': { 'i': 'int', 'b': 'bool' }, - 'if': { 'not': 'IFNOT' } } + 'if': { 'not': { 'any': [ 'IFONE', 'IFTWO' ] } } } =20 ## # =3D=3D Another subsection diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 26d1fa5d28..d72f3047e9 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -51,7 +51,7 @@ alternate Alternate tag type case i: int case b: bool - if OrderedDict([('not', 'IFNOT')]) + if OrderedDict([('not', OrderedDict([('any', ['IFONE', 'IFTWO'])]))]) feature alt-feat object q_obj_cmd-arg member arg1: int optional=3DFalse diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt index 5bfe06e14e..85a370831f 100644 --- a/tests/qapi-schema/doc-good.txt +++ b/tests/qapi-schema/doc-good.txt @@ -174,7 +174,7 @@ Features If ~~ =20 -"!IFNOT" +"!(IFONE or IFTWO)" =20 =20 Another subsection diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index e20f76d84c..6e37758280 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -261,6 +261,11 @@ 'bar': { 'type': ['TestIfEnum'], 'if': 'TEST_IF_EVT_BAR' } }, 'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } } =20 +{ 'event': 'TEST_IF_EVENT2', 'data': {}, + # FIXME C #if generated for this conditional is wrong + 'if': { 'not': { 'any': [ { 'not': 'TEST_IF_EVT' }, + { 'not': 'TEST_IF_STRUCT' } ] } } } + # test 'features' =20 { 'struct': 'FeatureStruct0', diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 517d802636..5d2e830ba2 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -357,6 +357,9 @@ object q_obj_TEST_IF_EVENT-arg event TEST_IF_EVENT q_obj_TEST_IF_EVENT-arg boxed=3DFalse if OrderedDict([('all', ['TEST_IF_EVT', 'TEST_IF_STRUCT'])]) +event TEST_IF_EVENT2 None + boxed=3DFalse + if OrderedDict([('not', OrderedDict([('any', [OrderedDict([('not', 'TE= ST_IF_EVT')]), OrderedDict([('not', 'TEST_IF_STRUCT')])])]))]) object FeatureStruct0 member foo: int optional=3DFalse object FeatureStruct1 --=20 2.31.1