From patchwork Wed Nov 7 16:27:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 994365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-489266-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B7TELxuM"; dkim-atps=neutral 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 42qsK93V2Jz9sD4 for ; Thu, 8 Nov 2018 03:27:56 +1100 (AEDT) Received: (qmail 126907 invoked by alias); 7 Nov 2018 16:27:51 -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 126888 invoked by uid 89); 7 Nov 2018 16:27:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=initiate, 7237, H*r:sk:32-v6so, HX-HELO:sk:mail-pg X-HELO: mail-pg1-f175.google.com Received: from mail-pg1-f175.google.com (HELO mail-pg1-f175.google.com) (209.85.215.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Nov 2018 16:27:49 +0000 Received: by mail-pg1-f175.google.com with SMTP id 32-v6so7532206pgu.2 for ; Wed, 07 Nov 2018 08:27:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=YtWR0qSDNwqRYl+Hlh0L/GnGGatxCRlBfpBeyCccyS8=; b=B7TELxuMhaJEA0VK1licRmqRWFRCt7F6emfP0cNW0bk9t8QXysP3+1+v+lVIkkFKFw 2f3eP0udi1Eg7bZDZjaGmjw/EJHRH02+N9WCoTHxxOCs3pjsBMzrFHjSf8+MH2YvoMG2 lQ2+lQvpoySNnYZL+oUi+7YalyEJ9Eoqk0qDOSSyHRoFI+Bao+XnaALnqBsuNkPtj/+2 Gdzq1fbCoyO7wZN1jVxf65+zvvKz5BpQ2309r2kQDM2e1uPu4eCC1PrbSG1fd6Omnbja cbZ1wttZxY8hSt0odREikWKGSLMjlKrHkatpmju9zr7a4jt+PqCVlzEuPykV/pGt9CH3 xuLw== Received: from [192.168.3.137] (ip-66-181-21-210.cust.i2bnetworks.com. [66.181.21.210]) by smtp.googlemail.com with ESMTPSA id z9-v6sm1195402pfg.174.2018.11.07.08.27.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 08:27:23 -0800 (PST) Sender: Nathan Sidwell To: GCC Patches From: Nathan Sidwell Subject: [PR C++/87904] lookup ICE Message-ID: Date: Wed, 7 Nov 2018 08:27:14 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 My recent relaxing of overload ordering broken an invariant that unhiding a hidden decl was assuming. Fixed thusly. nathan 2018-11-07 Nathan Sidwell PR c++/87904 * cp-tree.h (struct tree_overload): Fix comment. * tree.c (ovl_iterator::reveal_node): Propagate OVL_DEDUP_P. PR c++/87904 * g++.dg/lookup/pr87904.C: New. Index: gcc/cp/cp-tree.h =================================================================== --- gcc/cp/cp-tree.h (revision 265851) +++ gcc/cp/cp-tree.h (working copy) @@ -723,8 +723,7 @@ typedef struct ptrmem_cst * ptrmem_cst_t #define OVL_SINGLE_P(NODE) \ (TREE_CODE (NODE) != OVERLOAD || !OVL_CHAIN (NODE)) -/* OVL_HIDDEN_P nodes come first, then OVL_USING_P nodes, then regular - fns. */ +/* OVL_HIDDEN_P nodes come before other nodes. */ struct GTY(()) tree_overload { struct tree_common common; Index: gcc/cp/tree.c =================================================================== --- gcc/cp/tree.c (revision 265851) +++ gcc/cp/tree.c (working copy) @@ -2261,13 +2261,17 @@ ovl_iterator::reveal_node (tree overload OVL_HIDDEN_P (node) = false; if (tree chain = OVL_CHAIN (node)) - if (TREE_CODE (chain) == OVERLOAD - && (OVL_USING_P (chain) || OVL_HIDDEN_P (chain))) + if (TREE_CODE (chain) == OVERLOAD) { - /* The node needs moving, and the simplest way is to remove it - and reinsert. */ - overload = remove_node (overload, node); - overload = ovl_insert (OVL_FUNCTION (node), overload); + if (OVL_HIDDEN_P (chain)) + { + /* The node needs moving, and the simplest way is to remove it + and reinsert. */ + overload = remove_node (overload, node); + overload = ovl_insert (OVL_FUNCTION (node), overload); + } + else if (OVL_DEDUP_P (chain)) + OVL_DEDUP_P (node) = true; } return overload; } Index: gcc/testsuite/g++.dg/lookup/pr87904.C =================================================================== --- gcc/testsuite/g++.dg/lookup/pr87904.C (nonexistent) +++ gcc/testsuite/g++.dg/lookup/pr87904.C (working copy) @@ -0,0 +1,21 @@ +// PR c++ 87904 ICE failing to initiate deduping + +namespace X { + void Foo (char); +} + +struct B { + friend void Foo (int); +}; + +using X::Foo; + +void Foo (float); +void Foo(int); + +void frob () +{ + using namespace X; + + Foo (1); +}