diff mbox

Fix PR 51198, DECL_INITIAL still contains stuff for FIELD_DECLs

Message ID CA+=Sn1mZ1PDCt5bd03VOqRscXa-5+JZXnNTeVi=69mGGkcNQ6Q@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski Nov. 30, 2011, 7:05 p.m. UTC
Hi,
  With C++11's decl initialization for non static members, the
DECL_INITIAL for FIELD_DECLs contains stuff which we don't need to
keep around after the front-end is done.  This patch clears them in
the free_lang_data pass.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
* tree.c (free_lang_data_in_decl): Clear FIELD_DECL's DECL_INITIAL also.

testsuite/ChangeLog:
* g++.dg/torture/pr51198.C: New testcase.

Comments

Richard Biener Dec. 1, 2011, 3:36 p.m. UTC | #1
On Wed, Nov 30, 2011 at 8:05 PM, Andrew Pinski
<andrew.pinski@caviumnetworks.com> wrote:
> Hi,
>  With C++11's decl initialization for non static members, the
> DECL_INITIAL for FIELD_DECLs contains stuff which we don't need to
> keep around after the front-end is done.  This patch clears them in
> the free_lang_data pass.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Ok.

Thanks,
Richard.

> Thanks,
> Andrew Pinski
>
> ChangeLog:
> * tree.c (free_lang_data_in_decl): Clear FIELD_DECL's DECL_INITIAL also.
>
> testsuite/ChangeLog:
> * g++.dg/torture/pr51198.C: New testcase.
diff mbox

Patch

Index: tree.c
===================================================================
--- tree.c	(revision 181823)
+++ tree.c	(working copy)
@@ -4651,7 +4651,8 @@  free_lang_data_in_decl (tree decl)
 	  || (decl_function_context (decl) && !TREE_STATIC (decl)))
 	DECL_INITIAL (decl) = NULL_TREE;
     }
-  else if (TREE_CODE (decl) == TYPE_DECL)
+  else if (TREE_CODE (decl) == TYPE_DECL
+	   || TREE_CODE (decl) == FIELD_DECL)
     DECL_INITIAL (decl) = NULL_TREE;
   else if (TREE_CODE (decl) == TRANSLATION_UNIT_DECL
            && DECL_INITIAL (decl)
Index: testsuite/g++.dg/torture/pr51198.C
===================================================================
--- testsuite/g++.dg/torture/pr51198.C	(revision 0)
+++ testsuite/g++.dg/torture/pr51198.C	(revision 0)
@@ -0,0 +1,29 @@ 
+/* { dg-options "-std=gnu++0x" } */
+
+struct A
+{
+  int i = 0 ? 0 : throw 1;
+};
+
+
+struct B
+{
+  int f();
+  int i = f();
+};
+
+struct C
+{
+  C(int);
+};
+
+struct D
+{
+  C a = 0;
+};
+
+A a;
+B b;
+D d;
+
+