From patchwork Mon Oct 11 15:10:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 67429 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 A9B42B70A6 for ; Tue, 12 Oct 2010 02:11:01 +1100 (EST) Received: (qmail 16761 invoked by alias); 11 Oct 2010 15:10:58 -0000 Received: (qmail 16741 invoked by uid 22791); 11 Oct 2010 15:10:57 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, TW_CX, TW_FN X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Oct 2010 15:10:53 +0000 Received: from relay1.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 mx1.suse.de (Postfix) with ESMTP id AA7E093987; Mon, 11 Oct 2010 17:10:50 +0200 (CEST) Date: Mon, 11 Oct 2010 17:10:50 +0200 From: Martin Jambor To: GCC Patches Cc: jason@redhat.com Subject: [PATCH, PR 45562] Add two (cp_function_chain != NULL) checks Message-ID: <20101011151049.GB12977@virgil.arch.suse.de> Mail-Followup-To: GCC Patches , jason@redhat.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes 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 Hi, the problem with PR 45562 seems to be that some template binding invoked late because of a compare debug dump assumes that if cfun is non-NULL so is cfun->language which is accessed through macro cp_function_chain. The patch below adds a check for non-NULLness of cp_function_chain to two places that already test cfun. Looking at the definition of macro current_class_ptr which already does both I believe this is correct or at least an already used and admissible workaround. Because of the compare-debug flag I thought that any testcase would be a rather fragile one and not all that much beneficial and so I did not include one. I'm running a bootstrap and testsuite now but because of the nature of the patch I do not expect any problems. OK for trunk? Thanks, Martin 2010-10-10 Martin Jambor PR c++/45562 * cp/cp-tree.h (current_class_ref): Check that cp_function_chain is non-NULL. * cp/call.c (build_cxx_call): Likewise. Index: icln/gcc/cp/call.c =================================================================== --- icln.orig/gcc/cp/call.c +++ icln/gcc/cp/call.c @@ -6082,7 +6082,8 @@ build_cxx_call (tree fn, int nargs, tree fndecl = get_callee_fndecl (fn); if ((!fndecl || !TREE_NOTHROW (fndecl)) && at_function_scope_p () - && cfun) + && cfun + && cp_function_chain) cp_function_chain->can_throw = 1; /* Check that arguments to builtin functions match the expectations. */ Index: icln/gcc/cp/cp-tree.h =================================================================== --- icln.orig/gcc/cp/cp-tree.h +++ icln/gcc/cp/cp-tree.h @@ -1055,7 +1055,8 @@ struct GTY(()) language_function { (cfun && cp_function_chain \ ? cp_function_chain->x_current_class_ptr : NULL_TREE) #define current_class_ref \ - (cfun ? cp_function_chain->x_current_class_ref : NULL_TREE) + ((cfun && cp_function_chain) \ + ? cp_function_chain->x_current_class_ref : NULL_TREE) /* The EH_SPEC_BLOCK for the exception-specifiers for the current function, if any. */