]> gcc.gnu.org Git - gcc.git/commitdiff
decl2.c (finish_file): Avoid out-of-bounds array reference during memmove.
authorRichard Henderson <rth@redhat.com>
Wed, 10 Sep 2003 02:41:43 +0000 (19:41 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 10 Sep 2003 02:41:43 +0000 (19:41 -0700)
        * decl2.c (finish_file): Avoid out-of-bounds array reference
        during memmove.

From-SVN: r71261

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/semantics.c

index 8af149182b73f631e79a6a0db4ff6da38eb5ff05..bd1093fa0ef71a559c9be059446cc62116055185 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-09  Richard Henderson  <rth@redhat.com>
+
+       * decl2.c (finish_file): Avoid out-of-bounds array reference
+       during memmove.
+
 2003-09-09  Richard Henderson  <rth@redhat.com>
 
        * decl2.c (mark_member_pointers): Rename from
index cbf074fa2bc7e1877e0771519df7004a2655952e..8c68a02f68ef2adda492b9ae0d1044cc2d78509f 100644 (file)
@@ -2705,12 +2705,12 @@ finish_file ()
         them to the beginning of the array, then get rid of the
         leftovers.  */
       n_new = VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) - n_old;
-      memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0),
-              &VARRAY_TREE (unemitted_tinfo_decls, n_old),
-              n_new * sizeof (tree));
+      if (n_new)
+       memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0),
+                &VARRAY_TREE (unemitted_tinfo_decls, n_old),
+                n_new * sizeof (tree));
       memset (&VARRAY_TREE (unemitted_tinfo_decls, n_new),
-             0,
-             n_old * sizeof (tree));
+             0, n_old * sizeof (tree));
       VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) = n_new;
 
       /* The list of objects with static storage duration is built up
index e7392c03052f612ee2b2b8aeee5c73b970d3b047..b5d76cea29aef5f9d91f14dc8d2bbf5285c4be94 100644 (file)
@@ -2935,62 +2935,12 @@ expand_or_defer_fn (tree fn)
   if (flag_syntax_only)
     return;
 
-  if (flag_unit_at_a_time && cgraph_global_info_ready)
-    abort ();
-
-  if (flag_unit_at_a_time && !cgraph_global_info_ready)
-    {
-      if (at_eof)
-       {
-         /* Compute the appropriate object-file linkage for inline
-            functions.  */
-         if (DECL_DECLARED_INLINE_P (fn))
-           import_export_decl (fn);
-         cgraph_finalize_function (fn, DECL_SAVED_TREE (fn));
-       }
-      else
-       {
-         if (!DECL_EXTERNAL (fn))
-           {
-             DECL_NOT_REALLY_EXTERN (fn) = 1;
-             DECL_EXTERNAL (fn) = 1;
-           }
-         /* Remember this function.  In finish_file we'll decide if
-            we actually need to write this function out.  */
-         defer_fn (fn);
-         /* Let the back-end know that this function exists.  */
-         (*debug_hooks->deferred_inline_function) (fn);
-       }
-      return;
-    }
-
-
-  /* If possible, avoid generating RTL for this function.  Instead,
-     just record it as an inline function, and wait until end-of-file
-     to decide whether to write it out or not.  */
-  if (/* We have to generate RTL if it's not an inline function.  */
-      (DECL_INLINE (fn) || DECL_COMDAT (fn))
-      /* Or if we have to emit code for inline functions anyhow.  */
-      && !flag_keep_inline_functions
-      /* Or if we actually have a reference to the function.  */
-      && !DECL_NEEDED_P (fn))
-    {
-      /* Set DECL_EXTERNAL so that assemble_external will be called as
-        necessary.  We'll clear it again in finish_file.  */
-      if (!DECL_EXTERNAL (fn))
-       {
-         DECL_NOT_REALLY_EXTERN (fn) = 1;
-         DECL_EXTERNAL (fn) = 1;
-       }
-      /* Remember this function.  In finish_file we'll decide if
-        we actually need to write this function out.  */
-      defer_fn (fn);
-      /* Let the back-end know that this function exists.  */
-      (*debug_hooks->deferred_inline_function) (fn);
-      return;
-    }
+  /* Compute the appropriate object-file linkage for inline functions.  */
+  if (DECL_DECLARED_INLINE_P (fn))
+    import_export_decl (fn);
 
-  expand_body (fn);
+  /* Expand or defer, at the whim of the compilation unit manager.  */
+  cgraph_finalize_function (fn, DECL_SAVED_TREE (fn));
 }
 
 /* Helper function for walk_tree, used by finish_function to override all
This page took 0.089966 seconds and 5 git commands to generate.