From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107597 invoked by alias); 15 Apr 2019 11:55:54 -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 107146 invoked by uid 89); 15 Apr 2019 11:55:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=Bootstrapped X-HELO: mail-lj1-f182.google.com Received: from mail-lj1-f182.google.com (HELO mail-lj1-f182.google.com) (209.85.208.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 15 Apr 2019 11:55:52 +0000 Received: by mail-lj1-f182.google.com with SMTP id v13so15362787ljk.4 for ; Mon, 15 Apr 2019 04:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ex76l3ewnFU2a8wi1DEThUJUAj9bwm25a5Ul0nF3HGM=; b=k9EKZPOhTyFarQs9LZg26tRLXlB0jdd7A8M3lEHRDKh/lsnHMMEVo1h97+/D8fnuuI fJAbBQWC7+okpsijEQfBhakdExrqHzRPQ84MUPn7aOODECwHpdVqOTaiUyr7DEeJqYLm NfYtPMAGDFGjVv6S6NWV8oESROlTPh2fe1i1ypiK/mNmoqwOMO4kk01Vb1O1FQqGAJfd SY5xHMykgBWPvyPbaEZA6RbyiRrATeFLDeUSQhe2gkBcxZu+GBPnUMTyo6sRDLQ14iEr p1peeArvVjqk2tAyT6tM6pxkwf21oxB6YIq54gpoUJDq7Snl8/0WOQMDaQGtdHpHL/GF E1dA== MIME-Version: 1.0 References: <20190414205904.ojeyug5rlayaig4q@kam.mff.cuni.cz> In-Reply-To: <20190414205904.ojeyug5rlayaig4q@kam.mff.cuni.cz> From: Richard Biener Date: Mon, 15 Apr 2019 12:06:00 -0000 Message-ID: Subject: Re: Fix false -Wodr warnings To: Jan Hubicka Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00584.txt.bz2 On Sun, Apr 14, 2019 at 10:59 PM Jan Hubicka 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 > + > +extern void test(); > + > +int main() > +{ > + std::map 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 > + > +void test() > +{ > + std::map 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;