This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] Clear DECL_INITIAL during C++ NVR (PR c++/37568)


Hi!

The recently added checking in ipa-reference code ICEs on C++ NRVed decls,
which have DECL_INITIAL set to error_mark_node:
#ifdef ENABLE_CHECKING
  /* Verify that all local initializers was expanded by gimplifier.  */
  for (step = DECL_STRUCT_FUNCTION (decl)->local_decls;
       step;
       step = TREE_CHAIN (step))
    {
      tree var = TREE_VALUE (step);
      if (TREE_CODE (var) == VAR_DECL
          && DECL_INITIAL (var)
          && !TREE_STATIC (var))
        gcc_unreachable ();
    }
#endif
As discussed in bugzilla, this patch clears DECL_INITAL in this case
instead of leaving it as error_mark_node.

Bootstrapped/regtested on x86_64-linux, additionally regtested
with --target_board=unix/-m32.  Ok for trunk?

2008-09-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/37568
	* semantics.c (finalize_nrv_r): Clear DECL_INITIAL instead of
	setting it to error_mark_node.

	* testsuite/libmudflap.c++/pass66-frag.cxx: New test.

--- gcc/cp/semantics.c.jj	2008-09-30 16:56:10.000000000 +0200
+++ gcc/cp/semantics.c	2008-09-30 19:07:37.000000000 +0200
@@ -3310,13 +3310,11 @@ finalize_nrv_r (tree* tp, int* walk_subt
       tree init;
       if (DECL_INITIAL (dp->var)
 	  && DECL_INITIAL (dp->var) != error_mark_node)
-	{
-	  init = build2 (INIT_EXPR, void_type_node, dp->result,
-			 DECL_INITIAL (dp->var));
-	  DECL_INITIAL (dp->var) = error_mark_node;
-	}
+	init = build2 (INIT_EXPR, void_type_node, dp->result,
+		       DECL_INITIAL (dp->var));
       else
 	init = build_empty_stmt ();
+      DECL_INITIAL (dp->var) = NULL_TREE;
       SET_EXPR_LOCUS (init, EXPR_LOCUS (*tp));
       *tp = init;
     }
--- libmudflap/testsuite/libmudflap.c++/pass66-frag.cxx.jj	2008-09-30 19:16:10.000000000 +0200
+++ libmudflap/testsuite/libmudflap.c++/pass66-frag.cxx	2008-09-30 19:15:32.000000000 +0200
@@ -0,0 +1,17 @@
+// PR c++/37568
+// { dg-do compile }
+// { dg-options "-fmudflap -O" }
+
+struct A
+{
+  int i;
+};
+
+A
+foo ()
+{
+  A a = { 1 };
+  return a;
+}
+
+A a = foo ();

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]