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.
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;
+
+

Reply via email to