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

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

From-SVN: r276250

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

index 8bd42b839731e798f866f0298b2696183f061b8a..297eb6f0e9b2b7c569717c2964e8d3044d1ba055 100644 (file)
@@ -1,3 +1,12 @@
+2019-09-28  Marek Polacek  <polacek@redhat.com>
+
+       Backported from mainline
+       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-10  Marek Polacek  <polacek@redhat.com>
 
        Backported from mainline
index b3fe901097c8b749ea151cb97c24d0f3ee5efe60..34d440c7eb5882494daefeeb83347b9399fa8352 100644 (file)
@@ -25231,8 +25231,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/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), "");