From patchwork Wed Mar 21 15:55:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 888925 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-475173-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=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uzo2I0BL"; 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 405vXm5Y1Sz9ry1 for ; Thu, 22 Mar 2018 02:55:51 +1100 (AEDT) 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=H/GzZxu6u/kts41O+RXKRA122pKYzuQ2lNZOw5xoXhoIiypJqe pBC14Wkr9pZc+h3uwZ9aTHFxjEEMXaEdv7PXJ5EQhfy0wCZB9Yox4kIZdLoETc9r ujNY5n9Q0ECtsdHCdfNo+JrYRIWrPYJvsYV8o1xlrHNeJNj6TxOCaZ0mg= 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=ZNQrqKZcn5Fw8ALR8AKRKCdX1WA=; b=uzo2I0BLAyqDVFwEIVpK V6r4/JmGdGUWRETmD9Wt68QJzbc9AfTsUw1XEqZMgLtSVqXA7f7l1xrOSCM6xFJw kmZ4RRGrkCxud9tR1qtThS2nywLmZxY3wrZIfUWO160hTiyYSLs1WhsxjRvp8FLQ eRQbTbmKnUXQpi2lLsLoZXk= Received: (qmail 97655 invoked by alias); 21 Mar 2018 15:55:44 -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 97645 invoked by uid 89); 21 Mar 2018 15:55:44 -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= X-HELO: mail-yw0-f174.google.com Received: from mail-yw0-f174.google.com (HELO mail-yw0-f174.google.com) (209.85.161.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Mar 2018 15:55:42 +0000 Received: by mail-yw0-f174.google.com with SMTP id u15so1819609ywg.8 for ; Wed, 21 Mar 2018 08:55: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=DShiWYZvdVGEblwoP+xLK9/+HQU8mKoC7X09tvZVSPE=; b=YB4H6NjXjyx0HpXCblPEbb49Hm5c6fxuyDs4Z1QhXmyMe9e33X2MdXwcYlZPX57txW 9Rv/gcAqrgsozZGiT/Ms05UfGfqYU7BxB4fwTD2caMaX1Kuqrn4Bj6ghTdruTGvV9iLL wHVKSNvivlM42nbBENsPKmUWPHtf2w/hi5Ok/vw7YUkMg6zQAtf2jbkfXiPHH93ab3bD qoei+BMQEFxcrz80zE3GOIOtl5Cso5pzuj3U7s5pfHqiKIVupeK4xFn4X2RARzxkJY6u /esb6NjK3f+c5YsQ5M5vGRRpwQQDJaaGnqDXTvO5Pl5jeRZYFdk2GAH1sVawxBBPCasY E8ug== X-Gm-Message-State: AElRT7Eah0F+RkeIb7FmxF2FMiF52PZMZ9+ZbBs9YYwFM95eeyETh9x5 oMqVYN0vgZoRcXRCZqvsSUw= X-Google-Smtp-Source: AG47ELsz8+tbeKTHwtyQGu1jsvRBp1k7EYHjUYqBoqV3q0FaoqbSGdc1nuVnfiIfGfg271aqo9CTnA== X-Received: by 10.129.116.3 with SMTP id p3mr11905715ywc.467.1521647740523; Wed, 21 Mar 2018 08:55:40 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::2:9c2a]) by smtp.googlemail.com with ESMTPSA id g77sm1656661ywe.79.2018.03.21.08.55.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Mar 2018 08:55:39 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [PR c++/84804] ICE with default arg, template friend & lambda Message-ID: <1e982dd5-0741-1de1-18a0-019258e19710@acm.org> Date: Wed, 21 Mar 2018 11:55:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 When instantiating a template we end up with a rather strange binding hierarchy -- the innermost binding is the template and the next one is the instantiation. Anyway, the upshot is we end up trying to push a tsubst'd lambda into the template itself and die because that's marked as a complete type. All somewhat suspicious. However, there as a 'scope == ts_lambda' escape on that check, and I'd removed it because it seemed unneeded. Sadly not. As we now never pass ts_lambda into do_pushtag, we have to inspect the type being pushed to determine this check. This gets us back to the older behaviour, but at least we push into the instantiation, not the template because of changes I made earlier. nathan 2018-03-21 Nathan Sidwell PR c++/84804 * name-lookup.c (do_pushtag): Permit lambdas to be pushed into complete classes. PR c++/84804 * g++.dg/lookup/pr84804.C: New. Index: cp/name-lookup.c =================================================================== --- cp/name-lookup.c (revision 258716) +++ cp/name-lookup.c (working copy) @@ -6436,7 +6436,8 @@ do_pushtag (tree name, tree type, tag_sc if (b->kind == sk_class) { - if (!TYPE_BEING_DEFINED (current_class_type)) + if (!TYPE_BEING_DEFINED (current_class_type) + && !LAMBDA_TYPE_P (type)) return error_mark_node; if (!PROCESSING_REAL_TEMPLATE_DECL_P ()) Index: testsuite/g++.dg/lookup/pr84804.C =================================================================== --- testsuite/g++.dg/lookup/pr84804.C (revision 0) +++ testsuite/g++.dg/lookup/pr84804.C (working copy) @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } +// PR c++/84804 ICE instantiating friend with default arg containing a lambda +template struct A +{ + // Note, instantiation injects this into ::, so there can only be one! + friend void foo(int i = []{ return 0;}()) {} +}; + +void bar() +{ + A<0> x; +}