From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 5422F3858D1E for ; Thu, 18 Aug 2022 15:34:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5422F3858D1E 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,247,1654588800"; d="scan'208";a="84281665" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 18 Aug 2022 07:34:19 -0800 IronPort-SDR: DMFM1KsC+VP3YSYUfaUaikOv1+lWYruJlchiCar7RElNMPHUtGeYEN51ivQC+Wb+cC8rV/hD0w NTwxheg1vr+GAbCWleBI41hGoE6fmD7A+SmeeJyZfe7CZzHDa3thqTx1fn2eAuYnO/E3WQpUS4 AhnWd6iWa3dO9PRuNvetA9FSKlqcUy/Zx6op9eBpAZ1agUDom+qasUr8f7YVTEYQpr3riKKhuY Oizx9zQBNhjOPQi1aiCWeQ2Ik98eotfy/nCTegYcrGemSruPzZejSHCIgqf6NGZxI7wdo3figt HOg= Date: Thu, 18 Aug 2022 15:34:15 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: "Jose E. Marchesi" CC: Subject: Re: [PATCH V2] Add warning options -W[no-]compare-distinct-pointer-types In-Reply-To: <87a681d7tf.fsf_-_@oracle.com> Message-ID: References: <87mtciu23z.fsf@oracle.com> <87a681d7tf.fsf_-_@oracle.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3117.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, 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: , X-List-Received-Date: Thu, 18 Aug 2022 15:34:23 -0000 On Thu, 18 Aug 2022, Jose E. Marchesi via Gcc-patches wrote: > diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc > index de8780a1502..04af02add37 100644 > --- a/gcc/c/c-typeck.cc > +++ b/gcc/c/c-typeck.cc > @@ -12397,7 +12397,8 @@ build_binary_op (location_t location, enum tree_code code, > } > else > /* Avoid warning about the volatile ObjC EH puts on decls. */ > - if (!objc_ok) > + if (!objc_ok > + && warn_compare_distinct_pointer_types) > pedwarn (location, 0, > "comparison of distinct pointer types lacks a cast"); > > @@ -12517,8 +12518,9 @@ build_binary_op (location_t location, enum tree_code code, > int qual = ENCODE_QUAL_ADDR_SPACE (as_common); > result_type = build_pointer_type > (build_qualified_type (void_type_node, qual)); > - pedwarn (location, 0, > - "comparison of distinct pointer types lacks a cast"); > + if (warn_compare_distinct_pointer_types) > + pedwarn (location, 0, > + "comparison of distinct pointer types lacks a cast"); I think this should use OPT_Wcompare_distinct_pointer_types in place of 0, and then you shouldn't need to check warn_compare_distinct_pointer_types (as well as the diagnostic then automatically telling the user what option controls it). -- Joseph S. Myers joseph@codesourcery.com