aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-06-14 09:22:33 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-06-14 09:22:33 -0400
commit8a26547b39e2e6ddc8097969c0a2c18f65afda6c (patch)
tree87ddd732969e6b4939b31e88abc78bb954b1b796
parente748435795f8c6f3b77fa0ac18a43151a52ad324 (diff)
downloadgcc-8a26547b39e2e6ddc8097969c0a2c18f65afda6c.zip
gcc-8a26547b39e2e6ddc8097969c0a2c18f65afda6c.tar.gz
gcc-8a26547b39e2e6ddc8097969c0a2c18f65afda6c.tar.bz2
PR c++/85552 - wrong instantiation of dtor for DMI.
The problem here is that when processing direct-initialization of a data member, we don't need to worry about destruction semantics; that will be handled in the [cd]tor. Conveniently, we already have tf_no_cleanup from a similar fix to new-expressions. * typeck2.c (digest_nsdmi_init): Set tf_no_cleanup for direct-init. From-SVN: r272287
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck2.c5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C30
3 files changed, 39 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c6823b5..62e5417 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-06-12 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-06-13 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (grokdeclarator): Use id_loc in five additional places
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 0109d6e..e8627dd 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1309,7 +1309,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
index 0000000..a12740b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C
@@ -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;
+}