PR c++/79796 - ICE with NSDMI and this pointer
authorMarek Polacek <polacek@redhat.com>
Mon, 6 Mar 2017 17:38:42 +0000 (17:38 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 6 Mar 2017 17:38:42 +0000 (17:38 +0000)
PR c++/79796 - ICE with NSDMI and this pointer
* call.c (build_over_call): Handle NSDMI with a 'this' by calling
replace_placeholders.

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

From-SVN: r245927

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

index 12d74a6702f30c5e02aa3073338991986e4cc9c3..13350b8b347c7f762207867d9f02b20876d6d7ce 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/79796 - ICE with NSDMI and this pointer
+       * call.c (build_over_call): Handle NSDMI with a 'this' by calling
+       replace_placeholders.
+
 2017-03-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/79822
index 5afec4f0897bff140ee31e0fc40c0895193e29f7..86c7647e7cd75e5c2f0412a0cea413de8dff7996 100644 (file)
@@ -8047,6 +8047,9 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
        {
          arg = cp_build_indirect_ref (arg, RO_NULL, complain);
          val = build2 (MODIFY_EXPR, TREE_TYPE (to), to, arg);
+         if (cxx_dialect >= cxx14)
+           /* Handle NSDMI that refer to the object being initialized.  */
+           replace_placeholders (arg, to);
        }
       else
        {
index 798d89b2571cfbb468048fa4336ff1f0fa103781..445e4141408ec74f8af02dcd0fd2753f750873be 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/79796 - ICE with NSDMI and this pointer
+       * g++.dg/cpp0x/nsdmi13.C: New test.
+
 2017-03-06  Julia Koval  <julia.koval@intel.com>
 
        PR target/79793
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi13.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi13.C
new file mode 100644 (file)
index 0000000..2751da3
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/79796
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  A* p = this;
+};
+
+void foo()
+{
+  A a;
+  a = A({});
+}