PR c++/85545 - ICE with noexcept PMF conversion.
authorJason Merrill <jason@redhat.com>
Thu, 26 Apr 2018 20:32:32 +0000 (16:32 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 26 Apr 2018 20:32:32 +0000 (16:32 -0400)
* cvt.c (cp_fold_convert): Handle PMF CONSTRUCTORs directly.

From-SVN: r259689

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/testsuite/g++.dg/cpp1z/noexcept-type20.C [new file with mode: 0644]

index 037870627f926752caa13a535553aa3ae3564691..491853e816675f54f040886ce6584e4ba4d0c6d9 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-26  Jason Merrill  <jason@redhat.com>
+
+       PR c++/85545 - ICE with noexcept PMF conversion.
+       * cvt.c (cp_fold_convert): Handle PMF CONSTRUCTORs directly.
+
 2018-04-25  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/85437
index 9b53fa3067d9dafe7063dc79db1e2a7f022a0ebe..a3735a1cffe00b78698c17f87c1aff1e5830af01 100644 (file)
@@ -601,7 +601,9 @@ cp_fold_convert (tree type, tree expr)
   tree conv;
   if (TREE_TYPE (expr) == type)
     conv = expr;
-  else if (TREE_CODE (expr) == PTRMEM_CST)
+  else if (TREE_CODE (expr) == PTRMEM_CST
+          || (TREE_CODE (expr) == CONSTRUCTOR
+              && TYPE_PTRMEMFUNC_P (type)))
     {
       /* Avoid wrapping a PTRMEM_CST in NOP_EXPR.  */
       conv = copy_node (expr);
diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type20.C b/gcc/testsuite/g++.dg/cpp1z/noexcept-type20.C
new file mode 100644 (file)
index 0000000..a6033f7
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/85545
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  void foo() noexcept;
+};
+
+template<typename T> void bar(T);
+
+void baz()
+{
+  bar(static_cast<void(A::*)()>(&A::foo));
+}