re PR c++/56428 ([C++11] "is not a constant expression" when comparing non-type templ...
authorMarek Polacek <polacek@redhat.com>
Fri, 2 Aug 2019 18:17:20 +0000 (18:17 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 2 Aug 2019 18:17:20 +0000 (18:17 +0000)
PR c++/56428
* g++.dg/cpp0x/nontype4.C: New test.

From-SVN: r274028

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nontype4.C [new file with mode: 0644]

index d57410c..147d8f8 100644 (file)
@@ -1,5 +1,10 @@
 2019-08-02  Marek Polacek  <polacek@redhat.com>
 
+       PR c++/56428
+       * g++.dg/cpp0x/nontype4.C: New test.
+
+2019-08-02  Marek Polacek  <polacek@redhat.com>
+
        PR c++/53009
        * g++.dg/cpp0x/nontype3.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/nontype4.C b/gcc/testsuite/g++.dg/cpp0x/nontype4.C
new file mode 100644 (file)
index 0000000..2c552d0
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/56428
+// { dg-do compile { target c++11 } }
+
+struct A { };
+
+template<bool B>
+  struct Builder
+  {
+    static A build() { return A(); }
+  };
+
+template<A (*F)()>
+  A f()
+  {
+    return Builder<F != nullptr>::build();
+  }
+
+A g();
+
+int main()
+{
+  f< &g >();
+  f< nullptr >();
+  f< &f<nullptr> >();
+}