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]

Fix crash with -fdump-tree-original-details


While developing a patch, we stumbled across a crash in dump_eh_tree triggered 
by -fdump-tree-original-details because FUN was NULL.  It is valid for a 
function to have DECL_STRUCT_FUNCTION uninitialized before gimplification

/* Entry point to the gimplification pass.  FNDECL is the FUNCTION_DECL
   node for the function we want to gimplify.  */

void
gimplify_function_tree (tree fndecl)
{
  tree oldfn, parm, ret;

  oldfn = current_function_decl;
  current_function_decl = fndecl;
  cfun = DECL_STRUCT_FUNCTION (fndecl);
  if (cfun == NULL)
    allocate_struct_function (fndecl);

so dump_function_to_file must cope with that.


Bootstrapped/regtested on x86_64-suse-linux, applied to mainline as obvious.


2007-02-19  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-cfg.c (dump_function_to_file): Be prepared for functions
	without DECL_STRUCT_FUNCTION initialized.


-- 
Eric Botcazou
Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 122038)
+++ tree-cfg.c	(working copy)
@@ -4998,6 +4998,7 @@ void
 dump_function_to_file (tree fn, FILE *file, int flags)
 {
   tree arg, vars, var;
+  struct function *dsf;
   bool ignore_topmost_bind = false, any_var = false;
   basic_block bb;
   tree chain;
@@ -5015,8 +5016,10 @@ dump_function_to_file (tree fn, FILE *fi
     }
   fprintf (file, ")\n");
 
-  if (flags & TDF_DETAILS)
-    dump_eh_tree (file, DECL_STRUCT_FUNCTION (fn));
+  dsf = DECL_STRUCT_FUNCTION (fn);
+  if (dsf && (flags & TDF_DETAILS))
+    dump_eh_tree (file, dsf);
+
   if (flags & TDF_RAW)
     {
       dump_node (fn, TDF_SLIM | flags, file);

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