From patchwork Fri Jul 19 07:28:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1133926 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-505310-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="HoDyLQaJ"; 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 45qjLM2CLBz9s3Z for ; Fri, 19 Jul 2019 17:29:13 +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=ZSL7DFQBVES3eRyl 84RBLcX89fbD6xy3C0wg4NFIxPSG1ISvnkbR1+0bGBnW2Av39YveBj2mfhh2/DUq /h3FpnNyRhAEEhmJ050Ks2KPrklGX7XeJqN+etSv8d+qAF5UKNuJ498CZJXFjnh9 86upEE7Y83SJohiDDAbQpZOCB+c= 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=Eqpyf9jaH6yJ6vF4cHVn2L Cb7xU=; b=HoDyLQaJ4KQ5Px3WigrLN+mAxuOpL1F1GSUwbujfkYgFoX6XhjzPet OduBCXtZ11cfjcfjc6xnNdRJgxivkoUarYr+mdPWVTzRDXxaA2JiV94A8OaMEzDZ V3BD3c8xGh1hrZvrWnouX+W04nupnprs82oA4adQeeR3xoy5+OTe8= Received: (qmail 131046 invoked by alias); 19 Jul 2019 07:29:07 -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 131036 invoked by uid 89); 19 Jul 2019 07:29:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL, 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=HX-Received:Fri, 2a, HContent-Transfer-Encoding:8bit X-HELO: mail-wr1-f46.google.com Received: from mail-wr1-f46.google.com (HELO mail-wr1-f46.google.com) (209.85.221.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 Jul 2019 07:29:05 +0000 Received: by mail-wr1-f46.google.com with SMTP id 31so31232211wrm.1 for ; Fri, 19 Jul 2019 00:29:05 -0700 (PDT) Received: from localhost.localdomain ([62.153.214.124]) by smtp.gmail.com with ESMTPSA id t3sm21961559wmi.6.2019.07.19.00.29.01 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 19 Jul 2019 00:29:02 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] PR c++/90101 - dependent class non-type parameter. Date: Fri, 19 Jul 2019 09:28:59 +0200 Message-Id: <20190719072859.10788-1-jason@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes We shouldn't complain that a dependent type is incomplete. Tested x86_64-pc-linux-gnu, applying to trunk. * pt.c (invalid_nontype_parm_type_p): Check for dependent class type. --- gcc/cp/pt.c | 2 ++ gcc/testsuite/g++.dg/cpp2a/nontype-class21.C | 10 ++++++++++ gcc/testsuite/g++.dg/cpp2a/nontype-class22.C | 21 ++++++++++++++++++++ gcc/cp/ChangeLog | 5 +++++ 4 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp2a/nontype-class21.C create mode 100644 gcc/testsuite/g++.dg/cpp2a/nontype-class22.C base-commit: d4f6160a8abbf666fc86fc9c60763b4b93da8fb9 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 53aaad1800a..e433413827a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -25228,6 +25228,8 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain) "with %<-std=c++2a%> or %<-std=gnu++2a%>"); return true; } + if (dependent_type_p (type)) + return false; if (!complete_type_or_else (type, NULL_TREE)) return true; if (!literal_type_p (type)) diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class21.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class21.C new file mode 100644 index 00000000000..c58fe05b9dd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class21.C @@ -0,0 +1,10 @@ +// PR c++/90101 +// { dg-do compile { target c++2a } } + +template +struct A{}; + +template> +struct B {}; + +B<2,A<2>{}> b; diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class22.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class22.C new file mode 100644 index 00000000000..026855f0bc6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class22.C @@ -0,0 +1,21 @@ +// PR c++/90100 +// { dg-do compile { target c++2a } } + +template +inline constexpr bool is_nontype_list = false; + +template typename T, auto... NonTypes> +inline constexpr bool is_nontype_list> = true; + +// works +template +struct A {}; + +static_assert(is_nontype_list>); + +// fails +struct X { + int v; +}; + +static_assert(is_nontype_list>); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cef36b2d1b2..c1fc980e287 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-07-19 Jason Merrill + + PR c++/90101 - dependent class non-type parameter. + * pt.c (invalid_nontype_parm_type_p): Check for dependent class type. + 2019-07-18 Jason Merrill PR c++/90098 - partial specialization and class non-type parms.