[PR,45562] Add two (cp_function_chain != NULL) checks

Message ID 20101011151049.GB12977@virgil.arch.suse.de
State New
Headers show

Commit Message

Martin Jambor Oct. 11, 2010, 3:10 p.m.

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

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?



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

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


Jason Merrill Oct. 11, 2010, 7:22 p.m. | #1



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.  */