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]

[committed] Fix use of ggc_freed old decl in pushdecl_maybe_friend (PR c++/43033)


Hi!

As discussed in the PR, x might be ggc_freed at this point, so it shouldn't
be dereferenced.  Approved in bugzilla by Jason, committed to trunk/4.4.

2010-02-12  Jakub Jelinek  <jakub@redhat.com>

	PR c++/43033
	* name-lookup.c (pushdecl_maybe_friend): Check default args of t
	instead of x.

	* g++.dg/other/default3.C: Xfail g4 test.

--- gcc/cp/name-lookup.c.jj	2010-02-12 13:25:21.000000000 +0100
+++ gcc/cp/name-lookup.c	2010-02-12 18:15:32.000000000 +0100
@@ -853,8 +853,8 @@ pushdecl_maybe_friend (tree x, bool is_f
 	    add_decl_to_level (x, NAMESPACE_LEVEL (CP_DECL_CONTEXT (t)));
 	}
 
-      if (TREE_CODE (x) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (x))
-	check_default_args (x);
+      if (TREE_CODE (t) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (t))
+	check_default_args (t);
 
       if (t != x || DECL_FUNCTION_TEMPLATE_P (t))
 	POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
--- gcc/testsuite/g++.dg/other/default3.C.jj	2008-09-05 12:55:01.000000000 +0200
+++ gcc/testsuite/g++.dg/other/default3.C	2010-02-12 18:17:34.000000000 +0100
@@ -25,7 +25,7 @@ template<typename> void g3(int, int);
 template<typename> void g3(int = 0, int);    // { dg-error "default" }
 
 template<typename> void g4(int, int);
-template<typename> void g4(int = 0, int) {}  // { dg-error "default" }
+template<typename> void g4(int = 0, int) {}  // { dg-error "default" "" { xfail *-*-* } }
 
 template<typename> void g5();
 template<typename> void g5(int = 0, int);    // { dg-error "default" }

	Jakub


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