From 467649eb698b5276610f8509432eb7a5f721c5f3 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 6 Sep 2010 00:48:58 -0400 Subject: [PATCH] semantics.c (finish_compound_literal): Always build a TARGET_EXPR. * semantics.c (finish_compound_literal): Always build a TARGET_EXPR. From-SVN: r163893 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/semantics.c | 15 +-------------- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/initlist43.C | 7 +++++++ 4 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist43.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 071f8d6..b2da825 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2010-09-06 Jason Merrill + + * semantics.c (finish_compound_literal): Always build a + TARGET_EXPR. + 2010-08-30 Paolo Carlini PR c++/45043 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0afa8f9..17c795f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2203,20 +2203,7 @@ finish_compound_literal (tree type, tree compound_literal) if (TREE_CODE (type) == ARRAY_TYPE) cp_complete_array_type (&type, compound_literal, false); compound_literal = digest_init (type, compound_literal); - if ((!at_function_scope_p () || CP_TYPE_CONST_P (type)) - && initializer_constant_valid_p (compound_literal, type)) - { - tree decl = create_temporary_var (type); - DECL_INITIAL (decl) = compound_literal; - TREE_STATIC (decl) = 1; - cp_apply_type_quals_to_decl (cp_type_quals (type), decl); - decl = pushdecl_top_level (decl); - DECL_NAME (decl) = make_anon_name (); - SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl)); - return decl; - } - else - return get_target_expr (compound_literal); + return get_target_expr (compound_literal); } /* Return the declaration for the function-name variable indicated by diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d72be50..eb19f0e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-09-06 Jason Merrill + + * g++.dg/cpp0x/initlist43.C: New. + 2010-09-05 Giuseppe Scrivano * gcc.dg/tree-ssa/tailrecursion-7.c: New file. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist43.C b/gcc/testsuite/g++.dg/cpp0x/initlist43.C new file mode 100644 index 0000000..72a09bd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist43.C @@ -0,0 +1,7 @@ +// Test that using T{} at file scope doesn't create a static temporary. +// { dg-options -std=c++0x } +// { dg-final { scan-assembler-not "local" } } + +struct A { }; + +A a = A{}; -- 2.7.4