From patchwork Thu Mar 1 21:37:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 880125 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-474127-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="gtkE0Sf/"; 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 3zsm4h4NsQz9s76 for ; Fri, 2 Mar 2018 08:37:55 +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=He2rNT+uYSBUHKmbk0enOUs3fukuTheZlvwZ4+xdEeDP6ms5cr E/6qkRH5Tryuo+UpNBb3fCSsNX6ZqZ6LGtU625Hq1kk7tXFvj+jUS8VfYssFuU7K gT4/mHM9yhkt0R4GczmSgdy/TnrPhy+zrHiqxSFLu+Qm+rMuVwJlJUSiw= 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=+VGkRuIZIK5HceV6qAswSs6pcgY=; b=gtkE0Sf/Z112sa8cpaJ9 ilNVOZKw7pg1votHvHd7RtMi29kUNrH7ltAv3bd+Hmypc7wvF71rMWkCY0y3dQP8 7njodH/Qy/8JGu/2YhhKCN0s1kctVU4rOgiHYJwHMITUQjhRmbkaucGJeRZB19fe lDl1hoGL1ZfLF483RTp6P/o= Received: (qmail 64721 invoked by alias); 1 Mar 2018 21:37:48 -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 64711 invoked by uid 89); 1 Mar 2018 21:37:47 -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-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; Thu, 01 Mar 2018 21:37:46 +0000 Received: by mail-yw0-f182.google.com with SMTP id j143so2633923ywb.4 for ; Thu, 01 Mar 2018 13:37:46 -0800 (PST) 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=U8tkv06NUZ/NuajS1IHDaoqfunEkAR2FqdD50wONyHU=; b=dT5M45ul57w2v2bopSgBJTIGzJ62re/A/FfJ1Hr3vibj+vaFrq7YQzDC3QELSdYKXb pgtlvvwIGy9kjqLGEdiygzGE6qKxYhgzCqLVae/oGFIapAboZO12Ux4TzWe2JfO3Z5+s JRr8s4hok3YpKRLocDSU1MXqWj8yvDmNb0u60TFIlkLwthTJhMwhaaePmJaS+UAM3fXY 2DdMpCu8XlcjFj+tCJQuYtjqLiLBTQKNXvrWWdMLT1IdjzwcQJJlQFsqh26zIL8JUAy2 J2FGiSrLIThrXIl59CKpQ54mmT1/wB34wmBaX3PA8xabeQH8kCMEJwEkLgVObi7q4GrC 2OCA== X-Gm-Message-State: APf1xPAKaTvjn13kTKvAhs0ohGvEGLS1eiwFK1Ese27qolrdhBHtTSLb 0Sgxwu0R2BJgn0AE9PWcCcU= X-Google-Smtp-Source: AG47ELt1W9piD+I3ZOcEJGbGuwKLUnPyzo2Wgtkm0Kk8OnhZOh8OteYhbKJM6IczJvwYlL/902jbxQ== X-Received: by 10.129.62.14 with SMTP id l14mr2404798ywa.34.1519940264316; Thu, 01 Mar 2018 13:37:44 -0800 (PST) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3:acb8]) by smtp.googlemail.com with ESMTPSA id k2sm1896620ywi.52.2018.03.01.13.37.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 13:37:43 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: [PR c++/84434] ICE with deduction guide Message-ID: <30446d31-fe5e-1dc5-6c16-27454978e6db@acm.org> Date: Thu, 1 Mar 2018 16:37:41 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 This crash was caused by unexpectedly seeing a USING_DECL. Normally we want to make dependent using-decls visible to name lookup, so we know to defer things to instantiation time. But here we're (a) explicitly looking inside uninstantiated templates and (b) want to know the ctors the template definitely has. so we should ignore the dependent inherited ctor. Before my name reworking, the lookup during the deduction guide generation never saw the using decl, as it never made it into the special CONSTRUCTOR_SLOT. nathan 2018-03-01 Nathan Sidwell PR c++/84434 * name-lookup.c (member_vec_dedup): Remove manually peeled iteration. Ignore dependent ctor inheritance. PR c++/84434 * g++.dg/template/pr84434.C: New. Index: cp/name-lookup.c =================================================================== --- cp/name-lookup.c (revision 258100) +++ cp/name-lookup.c (working copy) @@ -1591,68 +1591,58 @@ member_vec_dedup (vec *memb if (!len) return; - tree current = (*member_vec)[0], name = OVL_NAME (current); - tree next = NULL_TREE, next_name = NULL_TREE; - for (unsigned jx, ix = 0; ix < len; - ix = jx, current = next, name = next_name) + tree name = OVL_NAME ((*member_vec)[0]); + for (unsigned jx, ix = 0; ix < len; ix = jx) { + tree current = NULL_TREE; tree to_type = NULL_TREE; tree to_using = NULL_TREE; tree marker = NULL_TREE; - if (IDENTIFIER_CONV_OP_P (name)) - { - marker = current; - current = OVL_CHAIN (current); - name = DECL_NAME (OVL_FUNCTION (marker)); - gcc_checking_assert (name == conv_op_identifier); - } - if (TREE_CODE (current) == USING_DECL) + for (jx = ix; jx < len; jx++) { - current = strip_using_decl (current); - if (is_overloaded_fn (current)) - current = NULL_TREE; - else if (TREE_CODE (current) == USING_DECL) + tree next = (*member_vec)[jx]; + if (jx != ix) { - to_using = current; - current = NULL_TREE; + tree next_name = OVL_NAME (next); + if (next_name != name) + { + name = next_name; + break; + } } - } - if (current && DECL_DECLARES_TYPE_P (current)) - { - to_type = current; - current = NULL_TREE; - } - - for (jx = ix + 1; jx < len; jx++) - { - next = (*member_vec)[jx]; - next_name = OVL_NAME (next); - if (next_name != name) - break; - - if (marker) + if (IDENTIFIER_CONV_OP_P (name)) { - gcc_checking_assert (OVL_FUNCTION (marker) - == OVL_FUNCTION (next)); + marker = next; next = OVL_CHAIN (next); } if (TREE_CODE (next) == USING_DECL) { + if (IDENTIFIER_CTOR_P (name)) + /* Dependent inherited ctor. */ + continue; + next = strip_using_decl (next); - if (is_overloaded_fn (next)) - next = NULL_TREE; - else if (TREE_CODE (next) == USING_DECL) + if (TREE_CODE (next) == USING_DECL) { to_using = next; - next = NULL_TREE; + continue; } + + if (is_overloaded_fn (next)) + continue; } - if (next && DECL_DECLARES_TYPE_P (next)) - to_type = next; + if (DECL_DECLARES_TYPE_P (next)) + { + to_type = next; + continue; + } + + if (!current) + current = next; } if (to_using) @@ -1671,13 +1661,15 @@ member_vec_dedup (vec *memb current = stat_hack (current, to_type); } - gcc_assert (current); - if (marker) + if (current) { - OVL_CHAIN (marker) = current; - current = marker; + if (marker) + { + OVL_CHAIN (marker) = current; + current = marker; + } + (*member_vec)[store++] = current; } - (*member_vec)[store++] = current; } while (store++ < len) Index: testsuite/g++.dg/template/pr84434.C =================================================================== --- testsuite/g++.dg/template/pr84434.C (revision 0) +++ testsuite/g++.dg/template/pr84434.C (working copy) @@ -0,0 +1,23 @@ +// PR c++/84434 ICE with deduction guide and dependent using decl +// { dg-do compile { target c++17 } } + +template class B { +public: + template B (U) {} +}; + +template +struct scope_guard : B { + using base_type = B; + + using base_type::base_type; + + ~scope_guard() = default; +}; + +template +scope_guard (T) -> scope_guard; + +void Frob () { + scope_guard (1); +}