This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, PR 45562] Add two (cp_function_chain != NULL) checks
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: jason at redhat dot com
- Date: Mon, 11 Oct 2010 17:10:50 +0200
- Subject: [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. */