* [C++ PATCH] Clear DECL_INITIAL during C++ NVR (PR c++/37568)
@ 2008-09-30 21:28 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2008-09-30 21:28 UTC (permalink / raw)
To: Jason Merrill, Mark Mitchell; +Cc: gcc-patches
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-09-30 20:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-30 21:28 [C++ PATCH] Clear DECL_INITIAL during C++ NVR (PR c++/37568) Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).