From fa9ef321070b9fbedf735ee8fdf864aa7c2b80f5 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 21 Apr 2011 00:28:32 -0400 Subject: [PATCH] semantics.c (finish_compound_literal): Don't put an array with a dtor in a static variable. * semantics.c (finish_compound_literal): Don't put an array with a dtor in a static variable. From-SVN: r172810 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/semantics.c | 1 + gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/initlist47.C | 9 +++++++++ 4 files changed, 15 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist47.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dcfa7e67a71..965ee6ee73b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-04-20 Jason Merrill + * semantics.c (finish_compound_literal): Don't put an array + with a dtor in a static variable. + * call.c (build_over_call): Handle trivial dtor. * search.c (lookup_fnfields_slot): Call complete_type. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index e9b19076ff1..7763ae00bf3 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2383,6 +2383,7 @@ finish_compound_literal (tree type, tree compound_literal, represent class temporaries with TARGET_EXPR so we elide copies. */ if ((!at_function_scope_p () || CP_TYPE_CONST_P (type)) && TREE_CODE (type) == ARRAY_TYPE + && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type) && initializer_constant_valid_p (compound_literal, type)) { tree decl = create_temporary_var (type); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8fd021625ac..07a0a6b3aed 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-04-20 Jason Merrill + * g++.dg/cpp0x/initlist47.C: New. + * g++.dg/init/dtor4.C: New. 2011-04-20 Uros Bizjak diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist47.C b/gcc/testsuite/g++.dg/cpp0x/initlist47.C new file mode 100644 index 00000000000..b76fb58361f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist47.C @@ -0,0 +1,9 @@ +// { dg-options -std=c++0x } + +struct A { ~A() = delete; }; // { dg-error "declared" } + +int main() +{ + typedef const A cA[2]; + cA{}; // { dg-error "deleted" } +} -- 2.30.2