From patchwork Wed Jan 11 03:09:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 135349 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 C124EB6EEC for ; Wed, 11 Jan 2012 14:10:21 +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=1326856223; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=xWjgLad Vjxaxk31rFy2Z5M+WZ+o=; b=LDK6rRPc1kBPdfq+lkEa+2mjlYXKvhg+iV9cPdM QkrwnUJix5hS++SLVPgxO1nPJWWpeg0UNfcapaZzyrVl8jWCAiyG57PWssOArl3K nKy+uhUus9la2oiNhtedpJ09/oNJ1tborqOnGYvZh/u0gazaPQt2E9v0DePLlS95 kd9w= 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:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=r8Zus4T/Wl19IcuhTIIfKwBqmVC+AISva2w6gCdZdx7uSH01qfU0CODxdU64je vKFTCK3n8d1WTEOjN3isgnxVFe17j0rKz7Z6dpYWj4Gtq5EmsLfyuJ3ILrP2sEIF WZHm0l5WMySJ4u7tdkiKndaGIdg5YZIoKvcDOJ7B+vytk=; Received: (qmail 16149 invoked by alias); 11 Jan 2012 03:10:14 -0000 Received: (qmail 16139 invoked by uid 22791); 11 Jan 2012 03:10:10 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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, 11 Jan 2012 03:09:54 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0B39rBS000536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 10 Jan 2012 22:09:54 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0B39rRX013963 for ; Tue, 10 Jan 2012 22:09:53 -0500 Received: from [0.0.0.0] (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q0B39pqZ032488 for ; Tue, 10 Jan 2012 22:09:52 -0500 Message-ID: <4F0CFD7F.9030301@redhat.com> Date: Tue, 10 Jan 2012 22:09:51 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/51614 (ICE with ambiguous 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 Here build_base_path expects that the binfo argument will designate a subobject of the expression argument, but that isn't the case here because the base is ambiguous. So let's complain about that instead of aborting. Tested x86_64-pc-linux-gnu, applying to trunk. commit 640c9c1f2824490323a8deb32170379ffeb2c399 Author: Jason Merrill Date: Tue Jan 10 14:45:48 2012 -0500 PR c++/51614 * class.c (build_base_path): Diagnose ambiguous base. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 79686a2..58c89d3 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -266,10 +266,25 @@ build_base_path (enum tree_code code, if (want_pointer) probe = TYPE_MAIN_VARIANT (TREE_TYPE (probe)); + if (code == PLUS_EXPR + && !SAME_BINFO_TYPE_P (BINFO_TYPE (d_binfo), probe)) + { + /* This can happen when adjust_result_of_qualified_name_lookup can't + find a unique base binfo in a call to a member function. We + couldn't give the diagnostic then since we might have been calling + a static member function, so we do it now. */ + if (complain & tf_error) + { + tree base = lookup_base (probe, BINFO_TYPE (d_binfo), + ba_unique, NULL); + gcc_assert (base == error_mark_node); + } + return error_mark_node; + } + gcc_assert ((code == MINUS_EXPR && SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), probe)) - || (code == PLUS_EXPR - && SAME_BINFO_TYPE_P (BINFO_TYPE (d_binfo), probe))); + || code == PLUS_EXPR); if (binfo == d_binfo) /* Nothing to do. */ diff --git a/gcc/testsuite/g++.dg/inherit/ambig1.C b/gcc/testsuite/g++.dg/inherit/ambig1.C new file mode 100644 index 0000000..3596bb5 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/ambig1.C @@ -0,0 +1,14 @@ +// PR c++/51614 + +struct A +{ + void foo(); +}; + +struct B : A {}; +struct C : A {}; + +struct D : B, C +{ + D() { A::foo(); } // { dg-error "ambiguous" } +};