From patchwork Thu Sep 8 15:29:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chung-Lin Tang X-Patchwork-Id: 1099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp303272wrt; Thu, 8 Sep 2022 08:29:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5BLwhGUKYSTIKbx5YXtH/PVFojn+DLGjkN0SqaEJQRF80o2WfQ7za/Xg/HK46oj6pChPO0 X-Received: by 2002:a05:6402:3594:b0:448:6491:f9ad with SMTP id y20-20020a056402359400b004486491f9admr7905611edc.63.1662650988632; Thu, 08 Sep 2022 08:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662650988; cv=none; d=google.com; s=arc-20160816; b=T5quIlL4KYMGx57mb+KcEED1lBn6NHGN5oXXUc8sGO6uJYWgSSKL4VjbSwmPwALOnY btdgroJzYRYmQDeje9kW3rNmRKlDeCoDaIfrrB4RnhuWkn+Dt3VUJ6yFymN/CeHJEpiy IK+BUC45J5cQ8FALcqHHANKSj1mmu/9pVTLdUSyVRpF2TXUImjAwG4AiKDwduTllG/nk 7n447vpzUMZU+UYf0NnBiBPiUbxl8wDG7HPu8wvdvsFafpkKAYgj59UINxKYciXACpHP Py2SvgZO2qBqE6V/nRBD7wqdal9tT/mVsjWdQprIq6XD10khJVFwj+CfgFn6nq3NabP5 wHIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:to:from :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=Rei7TUeMkhxztwhCn5ALZgtoNeWOse92ik7DzEuzRBw=; b=IK5ylgyxg3nXK49797tqffA69qG2NZyrR08yVazc9IPO+MnN5SUkisLV7YAqIkmcQM E2sgB4X136jK+DdSzHUdeGEl73f7aW5FMhNTroBBO/8jcgMUXXio5FulwmzHnrLBOoaQ 4gqfPoA6TQZIZbCdkvF2kdNdgQ4AYWLBN4q1S6Ms1tdFunIaiD6XhKLfosqpz42JBfPb dylYDbx4tgX8y6qndnp7/sdSV4PcuWbwU/pdWHBOFM4XEs+9D5wI7YHuQfCodER21Ad1 fgGeR37RvdSHfL+Ck2Qs9GNvLL8hBoeAQwKtPnmy2NZKkRSkb6KvFjua3htoWnLmeF5x bHsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id q8-20020a056402518800b0044c28ad39f8si16299324edd.238.2022.09.08.08.29.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 08:29:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 086743857C77 for ; Thu, 8 Sep 2022 15:29:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 2EEDF3858421 for ; Thu, 8 Sep 2022 15:29:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2EEDF3858421 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.93,300,1654588800"; d="diff'?scan'208";a="82550583" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 08 Sep 2022 07:29:18 -0800 IronPort-SDR: 0YTgr5VWOXEoqAqyJlHQ8/Q747BI8vAVSkQE5dXeQiSmuD1hi9E+4R2gop75cvDt17eCJx8FSL Fl+AwJMmjjN0zLU/PHJaDbm+VTgrmG0aRVzO1/i3TIKnDmJUPGBB9qfE5icTRVlzqTsongliW9 7yKD4ANWLWMEVR5Z98PH6nRb3f+r7f0veCClQaB3XrfS8fxiCPuTPgzPj3tJkXQJMa8LVLmA9g FUFUSQxXkyHyqscunbuV7lPQxnpOtjffxLN7fzZ/qAKaZc5JnRG53W/wxLMSv3zGlcEAo9BgDi 0eo= Message-ID: <56951572-c9b4-af2d-0e8b-9d47b87ba313@codesourcery.com> Date: Thu, 8 Sep 2022 23:29:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Content-Language: en-US From: Chung-Lin Tang To: gcc-patches , Joseph Myers Subject: [PATCH] optc-save-gen.awk: adjust generated array compare X-ClientProxiedBy: SVR-ORW-MBX-07.mgc.mentorg.com (147.34.90.207) To svr-orw-mbx-10.mgc.mentorg.com (147.34.90.210) X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandra Loosemore Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743415923096793166?= X-GMAIL-MSGID: =?utf-8?q?1743415923096793166?= Hi Joseph, Jan-Benedict reported a build-bot error for the nios2 port under --enable-werror-always: options-save.cc: In function 'bool cl_target_option_eq(const cl_target_option*, const cl_target_option*)': options-save.cc:9291:38: error: comparison between two arrays [-Werror=array-compare] 9291 | if (ptr1->saved_custom_code_status != ptr2->saved_custom_code_status | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ options-save.cc:9291:38: note: use unary '+' which decays operands to pointers or '&'component_ref' not supported by dump_decl[0] != &'component_ref' not supported by dump_decl[0]' to compare the addresses options-save.cc:9294:37: error: comparison between two arrays [-Werror=array-compare] 9294 | if (ptr1->saved_custom_code_index != ptr2->saved_custom_code_index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... This is due to an array-typed TargetSave state in config/nios2/nios2.opt: ... TargetSave enum nios2_ccs_code saved_custom_code_status[256] TargetSave int saved_custom_code_index[256] ... This patch adjusts the generated array state compare from 'ptr1->array' into '&ptr1->array[0]' in gcc/optc-save-gen.awk, seems sufficient to pass the tougher checks. Tested by ensuring the compiler builds, which should be sufficient here. Okay to commit to mainline? Thanks, Chung-Lin * optc-save-gen.awk: Adjust array compare to use '&ptr->name[0]' instead of 'ptr->name'. diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk index 233d1fbb637..27aabf2955e 100644 --- a/gcc/optc-save-gen.awk +++ b/gcc/optc-save-gen.awk @@ -1093,7 +1093,7 @@ for (i = 0; i < n_target_array; i++) { name = var_target_array[i] size = var_target_array_size[i] type = var_target_array_type[i] - print " if (ptr1->" name" != ptr2->" name ""; + print " if (&ptr1->" name"[0] != &ptr2->" name "[0]"; print " || memcmp (ptr1->" name ", ptr2->" name ", " size " * sizeof(" type ")))" print " return false;"; }