Reject class template placeholder as non-type template parm type in C++17.
authorJason Merrill <jason@redhat.com>
Fri, 3 Jan 2020 22:10:25 +0000 (17:10 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 3 Jan 2020 22:10:25 +0000 (17:10 -0500)
* pt.c (invalid_nontype_parm_type_p): Reject class placeholder in
C++17.

From-SVN: r279870

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/class-deduction64.C

index 35b954ca6b2a1f8297e5ec4794611d724a574c26..9b607b2f0733a7731b46d1da1a28888070933ba0 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-02  Jason Merrill  <jason@redhat.com>
+
+       * pt.c (invalid_nontype_parm_type_p): Reject class placeholder in
+       C++17.
+
 2020-01-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/90677
index 5b12aa6996a89daad35e0a37c3794e42725b56f1..bc23e9e03548765453988f06f39db45c600f5b66 100644 (file)
@@ -25811,7 +25811,16 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain)
   else if (TYPE_PTRMEM_P (type))
     return false;
   else if (TREE_CODE (type) == TEMPLATE_TYPE_PARM)
-    return false;
+    {
+      if (CLASS_PLACEHOLDER_TEMPLATE (type) && cxx_dialect < cxx2a)
+       {
+         if (complain & tf_error)
+           error ("non-type template parameters of deduced class type only "
+                  "available with %<-std=c++2a%> or %<-std=gnu++2a%>");
+         return true;
+       }
+      return false;
+    }
   else if (TREE_CODE (type) == TYPENAME_TYPE)
     return false;
   else if (TREE_CODE (type) == DECLTYPE_TYPE)
index 3a06e6fb522bf05c187020f37fa0d9bbcbc80125..a21ea129f46826d48a721f31128ff7d7b9365853 100644 (file)
@@ -3,7 +3,7 @@
 
 template <int> struct S;
 
-template <S> struct W {
+template <S> struct W {          // { dg-error "class type" "" { target c++17_only } }
   template <typename> static int foo();
   bool b = foo<int>();
 };