In expand_static_init we were diagnosing a deleted dtor if there was also no initializer, but not if there was, and nothing later on was diagnosing it either. Fixed thus.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 78593d02fb6af72a8f97e52cbfbbe9f49b29e9db
Author: Jason Merrill <ja...@redhat.com>
Date:   Mon Jun 22 14:00:30 2015 -0400

    	PR c++/66542
    	* decl.c (expand_static_init): Make sure the destructor is callable
    	here even if we have an initializer.

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" }

Reply via email to