]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/22061 (internal compiler error: in find_function_data, at function.c:317)
authorRichard Sandiford <richard@codesourcery.com>
Fri, 2 Sep 2005 12:34:58 +0000 (12:34 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Fri, 2 Sep 2005 12:34:58 +0000 (12:34 +0000)
PR c/22061
* c-decl.c (push_parm_decl): Push and pop x_dont_save_pending_sizes_p
around the call to grokdeclarator.  Call grokdeclarator with the
field set to 0.
(store_parm_decls): Always store the pending_sizes in cfun.
(c_expand_body_1): Call put_pending_sizes.
* c-objc-common.c (c_cannot_inline_tree_fn): Always check
pending_sizes.

From-SVN: r103776

gcc/ChangeLog
gcc/c-decl.c
gcc/c-objc-common.c
gcc/testsuite/ChangeLog

index e815b00a583d334e77bde9444ec499241003748f..187e883d8b4812e5e70f81c32692da0e10b8c575 100644 (file)
@@ -1,3 +1,14 @@
+2005-09-02  Richard Sandiford  <richard@codesourcery.com>
+
+       PR c/22061
+       * c-decl.c (push_parm_decl): Push and pop x_dont_save_pending_sizes_p
+       around the call to grokdeclarator.  Call grokdeclarator with the
+       field set to 0.
+       (store_parm_decls): Always store the pending_sizes in cfun.
+       (c_expand_body_1): Call put_pending_sizes.
+       * c-objc-common.c (c_cannot_inline_tree_fn): Always check
+       pending_sizes.
+
 2005-09-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/23478
index 38166cc94f39b54449228d1805387c2f69b06755..b4d7e357ea6bf5bd7c4bdf4159a4020d5da45a60 100644 (file)
@@ -2960,12 +2960,21 @@ void
 push_parm_decl (tree parm)
 {
   tree decl;
+  int old_dont_save_pending_sizes_p = 0;
 
   /* Don't attempt to expand sizes while parsing this decl.
      (We can get here with i_s_e 1 somehow from Objective-C.)  */
   int save_immediate_size_expand = immediate_size_expand;
   immediate_size_expand = 0;
 
+  /* If this is a nested function, we do want to keep SAVE_EXPRs for
+     the argument sizes, regardless of the parent's setting.  */
+  if (cfun)
+    {
+      old_dont_save_pending_sizes_p = cfun->x_dont_save_pending_sizes_p;
+      cfun->x_dont_save_pending_sizes_p = 0;
+    }
+
   decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)),
                         TREE_PURPOSE (TREE_PURPOSE (parm)),
                         PARM, 0, NULL);
@@ -2975,6 +2984,8 @@ push_parm_decl (tree parm)
 
   finish_decl (decl, NULL_TREE, NULL_TREE);
 
+  if (cfun)
+    cfun->x_dont_save_pending_sizes_p = old_dont_save_pending_sizes_p;
   immediate_size_expand = save_immediate_size_expand;
 }
 
@@ -5990,9 +6001,6 @@ store_parm_decls (void)
 {
   tree fndecl = current_function_decl;
 
-  /* The function containing FNDECL, if any.  */
-  tree context = decl_function_context (fndecl);
-
   /* True if this definition is written with a prototype.  */
   bool prototype = (current_function_parms
                    && TREE_CODE (current_function_parms) != TREE_LIST);
@@ -6017,20 +6025,9 @@ store_parm_decls (void)
   /* Begin the statement tree for this function.  */
   begin_stmt_tree (&DECL_SAVED_TREE (fndecl));
 
-  /* If this is a nested function, save away the sizes of any
-     variable-size types so that we can expand them when generating
-     RTL.  */
-  if (context)
-    {
-      tree t;
-
-      DECL_LANG_SPECIFIC (fndecl)->pending_sizes
-       = nreverse (get_pending_sizes ());
-      for (t = DECL_LANG_SPECIFIC (fndecl)->pending_sizes;
-          t;
-          t = TREE_CHAIN (t))
-       SAVE_EXPR_CONTEXT (TREE_VALUE (t)) = context;
-    }
+  /* Save away the sizes of any variable-size types so that we can
+     expand them when generating RTL.  */
+  DECL_LANG_SPECIFIC (fndecl)->pending_sizes = get_pending_sizes ();
 
   /* This function is being processed in whole-function mode.  */
   cfun->x_whole_function_mode_p = 1;
@@ -6181,15 +6178,12 @@ static void
 c_expand_body_1 (tree fndecl, int nested_p)
 {
   if (nested_p)
-    {
-      /* Make sure that we will evaluate variable-sized types involved
-        in our function's type.  */
-      expand_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes);
-
-      /* Squirrel away our current state.  */
-      push_function_context ();
-    }
+    /* Squirrel away our current state.  */
+    push_function_context ();
     
+  /* Make sure that we will evaluate variable-sized types involved
+     in our function's type.  */
+  put_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes);
   tree_rest_of_compilation (fndecl, nested_p);
 
   if (nested_p)
index fe0c0d5b9337628e28211cd651d0f19950c3c5d8..0efa2adc37259184dfece899a787070e3d92a034 100644 (file)
@@ -118,17 +118,12 @@ c_cannot_inline_tree_fn (tree *fnp)
        }
     }
 
-  if (! DECL_FILE_SCOPE_P (fn))
+  if (DECL_LANG_SPECIFIC (fn)->pending_sizes)
     {
-      /* If a nested function has pending sizes, we may have already
-         saved them.  */
-      if (DECL_LANG_SPECIFIC (fn)->pending_sizes)
-       {
-         if (do_warning)
-           warning ("%Jnested function '%F' can never be inlined because it "
-                    "has possibly saved pending sizes", fn, fn);
-         goto cannot_inline;
-       }
+      if (do_warning)
+       warning ("%Jfunction '%F' can never be inlined because it has "
+                "pending sizes", fn, fn);
+      goto cannot_inline;
     }
 
   return 0;
index c043043e9ec713b092c0f199830863d90557e49d..c1e664f64ce17c3d91186a13985de71daf83ebb4 100644 (file)
@@ -1,3 +1,11 @@
+2005-09-02  Richard Sandiford  <richard@codesourcery.com>
+
+       PR c/22061
+       * gcc.c-torture/execute/pr22061-1.c,
+       * gcc.c-torture/execute/pr22061-2.c,
+       * gcc.c-torture/execute/pr22061-3.c,
+       * gcc.c-torture/execute/pr22061-4.c: New tests.
+
 2005-09-02  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/22233