From patchwork Fri Jan 8 20:16:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 565061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 1E5DC1402A9 for ; Sat, 9 Jan 2016 07:16:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=v2MAVGWM; dkim-atps=neutral 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=CAh25oYgJSBMw2tD6Gzz9q04S1vIAYHrrslvbPrLI+w5P4akqj4Rc 3Bc9SwyLnROrjDt1ggVoAFNFnyBfcNAG4OLvtGrnpxUqOtCBjYWGu39lJY3CWsAQ 2koUDoB+EBd/YAInQ2Px3P0gETr1/NU3K50M7rQG0ilfULJEoHk2UA= 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=9F2J1sfBXLQ6qfpRlIjVjbXjCN8=; b=v2MAVGWMtft1jEmK5gCH /qsLoE+C3Y499hiFKF7EPUS6xJG1fWwK3EWCUhX7Z3HBK9zltCrXrWfuylF1UfYb V8PaENb3HL16N2i2O8+b11PkOT07Tgyd/5VBZjuWfLN2qgQ60QwvyheRv1+oqPB3 geQR/59vW9ntSGVj9gtitK8= Received: (qmail 128002 invoked by alias); 8 Jan 2016 20:16:51 -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 127987 invoked by uid 89); 8 Jan 2016 20:16:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 spammy=comdat, unsure, upset, Hx-languages-length:1383 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 08 Jan 2016 20:16:50 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id C3AF791FCC for ; Fri, 8 Jan 2016 20:16:48 +0000 (UTC) Received: from redhat.com (ovpn-204-137.brq.redhat.com [10.40.204.137]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u08KGi7i024440 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 8 Jan 2016 15:16:47 -0500 Date: Fri, 8 Jan 2016 21:16:43 +0100 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH for c++/69113 (ICE with -fno-weak) Message-ID: <20160108201643.GO31604@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Looking at the second Jason's patch here it seems that we should never set DECL_COMDAT on a decl that is !TREE_PUBLIC. The following test was breaking with -fno-weak, because there we set DECL_COMDAT on something that was !TREE_PUBLIC and the assert in vague_linkage_p was upset about that. I'm unsure about all this comdat business but the following fixes the ICE. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2016-01-08 Marek Polacek PR c++/69113 * decl2.c (comdat_linkage): Only set DECL_COMDAT if TREE_PUBLIC is set. * g++.dg/pr69113.C: New test. Marek diff --git gcc/cp/decl2.c gcc/cp/decl2.c index 9a07e1e..a7212ca0 100644 --- gcc/cp/decl2.c +++ gcc/cp/decl2.c @@ -1820,7 +1820,8 @@ comdat_linkage (tree decl) } } - DECL_COMDAT (decl) = 1; + if (TREE_PUBLIC (decl)) + DECL_COMDAT (decl) = 1; } /* For win32 we also want to put explicit instantiations in diff --git gcc/testsuite/g++.dg/pr69113.C gcc/testsuite/g++.dg/pr69113.C index e69de29..2f8331e 100644 --- gcc/testsuite/g++.dg/pr69113.C +++ gcc/testsuite/g++.dg/pr69113.C @@ -0,0 +1,17 @@ +// PR c++/69113 +// { dg-do compile } +// { dg-options "-fno-weak" } + +struct foo +{ + static void bar () + { + struct baz + { + static void m () + { + static int n; + } + }; + } +};