Jakub noticed that we were improperly allowing this in C++17 mode.
Tested x86_64-pc-linux-gnu, applying to trunk.
* pt.c (invalid_nontype_parm_type_p): Reject class placeholder in
C++17.
---
gcc/cp/pt.c | 11 ++++++++++-
gcc/testsuite/g++.dg/cpp1z/class-deduction64.C | 2 +-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 5b12aa6996a..bc23e9e0354 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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)
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
b/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
index 3a06e6fb522..a21ea129f46 100644
--- a/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
@@ -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>();
};
base-commit: 95d4b531e7e3750bdde17079e209909deee6b219
--
2.18.1