From: jason Date: Tue, 23 Jun 2015 14:08:19 +0000 (+0000) Subject: PR c++/66542 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=435172d141d9080a7944f18d971badf4363a2636;p=thirdparty%2Fgcc.git PR c++/66542 * decl.c (expand_static_init): Make sure the destructor is callable here even if we have an initializer. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224842 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 479044807efb..194d764469c5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-06-23 Jason Merrill + + 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 * 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 c934ff930779..d14ffe218fc5 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 000000000000..770bb9c305a6 --- /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" }