public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Jason Merrill <jason@redhat.com>, Martin Sebor <msebor@gmail.com>,
	Eric	Gallager <egall@gwmail.gwu.edu>,
	gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] v3: C/C++: add fix-it hints for missing '&' and '*' (PR c++/87850)
Date: Tue, 20 Nov 2018 22:05:00 -0000	[thread overview]
Message-ID: <1542751554.4619.83.camel@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1811200243080.10031@digraph.polyomino.org.uk>

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

  reply	other threads:[~2018-11-20 22:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-09 22:36 [PATCH] " David Malcolm
2018-11-10  7:01 ` Eric Gallager
2018-11-11 18:01   ` Martin Sebor
2018-11-11 21:02     ` David Malcolm
2018-11-12 21:32       ` Martin Sebor
2018-11-13 21:34         ` Jason Merrill
2018-11-15 21:48           ` [PATCH] v2: " David Malcolm
2018-11-16 18:13             ` Jason Merrill
2018-11-19 21:23               ` [PATCH] v3: " David Malcolm
2018-11-20  2:46                 ` Joseph Myers
2018-11-20 22:05                   ` David Malcolm [this message]
2018-11-20 22:23                     ` Joseph Myers
2018-11-30 23:01                       ` [PATCH] v4: " David Malcolm
2018-12-01 18:38                         ` Jason Merrill
2018-12-03 22:14                           ` Joseph Myers
2018-12-05 16:03                             ` Jason Merrill
2018-12-05 16:18                               ` David Malcolm
2018-11-21  0:36                 ` [PATCH] v3: " Jeff Law
2018-11-21  0:39                 ` Martin Sebor
2018-11-30 15:27                   ` David Malcolm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1542751554.4619.83.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=egall@gwmail.gwu.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=msebor@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).