From: mpolacek Date: Sat, 28 Sep 2019 11:36:36 +0000 (+0000) Subject: PR c++/91923 - failure-to-SFINAE with class type NTTP in C++17. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d88a6b8c4f45c8e448b4a3e4a7a410a9dde1b7c;p=thirdparty%2Fgcc.git PR c++/91923 - failure-to-SFINAE with class type NTTP in C++17. * pt.c (invalid_nontype_parm_type_p): Only emit errors when tf_error. * g++.dg/cpp0x/nontype5.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@276248 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ea2a84f24f3..895ebd9e8fbb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-09-28 Marek Polacek + + PR c++/91923 - failure-to-SFINAE with class type NTTP in C++17. + * pt.c (invalid_nontype_parm_type_p): Only emit errors when + tf_error. + 2019-09-27 Jakub Jelinek PR c++/88203 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5a2dfbbd994f..44b361833049 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -25232,8 +25232,9 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain) { if (cxx_dialect < cxx2a) { - error ("non-type template parameters of class type only available " - "with %<-std=c++2a%> or %<-std=gnu++2a%>"); + if (complain & tf_error) + error ("non-type template parameters of class type only available " + "with %<-std=c++2a%> or %<-std=gnu++2a%>"); return true; } if (dependent_type_p (type)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8fadb03e9739..617fc99715f8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-28 Marek Polacek + + PR c++/91923 - failure-to-SFINAE with class type NTTP in C++17. + * g++.dg/cpp0x/nontype5.C: New test. + 2019-09-28 Alan Modra PR testsuite/91676 diff --git a/gcc/testsuite/g++.dg/cpp0x/nontype5.C b/gcc/testsuite/g++.dg/cpp0x/nontype5.C new file mode 100644 index 000000000000..c31134581aa4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nontype5.C @@ -0,0 +1,17 @@ +// PR c++/91923 - failure-to-SFINAE with class type NTTP in C++17. +// { dg-do compile { target c++11 } } + +template +constexpr bool is_integral_(...) { + return false; +} +template +constexpr bool is_integral_(long) { + return true; +} + +static_assert(is_integral_(42), ""); +static_assert(!is_integral_(42), ""); + +struct S {}; +static_assert(!is_integral_(42), "");