From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109605 invoked by alias); 20 Nov 2018 22:05:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 109590 invoked by uid 89); 20 Nov 2018 22:05:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*f:sk:37RuEYB, H*f:2nMUVXThn, H*f:sk:8_CeurH, H*f:sk:1542662 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Nov 2018 22:05:57 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7A3A3082A38; Tue, 20 Nov 2018 22:05:55 +0000 (UTC) Received: from ovpn-116-30.phx2.redhat.com (ovpn-116-30.phx2.redhat.com [10.3.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5ADB61B6C; Tue, 20 Nov 2018 22:05:54 +0000 (UTC) Message-ID: <1542751554.4619.83.camel@redhat.com> Subject: Re: [PATCH] v3: C/C++: add fix-it hints for missing '&' and '*' (PR c++/87850) From: David Malcolm To: Joseph Myers Cc: Jason Merrill , Martin Sebor , Eric Gallager , gcc-patches List Date: Tue, 20 Nov 2018 22:05:00 -0000 In-Reply-To: References: <1542662581-41571-1-git-send-email-dmalcolm@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg01775.txt.bz2 On Tue, 2018-11-20 at 02:46 +0000, Joseph Myers wrote: > On Mon, 19 Nov 2018, David Malcolm wrote: > > > +/* C implementation of same_type_p. > > + Returns true iff TYPE1 and TYPE2 are the same type, in the > > usual > > + sense of `same'. */ > > + > > +bool > > +same_type_p (tree type1, tree type2) > > +{ > > + return comptypes (type1, type2) == 1; > > +} > > I don't think "compatible" and "same" are the same concept. Normally > in C > you'd be concerned with compatibility; "same type" is only used for > the > rule on duplicate typedefs, which uses > comptypes_check_different_types. The purpose here is to be able to offer fix-it hints for bogus code that's missing an '&' or a '*' prefix, and have that code live in c- common.c Jason wanted to avoid a pointer-equality test for types by using same_type_p to look through enums - but same_type_p is C++-specific. Should I do: (a) something like this for C: /* C implementation of same_type_p. Returns true iff TYPE1 and TYPE2 are the same type, or are compatible enough to be permitted in C11 typedef redeclarations. */ bool same_type_p (tree type1, tree type2) { bool different_types_p = false; int result = comptypes_check_different_types (type1, type2, &different_types_p); if (result == 1 && !different_types_p) return true; return false; } (b) provide a same_type_p for C that e.g. simply does pointer equality, (d) add a newly named function (e.g. "compatible_types_p", as C++ has a comptypes, but it has a 3rd param), or (d) fall back to simply doing pointer equality. Thanks Dave