From patchwork Wed Nov 9 17:37:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 124635 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 54899B6F7C for ; Thu, 10 Nov 2011 04:37:39 +1100 (EST) Received: (qmail 21121 invoked by alias); 9 Nov 2011 17:37:37 -0000 Received: (qmail 21111 invoked by uid 22791); 9 Nov 2011 17:37:37 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Nov 2011 17:37:24 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pA9HbOjn006191 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Nov 2011 12:37:24 -0500 Received: from localhost (ovpn-116-17.ams2.redhat.com [10.36.116.17]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pA9HbMEB015690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Nov 2011 12:37:23 -0500 Received: by localhost (Postfix, from userid 500) id EE30929C12B; Wed, 9 Nov 2011 18:37:21 +0100 (CET) From: Dodji Seketeli To: Jason Merrill Cc: GCC Patches Subject: [PATCH] PR c++/51043 - ICE in LTO X-URL: http://www.redhat.com Date: Wed, 09 Nov 2011 18:37:21 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) 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 Hello, LTO crashes during debug info generation while seamlessly trying to see if an anonymous union type has template info, using the TYPE_TEMPLATE_INFO accessor. That type's TYPE_NAME is NULL and we TYPE_TEMPLATE_INFO shouldn't crash on that. The first hunk (the change to TYPE_ALIAS_P) is what's strictly necessary to fix this. I went on to make the other part of TYPE_TEMPLATE_INFO that uses TYPE_NAME to be robust as well, in the second hunk. No test is needed because this was regressing g++.dg/lto/20100423-3.C. Bootstrapped and tested on powerpc64-unknown-linux-gnu against trunk. From: Dodji Seketeli Date: Wed, 9 Nov 2011 15:58:08 +0100 Subject: [PATCH] PR c++/51043 - ICE in LTO * cp-tree.h (TYPE_ALIAS_P, TYPE_TEMPLATE_INFO): Don't crash on NULL TYPE_NAME. --- gcc/cp/cp-tree.h | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 32d08ca..9410e54 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2550,8 +2550,9 @@ extern void decl_shadowed_for_var_insert (tree, tree); /* Nonzero for a type which is an alias for another type; i.e, a type which declaration was written 'using name-of-type = another-type'. */ -#define TYPE_ALIAS_P(NODE) \ - (TYPE_P (NODE) \ +#define TYPE_ALIAS_P(NODE) \ + (TYPE_P (NODE) \ + && TYPE_NAME (NODE) \ && TYPE_DECL_ALIAS_P (TYPE_NAME (NODE))) /* For a class type: if this structure has many fields, we'll sort them @@ -2605,15 +2606,15 @@ extern void decl_shadowed_for_var_insert (tree, tree); ->template_info) /* Template information for an ENUMERAL_, RECORD_, or UNION_TYPE. */ -#define TYPE_TEMPLATE_INFO(NODE) \ - (TREE_CODE (NODE) == ENUMERAL_TYPE \ - ? ENUM_TEMPLATE_INFO (NODE) : \ - (TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM \ - ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) : \ - ((CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE)) \ - ? CLASSTYPE_TEMPLATE_INFO (NODE) \ - : (DECL_LANG_SPECIFIC (TYPE_NAME (NODE)) \ - ? (DECL_TEMPLATE_INFO (TYPE_NAME (NODE))) \ +#define TYPE_TEMPLATE_INFO(NODE) \ + (TREE_CODE (NODE) == ENUMERAL_TYPE \ + ? ENUM_TEMPLATE_INFO (NODE) : \ + (TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM \ + ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) : \ + ((CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE)) \ + ? CLASSTYPE_TEMPLATE_INFO (NODE) \ + : ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE))) \ + ? (DECL_TEMPLATE_INFO (TYPE_NAME (NODE))) \ : NULL_TREE)))) /* Set the template information for an ENUMERAL_, RECORD_, or