Commit d4c9e7f9 by Jason Merrill Committed by Jason Merrill

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
parent c079cbac
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
......
......@@ -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)
......
// PR c++/66542
// { dg-do compile { target c++11 } }
struct A
{
A() {}
~A() = delete; // { dg-message "declared here" }
};
static A a; // { dg-error "deleted" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment