]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/37568
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 9 Oct 2008 20:15:17 +0000 (20:15 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 9 Oct 2008 20:15:17 +0000 (20:15 +0000)
* semantics.c (finalize_nrv_r): Clear DECL_INITIAL instead of
setting it to error_mark_node.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141010 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/semantics.c
libmudflap/ChangeLog
libmudflap/testsuite/libmudflap.c++/pass66-frag.cxx [new file with mode: 0644]

index bb4b6b21bedcb6663ce44d96e78c9e604a739215..6ad8a8a6ad5b530742f5e82aae4b375719dd208f 100644 (file)
@@ -1,3 +1,9 @@
+2008-10-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/37568
+       * semantics.c (finalize_nrv_r): Clear DECL_INITIAL instead of
+       setting it to error_mark_node.
+
 2008-10-07  Steve Ellcey  <sje@cup.hp.com>
 
        * decl.c (start_cleanup_fn): Declare as inline.
index b1bbb38dfa8e32e074f166c8fc48b9f7524f082d..040a9b10c35e0524e88e38964808f864b4306c1f 100644 (file)
@@ -3310,13 +3310,11 @@ finalize_nrv_r (tree* tp, int* walk_subtrees, void* data)
       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;
     }
index b09f9440d5fbb0b3c5a0ecb8e5a22dbcf484972f..9214759b304cc86c2afee206ebc324eb62454e67 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/37568
+       * testsuite/libmudflap.c++/pass66-frag.cxx: New test.
+
 2008-09-26  Peter O'Gorman  <pogma@thewrittenword.com>
             Steve Ellcey  <sje@cup.hp.com>
 
diff --git a/libmudflap/testsuite/libmudflap.c++/pass66-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass66-frag.cxx
new file mode 100644 (file)
index 0000000..989c7ca
--- /dev/null
@@ -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 ();