From patchwork Sun Apr 14 20:59:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1085391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-499238-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DspB/d/H"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44j3sQ6h1Yz9s55 for ; Mon, 15 Apr 2019 06:59:16 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=NsPsn/TyOqwS/JFaJ9PODmyudfi8kucCipArhWjmEMlvNz+LPria3 +CWx/b3WWMvBUp5coTPUOFABFGvTO++cCcPJErchImI1wvxNRakn5sGnwq4Wqeub dCuHa8a06fs7vMpY8B6pzlIrzDy+i1zIAwguyUqDlLL9u/ZSkhedRc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=eTZ0zyPWUawJ9WocVKYoXdNU01o=; b=DspB/d/HcCXz6V1Y5DxK 2MBSj8/jFSYoWtjywKGfpG1Tp2F4CEKKT66Zau9q8ybHAcEDVcE5wzKu5tUggaKm jpDRg8XtSaazLz5kCwoMn+jyrtgXAjETx/25UBhD8zObiib+pOjium2kiA9HJ+Sy V5T+bThl/pqaVjoBz7cohVs= Received: (qmail 40182 invoked by alias); 14 Apr 2019 20:59:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 40174 invoked by uid 89); 14 Apr 2019 20:59:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_50, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=270324, violations, tree_chain, TREE_CHAIN X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 14 Apr 2019 20:59:06 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 3D559281F2B; Sun, 14 Apr 2019 22:59:04 +0200 (CEST) Date: Sun, 14 Apr 2019 22:59:04 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix false -Wodr warnings Message-ID: <20190414205904.ojeyug5rlayaig4q@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) 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. 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;