From patchwork Fri Dec 9 09:16:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 130324 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]) by ozlabs.org (Postfix) with SMTP id E6AFE1007D6 for ; Fri, 9 Dec 2011 20:17:00 +1100 (EST) Received: (qmail 18611 invoked by alias); 9 Dec 2011 09:16:58 -0000 Received: (qmail 18603 invoked by uid 22791); 9 Dec 2011 09:16:58 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Dec 2011 09:16:44 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 064F98A95F for ; Fri, 9 Dec 2011 10:16:43 +0100 (CET) Date: Fri, 9 Dec 2011 10:16:42 +0100 (CET) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH][C++] Fix PR51262 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 The following fixes PR51262, the new type alias code does else if (CLASS_TYPE_P (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t))) which ICEs when t is a type with an anonymous name with -flto because we clear such TYPE_NAMEs during cp_free_lang_data. It turns out that doing so is no longer necessary because we now ignore names when merging canonical types (and thus C and C++ interoperate just fine). Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk? Thanks, Richard. 2011-12-09 Richard Guenther PR lto/51262 * tree.c (cp_free_lang_data): No longer clear anonymous names. * g++.dg/opt/pr51262.C: New testcase. Index: gcc/cp/tree.c =================================================================== --- gcc/cp/tree.c (revision 182117) +++ gcc/cp/tree.c (working copy) @@ -3479,17 +3479,6 @@ cp_free_lang_data (tree t) DECL_EXTERNAL (t) = 1; TREE_STATIC (t) = 0; } - if (CP_AGGREGATE_TYPE_P (t) - && TYPE_NAME (t)) - { - tree name = TYPE_NAME (t); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - /* Drop anonymous names. */ - if (name != NULL_TREE - && ANON_AGGRNAME_P (name)) - TYPE_NAME (t) = NULL_TREE; - } if (TREE_CODE (t) == NAMESPACE_DECL) { /* The list of users of a namespace isn't useful for the middle-end Index: gcc/testsuite/g++.dg/opt/pr51262.C =================================================================== --- gcc/testsuite/g++.dg/opt/pr51262.C (revision 0) +++ gcc/testsuite/g++.dg/opt/pr51262.C (revision 0) @@ -0,0 +1,21 @@ +// { dg-do compile } +// { dg-require-effective-target lto } +// { dg-options "-flto -g" } + +template < typename > void * +bar (int *p) +{ + union + { + int *p; + } + u; + u.p = p; + return u.p; +} + +void +foo (int *p) +{ + bar < void >(p); +}