From patchwork Tue Jun 6 15:10:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 771904 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 3whw9m5CxBz9s7B for ; Wed, 7 Jun 2017 01:10:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NnWJL3wE"; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=YXZ2ZLLLUcoXXghoXRtGJbO7Ci5q9DGXUm9ECkMN88dpZweifv s1SIArkSa+LJLq+NyYIY2qXbcU8Am05jzbWkrWML5Wi3/b0zznI97BDClSOnimMA 0iZXCWs8ifalhV8Cya7/h5nnDjR2Fbfyc1APTcLA1A4DqEukOtEqtLHpE= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=XKilqsLFxLGAokYGAwyX+KvkoXc=; b=NnWJL3wE3GgZL36lRLO0 YtL2Ut1HAXkNNWPNY9EIEyYYz4BaHmMdjbRSvRAUCuZyk1Iz6si3lPRAC3jb0lTK CCTOw20NSTJZ3viWVHGfc+6APrVX5U7Pw5UfBYfonaDqGNAEG2ExOlzYa335naLc 1To6xp1iKuZgAz1IOSrh05w= Received: (qmail 36478 invoked by alias); 6 Jun 2017 15:10:40 -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 36460 invoked by uid 89); 6 Jun 2017 15:10:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No 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=handsome, anticipated, dahl, jack X-HELO: mail-yw0-f182.google.com Received: from mail-yw0-f182.google.com (HELO mail-yw0-f182.google.com) (209.85.161.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Jun 2017 15:10:38 +0000 Received: by mail-yw0-f182.google.com with SMTP id 141so5917861ywe.2 for ; Tue, 06 Jun 2017 08:10:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=cNUnFBM84kaf4nI2O1Hw9E52H388pslCKrrXV/hnRxs=; b=CSE8fSvRmxM44CGWGO89oekYzxuSmgviieCO53slPgnyYP0gLpWu/LFGet5TAlrBYX trEMfPpMdwxvdhHygGMoy9Z8VBz037WaFSKxhElLNyDP/V5vUejpNx9cmMRrR1CpBrn2 Df5BQeHn7b3URxOEhC3S09nnI005jeQKnD+S8gsBz+kUrVdNWfNROixmWjt1Si+RcB+r cDXWHpdVizFYU04nteZttaU/w/U1bj/OF6x4FG5NJd9E5zi3u1UVw9RiM5ADucUJFKCj KDSqZdiKBbZqLMFoAeciASeQlgEbJQTAh7B4Q9Fq+MAW5zkPiQFtIdVfo4e7tVGSywlB F0AQ== X-Gm-Message-State: AODbwcBSfiVxUOaETVRytH0g1RG8ePTwaCAGYrmZ0SNQM0HHkXBZRpU4 p5MH4pPzIgUc04OD X-Received: by 10.13.218.133 with SMTP id c127mr3262144ywe.163.1496761840750; Tue, 06 Jun 2017 08:10:40 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::7:53e4]) by smtp.googlemail.com with ESMTPSA id u2sm5156780ywf.59.2017.06.06.08.10.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 08:10:40 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++/80979] ADL of friends Message-ID: <52683ee8-226b-629a-c882-5a47f8250227@acm.org> Date: Tue, 6 Jun 2017 11:10:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 This fixes 80979, and ICE in the new duplicate lookup matching code. That code is enabled when we discover using declarations are in play. And it was barfing on meeting an already-marked function. That function was in the lookup twice, which was a surprise. That had happened because the function was a friend, but not an invisible one. So we added it as part of the namespace ADL and also as when adding the class's friends. We only later discovered functions introduced by using declaration. The fix is to only add invisible friends during the class ADL. nathan 2017-06-06 Nathan Sidwell PR c++/80979 * name-lookup.c (adl_class_only): Don't add visible friends. Index: cp/name-lookup.c =================================================================== --- cp/name-lookup.c (revision 248914) +++ cp/name-lookup.c (working copy) @@ -801,6 +801,12 @@ name_lookup::adl_class_only (tree type) if (CP_DECL_CONTEXT (fn) != context) continue; + /* Only interested in anticipated friends. (Non-anticipated + ones will have been inserted during the namespace + adl.) */ + if (!DECL_ANTICIPATED (fn)) + continue; + /* Template specializations are never found by name lookup. (Templates themselves can be found, but not template specializations.) */ Index: testsuite/g++.dg/lookup/pr80979.C =================================================================== --- testsuite/g++.dg/lookup/pr80979.C (revision 0) +++ testsuite/g++.dg/lookup/pr80979.C (working copy) @@ -0,0 +1,26 @@ +// pr C++/80979 ICE with late discovery of using directives during ADL +// of a friend declaration. + +namespace Tiny { + class Handsome {}; + void Dahl (Handsome &, Handsome &); + + namespace Jack { + class Vladof { + friend void Dahl (Vladof &, Vladof &); + }; + void Dahl (Vladof &, Vladof &); + } + + struct BDonk {}; + + namespace Tina { + void Dahl (BDonk &, Jack::Vladof &); + } + using Tina::Dahl; +} + +void BoomBoom (Tiny::BDonk &vault, Tiny::Jack::Vladof &hunter) +{ + Dahl (vault, hunter); +}