public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Jason Merrill <jason@redhat.com>
Cc: Jan Hubicka <hubicka@ucw.cz>, gcc-patches@gcc.gnu.org
Subject: Re: False ODR violation positives on anonymous namespace types
Date: Tue, 12 May 2015 14:13:00 -0000	[thread overview]
Message-ID: <20150512140313.GA26537@kam.mff.cuni.cz> (raw)
In-Reply-To: <55520517.1020507@redhat.com>

> On 05/11/2015 04:39 PM, Jan Hubicka wrote:
> >What happens in LTO is that lto-symtab decide to merge the two declarations of
> >foo.  At this time it has chance to output the warning.  For that it needs to
> >be able to work out that these declarations are having different types, but
> >because LTO merge canonical types on structural basis, types_compatible_p
> >(long, int) will return true.
> 
> OK.  So I guess it makes sense to check built-in integer types as
> well, but compound types should be compared structurally.

Yes, agreed. 
  if (flag_lto_odr_type_mering
      && TREE_CODE (decl) == TYPE_DECL
      && DECL_NAME (decl)
      && decl == TYPE_NAME (TREE_TYPE (decl))
      && !is_lang_specific (TREE_TYPE (decl))
      /* Save some work. Names of builtin types are always derived from
         properties of its main variant.  A special case are integer types
         where mangling do make differences between char/signed char/unsigned
         char etc.  Storing name for these makes e.g.
         -fno-signed-char/-fsigned-char mismatches to be handled well.

         See cp/mangle.c:write_builtin_type for details.  */
      && (TREE_CODE (TREE_TYPE (decl)) != VOID_TYPE
          && TREE_CODE (TREE_TYPE (decl)) != BOOLEAN_TYPE
          && TREE_CODE (TREE_TYPE (decl)) != REAL_TYPE
          && TREE_CODE (TREE_TYPE (decl)) != FIXED_POINT_TYPE)
      && !TYPE_ARTIFICIAL (TREE_TYPE (decl))
      && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE)
      && !type_in_anonymous_namespace_p (TREE_TYPE (decl)))

I probably want to check

      /* Record, union and enumeration type have linkage that allows use
	 to check type_in_anonymous_namespace_p. Compound types
	 can be always compared structurally.
	 To save some work we compare builtin types properties of its main
	 variant.  A special case are integer types where mangling do make
	 differences between char/signed char/unsigned char etc.  Storing name
	 for these makes e.g.  -fno-signed-char/-fsigned-char mismatches to be
	 handled well.

         See cp/mangle.c:write_builtin_type for details.  */
      && ((RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
	   || TREE_CODE (TREE_TYPE (decl)) == ENUMERATION_TIME
	  && !type_in_anonymous_namespace_p (TREE_TYPE (decl)))
	  || TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE)

I will test this.  Thank you!
Honza
> 
> Jason

  reply	other threads:[~2015-05-12 14:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11 14:28 Jan Hubicka
2015-05-11 17:16 ` Jason Merrill
2015-05-11 17:46   ` Jan Hubicka
2015-05-11 17:54     ` Jason Merrill
2015-05-11 18:05       ` Jan Hubicka
2015-05-11 21:21         ` Jason Merrill
2015-05-11 21:52           ` Jan Hubicka
2015-05-12 13:51             ` Jason Merrill
2015-05-12 14:13               ` Jan Hubicka [this message]
2015-05-12 14:54                 ` Jan Hubicka
2015-05-12 16:07                   ` Jason Merrill
2015-05-12 16:27                     ` Jan Hubicka
2015-05-12 18:40                       ` Jan Hubicka

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=20150512140313.GA26537@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.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).