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, PR 45562] Add two (cp_function_chain != NULL) checks


Hi,

the problem with PR 45562 seems to be that some template binding
invoked late because of a compare debug dump assumes that if cfun is
non-NULL so is cfun->language which is accessed through macro
cp_function_chain.

The patch below adds a check for non-NULLness of cp_function_chain to
two places that already test cfun.  Looking at the definition of macro
current_class_ptr which already does both I believe this is correct or
at least an already used and admissible workaround.

Because of the compare-debug flag I thought that any testcase would be
a rather fragile one and not all that much beneficial and so I did not
include one.  I'm running a bootstrap and testsuite now but because of
the nature of the patch I do not expect any problems.  OK for trunk?

Thanks,

Martin


2010-10-10  Martin Jambor  <mjambor@suse.cz>

	PR c++/45562
	* cp/cp-tree.h (current_class_ref): Check that cp_function_chain is
	non-NULL.
	* cp/call.c (build_cxx_call): Likewise.

Index: icln/gcc/cp/call.c
===================================================================
--- icln.orig/gcc/cp/call.c
+++ icln/gcc/cp/call.c
@@ -6082,7 +6082,8 @@ build_cxx_call (tree fn, int nargs, tree
   fndecl = get_callee_fndecl (fn);
   if ((!fndecl || !TREE_NOTHROW (fndecl))
       && at_function_scope_p ()
-      && cfun)
+      && cfun
+      && cp_function_chain)
     cp_function_chain->can_throw = 1;
 
   /* Check that arguments to builtin functions match the expectations.  */
Index: icln/gcc/cp/cp-tree.h
===================================================================
--- icln.orig/gcc/cp/cp-tree.h
+++ icln/gcc/cp/cp-tree.h
@@ -1055,7 +1055,8 @@ struct GTY(()) language_function {
   (cfun && cp_function_chain					\
    ? cp_function_chain->x_current_class_ptr : NULL_TREE)
 #define current_class_ref \
-  (cfun ? cp_function_chain->x_current_class_ref : NULL_TREE)
+  ((cfun && cp_function_chain)                                  \
+   ? cp_function_chain->x_current_class_ref : NULL_TREE)
 
 /* The EH_SPEC_BLOCK for the exception-specifiers for the current
    function, if any.  */


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