From patchwork Tue Oct 23 15:50:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 193530 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 9E7252C0109 for ; Wed, 24 Oct 2012 03:48:15 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351615696; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=navFClskfEvHjVekaGb4 TW7qInI=; b=CfeJuXbzRYm+A+UisLgfc5tqZRlmpSz7MICmdxKBgX9c76AzWKEh LNH1ogL+eppgT51bvSmbqHXSa6/ZtnXlFJlTRGlx53QMGl+7/0poChK3NQo4anH1 KC4NHvDPzpbc0TtmAGaqJWleWCyI88rWm4tqZhe73gT4kaFRGx90kgQ= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ObS6dfQy+evclEGUCEvGMrngvyoJ375StwH62ckiijYPOpRPjkUXFkBsz4QO0s axTdV7VATghJciEjUwDUvF1TE1n4d/ua7FGWZPtZMU0/k7H2DLZZzQynOVNeoqD/ S76ARbqw+YBsY/lASNNR0U0YRZmD/vL09LG0L63KNecwk=; Received: (qmail 25540 invoked by alias); 23 Oct 2012 16:48:11 -0000 Received: (qmail 25531 invoked by uid 22791); 23 Oct 2012 16:48:11 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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; Tue, 23 Oct 2012 16:48:06 +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 q9NGm5in026090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Oct 2012 12:48:06 -0400 Received: from zalov.redhat.com (vpn1-6-28.ams2.redhat.com [10.36.6.28]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9NFotTi020148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 23 Oct 2012 11:50:56 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id q9NFosoX022457 for ; Tue, 23 Oct 2012 17:50:54 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id q9NFosQX022456 for gcc-patches@gcc.gnu.org; Tue, 23 Oct 2012 17:50:54 +0200 Date: Tue, 23 Oct 2012 17:50:54 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] variably_modified_type_p tweak for cdtor cloning (PR debug/54828) Message-ID: <20121023155053.GS1752@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 following testcase ICEs, because the VLA ARRAY_TYPE in the ctor isn't considered variably_modified_type_p during cloning of the ctor when the types weren't gimplified yet. The size is a non-constant expression that has SAVE_EXPR of a global VAR_DECL in it, so when variably_modified_type_p is called with non-NULL second argument, it returns NULL, we share the ARRAY_TYPE in between the abstract ctor origin and and the base_ctor and comp_ctor clones, later on when gimplifying the first of the clones gimplify_one_sizepos actually replaces the expression with a local temporary VAR_DECL and from that point it is variably_modified_type_p in the base ctor. But it is a var from different function in the other ctor and var with a location in the abstract origin which causes dwarf2out.c ICE. This patch fixes it by returning true also for non-gimplified types where gimplify_one_sizepos is expected to turn that into a local temporary. It seems frontends usually call variably_modified_type_p with NULL as last argument, with non-NULL argument it is only used during tree-nested.c/omp-low.c (which happens after gimplification), tree-inline.c (which usually happens after gimplification, with the exception of cdtor cloning, at least can't find anything else). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-10-23 Jakub Jelinek PR debug/54828 * tree.c (RETURN_TRUE_IF_VAR): Return true also if !TYPE_SIZES_GIMPLIFIED (type) and _t is going to be gimplified into a local temporary. * g++.dg/debug/pr54828.C: New test. Jakub --- gcc/tree.c.jj 2012-10-19 11:01:07.000000000 +0200 +++ gcc/tree.c 2012-10-23 14:46:24.846195605 +0200 @@ -8467,14 +8467,21 @@ variably_modified_type_p (tree type, tre tree t; /* Test if T is either variable (if FN is zero) or an expression containing - a variable in FN. */ + a variable in FN. If TYPE isn't gimplified, return true also if + gimplify_one_sizepos would gimplify the expression into a local + variable. */ #define RETURN_TRUE_IF_VAR(T) \ do { tree _t = (T); \ if (_t != NULL_TREE \ && _t != error_mark_node \ && TREE_CODE (_t) != INTEGER_CST \ && TREE_CODE (_t) != PLACEHOLDER_EXPR \ - && (!fn || walk_tree (&_t, find_var_from_fn, fn, NULL))) \ + && (!fn \ + || (!TYPE_SIZES_GIMPLIFIED (type) \ + && !TREE_CONSTANT (_t) \ + && TREE_CODE (_t) != VAR_DECL \ + && !CONTAINS_PLACEHOLDER_P (_t)) \ + || walk_tree (&_t, find_var_from_fn, fn, NULL))) \ return true; } while (0) if (type == error_mark_node) --- gcc/testsuite/g++.dg/debug/pr54828.C.jj 2012-10-23 14:30:13.194012566 +0200 +++ gcc/testsuite/g++.dg/debug/pr54828.C 2012-10-23 14:30:07.000000000 +0200 @@ -0,0 +1,14 @@ +// PR debug/54828 +// { dg-do compile } +// { dg-options "-g" } + +struct T { T (); virtual ~T (); }; +struct S : public virtual T { S (); virtual ~S (); }; +int v; +void foo (char *); + +S::S () +{ + char s[v]; + foo (s); +}