aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-06-23 10:08:19 -0400
committerJason Merrill <jason@gcc.gnu.org>2015-06-23 10:08:19 -0400
commitd4c9e7f92225d829ad1d18c950066cf99fc58cc7 (patch)
treeadaf8fbed9e5458f3d36bf4ae5c9b7f35c801603
parentc079cbacb722ed8d9219a4c0518e87fdb1b70b3a (diff)
downloadgcc-d4c9e7f92225d829ad1d18c950066cf99fc58cc7.zip
gcc-d4c9e7f92225d829ad1d18c950066cf99fc58cc7.tar.gz
gcc-d4c9e7f92225d829ad1d18c950066cf99fc58cc7.tar.bz2
re PR c++/66542 ([C++11] Can create static variable of type that has deleted destructor)
PR c++/66542 * decl.c (expand_static_init): Make sure the destructor is callable here even if we have an initializer. From-SVN: r224842
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/deleted12.C10
3 files changed, 19 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4790448..194d764 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-23 Jason Merrill <jason@redhat.com>
+
+ PR c++/66542
+ * decl.c (expand_static_init): Make sure the destructor is callable
+ here even if we have an initializer.
+
2015-06-04 Pierre-Marie de Rodat <derodat@adacore.com>
* lang-specs.h: Pass "-o %g.s" to cc1plus for headers even if
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index c934ff9..d14ffe2 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7163,12 +7163,12 @@ expand_static_init (tree decl, tree init)
gcc_assert (TREE_STATIC (decl));
/* Some variables require no dynamic initialization. */
- if (!init
- && TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
+ if (TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
{
/* Make sure the destructor is callable. */
cxx_maybe_build_cleanup (decl, tf_warning_or_error);
- return;
+ if (!init)
+ return;
}
if (DECL_THREAD_LOCAL_P (decl) && DECL_GNU_TLS_P (decl)
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted12.C b/gcc/testsuite/g++.dg/cpp0x/deleted12.C
new file mode 100644
index 0000000..770bb9c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/deleted12.C
@@ -0,0 +1,10 @@
+// PR c++/66542
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+ A() {}
+ ~A() = delete; // { dg-message "declared here" }
+};
+
+static A a; // { dg-error "deleted" }