From: Richard Biener <richard.guenther@gmail.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Fix false -Wodr warnings
Date: Mon, 15 Apr 2019 12:06:00 -0000 [thread overview]
Message-ID: <CAFiYyc25=h4EZ1KXg3T=MmU9ARubRsmmsrMxbXXBM+L_G8SDPA@mail.gmail.com> (raw)
In-Reply-To: <20190414205904.ojeyug5rlayaig4q@kam.mff.cuni.cz>
On Sun, Apr 14, 2019 at 10:59 PM Jan Hubicka <hubicka@ucw.cz> wrote:
>
> Hi,
> this patch fixes false warning that is output when different -std
> settings are used. In this case C++ FE produces same declaration in
> different representations which differ by 0 sized fileds only.
> The patch makes them to be ignored (and I checked we ignore them for
> canonical type merging too)
>
> Bootstrapped/regtested x86_64-linux, comitted.
The testcase is bogus
WARNING: lto.exp does not support dg-do
WARNING: lto.exp does not support dg-options in primary source file
> Honza
>
> PR lto/89358
> * g++.dg/lto/pr89358_0.C: New testcase.
> * g++.dg/lto/pr89358_1.C: New testcase.
> * ipa-devirt.c (skip_in_fields_list_p): New.
> (odr_types_equivalent_p): Use it.
> Index: testsuite/g++.dg/lto/pr89358_0.C
> ===================================================================
> --- testsuite/g++.dg/lto/pr89358_0.C (nonexistent)
> +++ testsuite/g++.dg/lto/pr89358_0.C (working copy)
> @@ -0,0 +1,11 @@
> +/* { dg-do link } */
> +/* { dg-options "-std=c++17" } */
> +#include <map>
> +
> +extern void test();
> +
> +int main()
> +{
> + std::map<int, int> m;
> + test();
> +}
> Index: testsuite/g++.dg/lto/pr89358_1.C
> ===================================================================
> --- testsuite/g++.dg/lto/pr89358_1.C (nonexistent)
> +++ testsuite/g++.dg/lto/pr89358_1.C (working copy)
> @@ -0,0 +1,7 @@
> +/* { dg-options "-std=c++14" } */
> +#include <map>
> +
> +void test()
> +{
> + std::map<int, int> m;
> +}
> Index: ipa-devirt.c
> ===================================================================
> --- ipa-devirt.c (revision 270324)
> +++ ipa-devirt.c (working copy)
> @@ -1282,6 +1282,24 @@ warn_types_mismatch (tree t1, tree t2, l
> inform (loc_t2, "the incompatible type is defined here");
> }
>
> +/* Return true if T should be ignored in TYPE_FIELDS for ODR comparsion. */
> +
> +static bool
> +skip_in_fields_list_p (tree t)
> +{
> + if (TREE_CODE (t) != FIELD_DECL)
> + return true;
> + /* C++ FE introduces zero sized fields depending on -std setting, see
> + PR89358. */
> + if (DECL_SIZE (t)
> + && integer_zerop (DECL_SIZE (t))
> + && DECL_ARTIFICIAL (t)
> + && DECL_IGNORED_P (t)
> + && !DECL_NAME (t))
> + return true;
> + return false;
> +}
> +
> /* Compare T1 and T2, report ODR violations if WARN is true and set
> WARNED to true if anything is reported. Return true if types match.
> If true is returned, the types are also compatible in the sense of
> @@ -1548,9 +1566,9 @@ odr_types_equivalent_p (tree t1, tree t2
> f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
> {
> /* Skip non-fields. */
> - while (f1 && TREE_CODE (f1) != FIELD_DECL)
> + while (f1 && skip_in_fields_list_p (f1))
> f1 = TREE_CHAIN (f1);
> - while (f2 && TREE_CODE (f2) != FIELD_DECL)
> + while (f2 && skip_in_fields_list_p (f2))
> f2 = TREE_CHAIN (f2);
> if (!f1 || !f2)
> break;
next prev parent reply other threads:[~2019-04-15 11:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-15 6:48 Jan Hubicka
2019-04-15 12:06 ` Richard Biener [this message]
2019-04-16 12:51 Dominique d'Humières
2019-04-16 12:55 ` Jan Hubicka
2019-04-16 13:02 ` Richard Biener
2019-04-16 13:08 ` Jakub Jelinek
2019-04-16 14:18 ` Dominique d'Humières
2020-01-23 13:53 ` Thomas Schwinge
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='CAFiYyc25=h4EZ1KXg3T=MmU9ARubRsmmsrMxbXXBM+L_G8SDPA@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
/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).