From 23e81e2e9cc51970900c866211fa84b6faf9a7ef Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 9 Apr 2008 16:15:53 +0000 Subject: [PATCH] PR c++/35708 * semantics.c (finish_compound_literal): Return a TARGET_EXPR, not a pushed variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134146 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 31 ++++++------------------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/complit9.C | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 25 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/complit9.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 17b09a761ca..1e131656516 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-04-09 Jason Merrill + + PR c++/35708 + * semantics.c (finish_compound_literal): Return a TARGET_EXPR, + not a pushed variable. + 2008-04-09 Volker Reichelt * call.c (build_op_delete_call): Fix quotation in warning message. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3a36fddab18..12cf38750db 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2101,7 +2101,6 @@ finish_unary_op_expr (enum tree_code code, tree expr) tree finish_compound_literal (tree type, VEC(constructor_elt,gc) *initializer_list) { - tree var; tree compound_literal; if (!TYPE_OBJ_P (type)) @@ -2120,30 +2119,12 @@ finish_compound_literal (tree type, VEC(constructor_elt,gc) *initializer_list) return compound_literal; } - /* Create a temporary variable to represent the compound literal. */ - var = create_temporary_var (type); - if (!current_function_decl) - { - /* If this compound-literal appears outside of a function, then - the corresponding variable has static storage duration, just - like the variable in whose initializer it appears. */ - TREE_STATIC (var) = 1; - /* The variable has internal linkage, since there is no need to - reference it from another translation unit. */ - TREE_PUBLIC (var) = 0; - /* It must have a name, so that the name mangler can mangle it. */ - DECL_NAME (var) = make_anon_name (); - } - /* We must call pushdecl, since the gimplifier complains if the - variable has not been declared via a BIND_EXPR. */ - pushdecl (var); - /* Initialize the variable as we would any other variable with a - brace-enclosed initializer. */ - cp_finish_decl (var, compound_literal, - /*init_const_expr_p=*/false, - /*asmspec_tree=*/NULL_TREE, - LOOKUP_ONLYCONVERTING); - return var; + type = complete_type (type); + compound_literal = reshape_init (type, compound_literal); + if (TREE_CODE (type) == ARRAY_TYPE) + cp_complete_array_type (&type, compound_literal, false); + compound_literal = digest_init (type, 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 18d9236b778..3e091a4ca7a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-04-09 Jason Merrill + + PR c++/35708 + * g++.dg/ext/complit9.C: New. + 2008-04-09 Samuel Tardieu PR ada/28305 diff --git a/gcc/testsuite/g++.dg/ext/complit9.C b/gcc/testsuite/g++.dg/ext/complit9.C new file mode 100644 index 00000000000..5b7fbe75cd8 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/complit9.C @@ -0,0 +1,15 @@ +// PR c++/35708 +// { dg-options "" } + +struct object { int one_o; int allocstamp; }; +int pgci_pointable (object obj); +void foo(void); +int main (int argc, char *argv[]) +{ + if (pgci_pointable((object){7,100})) + { + bad_rehash_size: + foo(); + } + goto bad_rehash_size; +} -- 2.11.4.GIT