re PR c++/35708 (jump to label enters catch block)
authorJason Merrill <jason@redhat.com>
Wed, 9 Apr 2008 16:15:53 +0000 (12:15 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 9 Apr 2008 16:15:53 +0000 (12:15 -0400)
        PR c++/35708
        * semantics.c (finish_compound_literal): Return a TARGET_EXPR,
        not a pushed variable.

From-SVN: r134146

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/complit9.C [new file with mode: 0644]

index 17b09a7..1e13165 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-09  Jason Merrill  <jason@redhat.com>
+
+       PR c++/35708
+       * semantics.c (finish_compound_literal): Return a TARGET_EXPR, 
+       not a pushed variable.
+
 2008-04-09  Volker Reichelt  <v.reichelt@netcologne.de>
 
        * call.c (build_op_delete_call): Fix quotation in warning message.
index 3a36fdd..12cf387 100644 (file)
@@ -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
index 18d9236..3e091a4 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-09  Jason Merrill  <jason@redhat.com>
+
+       PR c++/35708
+       * g++.dg/ext/complit9.C: New.
+
 2008-04-09  Samuel Tardieu  <sam@rfc1149.net>
 
        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 (file)
index 0000000..5b7fbe7
--- /dev/null
@@ -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;
+}