diff options
author | Marek Polacek <polacek@redhat.com> | 2019-09-28 11:36:36 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2019-09-28 11:36:36 +0000 |
commit | 028c9b3be468a5dbd27e3190b14d60b04ea02ff4 (patch) | |
tree | a772b67e0ee5e04c2906c6b99d6e46b40c878a1a /gcc | |
parent | c57a385006790d814e1f9ac4f4235a787c6c6e30 (diff) | |
download | gcc-028c9b3be468a5dbd27e3190b14d60b04ea02ff4.zip gcc-028c9b3be468a5dbd27e3190b14d60b04ea02ff4.tar.gz gcc-028c9b3be468a5dbd27e3190b14d60b04ea02ff4.tar.bz2 |
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.
From-SVN: r276248
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nontype5.C | 17 |
4 files changed, 31 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ea2a84..895ebd9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-09-28 Marek Polacek <polacek@redhat.com> + + 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 <jakub@redhat.com> PR c++/88203 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5a2dfbb..44b3618 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 8fadb03e..617fc99 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-28 Marek Polacek <polacek@redhat.com> + + 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 <amodra@gmail.com> 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 0000000..c311345 --- /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<typename T> +constexpr bool is_integral_(...) { + return false; +} +template<typename T, T = 1> +constexpr bool is_integral_(long) { + return true; +} + +static_assert(is_integral_<int>(42), ""); +static_assert(!is_integral_<void>(42), ""); + +struct S {}; +static_assert(!is_integral_<S>(42), ""); |