From daaa6fcc70ffe66bd56f5819ad4ee78fecd54bb6 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 19 Jul 2019 03:29:15 -0400 Subject: [PATCH] PR c++/90101 - dependent class non-type parameter. We shouldn't complain that a dependent type is incomplete. * pt.c (invalid_nontype_parm_type_p): Check for dependent class type. From-SVN: r273592 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 2 ++ gcc/testsuite/g++.dg/cpp2a/nontype-class21.C | 10 ++++++++++ gcc/testsuite/g++.dg/cpp2a/nontype-class22.C | 21 ++++++++++++++++++++ 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 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. 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>); -- 2.30.2