]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/85552 - wrong instantiation of dtor for DMI.
authorJason Merrill <jason@redhat.com>
Fri, 19 Jul 2019 08:52:58 +0000 (04:52 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 19 Jul 2019 08:52:58 +0000 (04:52 -0400)
* typeck2.c (digest_nsdmi_init): Set tf_no_cleanup for direct-init.

From-SVN: r273596

gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C [new file with mode: 0644]

index 71bddd7d40d0441181de9abc95d25c7230f57834..4b69396e7307f8a08bda08c32fa135f0f280e12d 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/85552 - wrong instantiation of dtor for DMI.
+       * typeck2.c (digest_nsdmi_init): Set tf_no_cleanup for direct-init.
+
 2019-07-19  Nina Dinka Ranns  <dinka.ranns@gmail.com>
 
        PR c++/63149 - Wrong auto deduction from braced-init-list.
index df002a1664c76d8a2913bdb170efb6e1d4fc7156..bdb98f844350e825c26b3cc4e2ca6e44d340e80a 100644 (file)
@@ -1293,7 +1293,10 @@ digest_nsdmi_init (tree decl, tree init, tsubst_flags_t complain)
   tree type = TREE_TYPE (decl);
   int flags = LOOKUP_IMPLICIT;
   if (DIRECT_LIST_INIT_P (init))
-    flags = LOOKUP_NORMAL;
+    {
+      flags = LOOKUP_NORMAL;
+      complain |= tf_no_cleanup;
+    }
   if (BRACE_ENCLOSED_INITIALIZER_P (init)
       && CP_AGGREGATE_TYPE_P (type))
     init = reshape_init (type, init, complain);
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C
new file mode 100644 (file)
index 0000000..a12740b
--- /dev/null
@@ -0,0 +1,30 @@
+// PR c++/85552
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+struct uptr {
+  uptr() { }
+  uptr(void*) { }
+  ~uptr() { static_assert(sizeof(T), "complete type"); }
+};
+
+class S;
+
+class Compiles
+{
+  uptr<S> s;
+};
+
+class DoesntCompile
+{
+  ~DoesntCompile();
+  DoesntCompile();
+
+  uptr<S> s1 { };
+  uptr<S> s2 { nullptr };
+};
+
+int main()
+{
+  return 0;
+}