PR c++/91923 - failure-to-SFINAE with class type NTTP in C++17.
authorMarek Polacek <polacek@redhat.com>
Sat, 28 Sep 2019 11:36:36 +0000 (11:36 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Sat, 28 Sep 2019 11:36:36 +0000 (11:36 +0000)
* pt.c (invalid_nontype_parm_type_p): Only emit errors when
tf_error.

* g++.dg/cpp0x/nontype5.C: New test.

From-SVN: r276248

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nontype5.C [new file with mode: 0644]

index 8ea2a84f24f3ae54d587d28742ecd10e7396e30f..895ebd9e8fbb256767e6374b1bd00257648d8c2a 100644 (file)
@@ -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
index 5a2dfbbd994f3699c9418aca993f883e61d40d8e..44b361833049c2ec054b0fb07148d97fb7679784 100644 (file)
@@ -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))
index 8fadb03e97395e82307b78cd45474b9965d78dee..617fc99715f8574354d9c192fa33a5f934d85a5b 100644 (file)
@@ -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 (file)
index 0000000..c311345
--- /dev/null
@@ -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), "");