From patchwork Thu Mar 17 15:31:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 599106 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qQsm46WNMz9sD3 for ; Fri, 18 Mar 2016 02:32:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CGopRZ+t; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=XAx9Sqy9G/66 eUQcUDSwNMhTAPgGQAy21BMi2KNbA1Tjoa/g8mU73Xa0aDOrIsfyrXl9EPu6yDXW S3mfSSjANZ3D9UhwLBu4a8muKZkQUJ+yUn0g64X+DXC2o0LLtJOPAepvcctrZoGj AN+l0RvsGOZUgG5Gx8Q/kWrMS7G4118= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=g/FMLkMvEGmVyQjiqY hEz+8+GVc=; b=CGopRZ+tYm6SPDk065KtVb+F9yjdXXf/7v9ZhwMJOH4Ql6MIDX cVB2pXgg2rNDL4vB59EMfELJywO5tIpnktdypTj8RIg4LmXbJ4M7yy5XVpZfQMpZ Ilj5gVHJRuXsG9C9lGsCnjWek2rshIU4LYbElbgiA5v5EXasS4Es2DC/A= Received: (qmail 16454 invoked by alias); 17 Mar 2016 15:31:53 -0000 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 Received: (qmail 8510 invoked by uid 89); 17 Mar 2016 15:31:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=qualifying, H*p:D*cx, erroneously, H*Ad:U*patrick X-HELO: mail-qg0-f50.google.com Received: from mail-qg0-f50.google.com (HELO mail-qg0-f50.google.com) (209.85.192.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 17 Mar 2016 15:31:37 +0000 Received: by mail-qg0-f50.google.com with SMTP id u110so74776747qge.3 for ; Thu, 17 Mar 2016 08:31:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tEZY4AZQRVBDD5A4KqHQHi/R9oBC7PP8CtT0ZqtL1So=; b=d5lUxW1vFygGkLCmuHwgKCqfTwHAdr19p5U+DEDSu9gJfMmdxK3xn7uaSnBirorAaP sAVvy0qsCUnfyih+vJ0MCi28rCTvawtZviO+Re8U5warSQl1XcxRQ0Ptw1tY0xWhUkI8 eRU+uLz2+8mVhkVLW4T/TeC60mOHoy4vrl/3WGodlHLPfNJvs7tjTn9P8H3lpsdIkEZr GB9UNpvF1ak1oty0SNQdGHe8MZrCGz01TsbQoNAYxvbFo99o4tVDXWVqiaOhW3C/7J5s jihw0WQJ6kzGxgvzDAs7icsv9C8O6GJmhuAzJBNO5qY4vYCI4Va9XqcaNBThyDZM4zWn 6OnA== X-Gm-Message-State: AD7BkJLYs7I7iiL5tFhjgivt7fZSvdY0guOKDOYJgXb18e6fm9zPMTgr7Eeki+AcxNzgTw== X-Received: by 10.140.238.76 with SMTP id j73mr16095060qhc.49.1458228695132; Thu, 17 Mar 2016 08:31:35 -0700 (PDT) Received: from localhost.localdomain (ool-4353abbc.dyn.optonline.net. [67.83.171.188]) by smtp.gmail.com with ESMTPSA id c18sm3967585qgd.49.2016.03.17.08.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Mar 2016 08:31:34 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] Fix PR c++/70205 (ICE on valid call to qualified static member function) Date: Thu, 17 Mar 2016 11:31:28 -0400 Message-Id: <1458228688-14054-1-git-send-email-patrick@parcs.ath.cx> adjust_result_of_qualified_name_lookup() may erroneously clobber the BASELINK_BINFO of its DECL argument if the BINFO_TYPE of DECL is an ambiguous base of the qualifying scope that's used to refer to DECL. But as the comment in the function suggests, this base ambiguity is not necessarily a problem since DECL may later get resolved to a static member function. This patch makes updating the BASELINK_BINFO of DECL conditional on the validity of the return value of the 2nd call to lookup_base as well as on the 1st call. Not sure if we should still update BASELINK_ACCESS_BINFO if the 2nd call fails, but I suppose it shouldn't hurt. I can't come up with a test case where this would make a difference. Bootstrap + regtest in progress on x86_64-pc-linux-gnu, also will test against Boost, does this look OK to commit if testing succeeds? gcc/cp/ChangeLog: PR c++/70205 * search.c (adjust_result_of_qualified_name_lookup): Don't update the BASELINK_BINFO of DECL if the second call to lookup_base fails. gcc/testsuite/ChangeLog: PR c++/70205 * g++.dg/lookup/pr70205.C: New test. --- gcc/cp/search.c | 4 +++- gcc/testsuite/g++.dg/lookup/pr70205.C | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/lookup/pr70205.C diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 7924611..503e34b 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1751,9 +1751,11 @@ adjust_result_of_qualified_name_lookup (tree decl, if (base && base != error_mark_node) { BASELINK_ACCESS_BINFO (decl) = base; - BASELINK_BINFO (decl) + tree decl_binfo = lookup_base (base, BINFO_TYPE (BASELINK_BINFO (decl)), ba_unique, NULL, tf_none); + if (decl_binfo && decl_binfo != error_mark_node) + BASELINK_BINFO (decl) = decl_binfo; } } diff --git a/gcc/testsuite/g++.dg/lookup/pr70205.C b/gcc/testsuite/g++.dg/lookup/pr70205.C new file mode 100644 index 0000000..3bda7fb --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr70205.C @@ -0,0 +1,11 @@ +// PR c++/70205 + +struct A +{ +protected: + static void f (); +}; +struct B : A { }; +struct C : A { }; +struct D : C, B { void a () { D::f (); } }; +struct E : D { void b () { D::f (); } };