From patchwork Wed Nov 9 18:12:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 124651 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 774D51007DB for ; Thu, 10 Nov 2011 05:13:01 +1100 (EST) Received: (qmail 19153 invoked by alias); 9 Nov 2011 18:12:58 -0000 Received: (qmail 19137 invoked by uid 22791); 9 Nov 2011 18:12:56 -0000 X-SWARE-Spam-Status: No, hits=-7.1 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 18:12:43 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pA9IChql020570 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Nov 2011 13:12:43 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pA9ICg75020586 for ; Wed, 9 Nov 2011 13:12:43 -0500 Received: from [0.0.0.0] (ovpn-113-127.phx2.redhat.com [10.3.113.127]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pA9ICfRi017868 for ; Wed, 9 Nov 2011 13:12:42 -0500 Message-ID: <4EBAC298.30606@redhat.com> Date: Wed, 09 Nov 2011 13:12:40 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111001 Thunderbird/7.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/51029 (C++11 ICE with virtual base) 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 With this test, build_base_path was crashing because it (reasonably) assumed that if we're in a constructor with virtual bases, we can look at current_in_charge_parm. But we can't in a template, even when we've cleared processing_template_decl for the sake of fold_non_dependent_expr. So don't try. Tested x86_64-pc-linux-gnu, applying to trunk. commit b27a03c5dcd721810269a876fd7f91e0d5a068ba Author: Jason Merrill Date: Tue Nov 8 13:09:24 2011 -0500 PR c++/51029 * class.c (build_base_path): Don't ICE in fold_non_dependent_expr. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index f10a749..d2cf63c 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -359,6 +359,11 @@ build_base_path (enum tree_code code, V_BINFO. That offset is an entry in D_BINFO's vtable. */ tree v_offset; + /* In a constructor template, current_in_charge_parm isn't set, + and we might end up here via fold_non_dependent_expr. */ + if (fixed_type_p < 0 && !(cfun && current_in_charge_parm)) + fixed_type_p = 0; + if (fixed_type_p < 0 && in_base_initializer) { /* In a base member initializer, we cannot rely on the diff --git a/gcc/testsuite/g++.dg/template/virtual1.C b/gcc/testsuite/g++.dg/template/virtual1.C new file mode 100644 index 0000000..ee86bf3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/virtual1.C @@ -0,0 +1,14 @@ +// PR c++/51029 + +struct A +{ + void foo(); +}; + +struct B : virtual A +{ + template B() + { + foo(); + } +};