From patchwork Sat Jul 20 14:42:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1134381 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-505364-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Oh9NOWSl"; 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 45rVwh2M4qz9sDB for ; Sun, 21 Jul 2019 00:43:14 +1000 (AEST) 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:subject:date:message-id:mime-version :content-transfer-encoding; q=dns; s=default; b=DSZCtoOOGpyOl77y 7Tlu1I1MEcA+0yM5RAOHHlTF2kEIomVD1TYXPJIdZuRda6eFeHxTZUZiLtw6ntIW jFmktzw9zlnN1h2pzqmsXskZmiNO1MDZ1RLILKMS7CeN4D/3l6fWcyoR6pMZ1uSm q/cCUFaAr9jkc6hUR9o3/x2hz0o= 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:subject:date:message-id:mime-version :content-transfer-encoding; s=default; bh=6g5/nc9neWYao6VhjhE41i FHSqU=; b=Oh9NOWSlyi8VwUOUQfLQhT7v+CFQIa5tkoIjcS6ZLnSmYDJpBxE4X2 KaAHi5lNmYoId50x2MkD7dfizAOIWysbXO47cjZ/cj4P+aEDYaxJnFzVwBNFHRNS gOr929R4j0CVuCc0sg9I1lSz9R7LSgc+eDfhZ3DeTLqpt2uxWOVGo= Received: (qmail 26230 invoked by alias); 20 Jul 2019 14:43:06 -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 26209 invoked by uid 89); 20 Jul 2019 14:43:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: mail-wr1-f66.google.com Received: from mail-wr1-f66.google.com (HELO mail-wr1-f66.google.com) (209.85.221.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 20 Jul 2019 14:43:04 +0000 Received: by mail-wr1-f66.google.com with SMTP id n9so35035259wru.0 for ; Sat, 20 Jul 2019 07:43:04 -0700 (PDT) Received: from localhost.localdomain ([46.183.103.8]) by smtp.gmail.com with ESMTPSA id o185sm32888422wmo.45.2019.07.20.07.43.00 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 20 Jul 2019 07:43:01 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix ICE on class template argument deduction with inherited ctor. Date: Sat, 20 Jul 2019 16:42:57 +0200 Message-Id: <20190720144257.26088-1-jason@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes In general, when we see a dependent using-declaration we don't know whether it names a function or not, so it doesn't get an OVERLOAD unless we see overloads of the same name in the current class. In the case of an inherited constructor we could figure that out from the name, but it's simpler to handle USING_DECL properly. Tested x86_64-pc-linux-gnu, applying to trunk. * cp-tree.h (ovl_iterator::using_p): A USING_DECL by itself was also introduced by a using-declaration. --- gcc/cp/cp-tree.h | 3 ++- .../g++.dg/cpp1z/class-deduction67.C | 21 +++++++++++++++++++ gcc/cp/ChangeLog | 5 +++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/class-deduction67.C base-commit: 8086cf948309ce8a2a353e0d483b9a14c9f83cc6 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 6068745567a..688924cdd12 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -774,7 +774,8 @@ class ovl_iterator /* Whether this overload was introduced by a using decl. */ bool using_p () const { - return TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl); + return (TREE_CODE (ovl) == USING_DECL + || (TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl))); } bool hidden_p () const { diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction67.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction67.C new file mode 100644 index 00000000000..4624794c4b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction67.C @@ -0,0 +1,21 @@ +// Deduction from inherited constructors isn't supported yet, but we shouldn't +// crash. It may well be supported in C++23. + +//{ dg-do compile { target c++17 } } + +template struct A +{ + A(T); +}; + +template struct B: A +{ + using A::A; +}; + +int main() +{ + B b = 42; // { dg-line init } + // { dg-prune-output "no matching function" } + // { dg-error "class template argument deduction" "" { target *-*-* } init } +} diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0c6a7de94d9..d645cdef147 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-07-20 Jason Merrill + + * cp-tree.h (ovl_iterator::using_p): A USING_DECL by itself was also + introduced by a using-declaration. + 2019-07-20 Jason Merrill Reduce memory consumption for push/pop_access_scope.