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]

[PATCH] Reset cfun before leaving cgraph_build_static_cdtor (PR c++/34619)


Hi!

On the attached testcase g++ ICEs with -fmudflap, because
cgraph_build_static_cdtor (invoked by mudflap_finish_file, but elsewhere
too) calls allocate_struct_function which sets cfun to the new artificial
fn, but nothing resets it, and when C++ FE handles stuff at file end,
it doesn't expect cfun to be non-NULL (or to be non-NULL without
cfun->language being allocated).  I think it is better just to reset
cfun back before leaving cgraph_build_static_cdtor, rather than changing
many places in C++ FE to avoid ICEs with cfun != NULL &&
cfun->language == NULL.

Ok for trunk?

2008-01-02  Jakub Jelinek  <jakub@redhat.com>

	PR c++/34619
	* cgraphunit.c (cgraph_build_static_cdtor): set_cfun back to NULL
	before returning.

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

--- gcc/cgraphunit.c.jj	2007-11-26 22:14:08.000000000 +0100
+++ gcc/cgraphunit.c	2008-01-02 17:38:20.000000000 +0100
@@ -1,5 +1,6 @@
 /* Callgraph based interprocedural optimizations.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+   Free Software Foundation, Inc.
    Contributed by Jan Hubicka
 
 This file is part of GCC.
@@ -1515,6 +1516,7 @@ cgraph_build_static_cdtor (char which, t
 
   cgraph_add_new_function (decl, false);
   cgraph_mark_needed_node (cgraph_node (decl));
+  set_cfun (NULL);
 }
 
 void
--- libmudflap/testsuite/libmudflap.c++/pass61-frag.cxx.jj	2008-01-02 20:44:54.000000000 +0100
+++ libmudflap/testsuite/libmudflap.c++/pass61-frag.cxx	2008-01-02 20:45:09.000000000 +0100
@@ -0,0 +1,20 @@
+// PR c++/34619
+// { dg-do compile }
+
+template <typename> struct A
+{
+  typedef int X;
+  static const int N = 1;
+};
+
+template <typename T> struct B
+{
+  typedef typename A <int [A <T>::N]>::X Y;
+  template <typename U> B (Y, U) {}
+};
+
+int main ()
+{
+}
+
+B <int>b (0, 0);

	Jakub


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