OSDN Git Service

* decl.c (initialize_local_var): Handle static variables here.
[pf3gnuchains/gcc-fork.git] / gcc / cp / decl.c
index bdbd1e8..00043d6 100644 (file)
@@ -7470,9 +7470,11 @@ initialize_local_var (decl, init, flags)
      tree init;
      int flags;
 {
      tree init;
      int flags;
 {
-  tree type;
+  tree type = TREE_TYPE (decl);
 
 
-  type = complete_type (TREE_TYPE (decl));
+  /* If the type is bogus, don't bother initializing the variable.  */
+  if (type == error_mark_node)
+    return;
 
   if (DECL_SIZE (decl) == NULL_TREE && !TREE_STATIC (decl))
     {
 
   if (DECL_SIZE (decl) == NULL_TREE && !TREE_STATIC (decl))
     {
@@ -7481,6 +7483,16 @@ initialize_local_var (decl, init, flags)
       TREE_ADDRESSABLE (decl) = TREE_USED (decl);
     }
 
       TREE_ADDRESSABLE (decl) = TREE_USED (decl);
     }
 
+  /* Local statics are handled differently from ordinary automatic
+     variables.  */
+  if (TREE_STATIC (decl))
+    {
+      if (TYPE_NEEDS_CONSTRUCTING (type) || init != NULL_TREE
+         || TYPE_NEEDS_DESTRUCTOR (type))
+       expand_static_init (decl, init);
+      return;
+    }
+
   if (DECL_SIZE (decl) && type != error_mark_node)
     {
       int already_used;
   if (DECL_SIZE (decl) && type != error_mark_node)
     {
       int already_used;
@@ -7776,13 +7788,6 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
          if (init)
            DECL_INITIAL (decl) = init;
        }
          if (init)
            DECL_INITIAL (decl) = init;
        }
-      else if (TREE_STATIC (decl) && type != error_mark_node)
-       {
-         /* Cleanups for static variables are handled by `finish_file'.  */
-         if (TYPE_NEEDS_CONSTRUCTING (type) || init != NULL_TREE
-             || TYPE_NEEDS_DESTRUCTOR (type))
-           expand_static_init (decl, init);
-       }
       else if (TREE_CODE (CP_DECL_CONTEXT (decl)) == FUNCTION_DECL)
        {
          /* This is a local declaration.  */
       else if (TREE_CODE (CP_DECL_CONTEXT (decl)) == FUNCTION_DECL)
        {
          /* This is a local declaration.  */
@@ -7808,6 +7813,13 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
              destroy_local_var (decl);
            }
        }
              destroy_local_var (decl);
            }
        }
+      else if (TREE_STATIC (decl) && type != error_mark_node)
+       {
+         /* Cleanups for static variables are handled by `finish_file'.  */
+         if (TYPE_NEEDS_CONSTRUCTING (type) || init != NULL_TREE
+             || TYPE_NEEDS_DESTRUCTOR (type))
+           expand_static_init (decl, init);
+       }
     finish_end0:
 
       /* Undo call to `pushclass' that was done in `start_decl'
     finish_end0:
 
       /* Undo call to `pushclass' that was done in `start_decl'
@@ -14293,7 +14305,8 @@ lang_mark_tree (t)
       if (ld)
        {
          ggc_mark (ld);
       if (ld)
        {
          ggc_mark (ld);
-         ggc_mark_tree (ld->decl_flags.access);
+         if (!DECL_GLOBAL_CTOR_P (t) && !DECL_GLOBAL_DTOR_P (t))
+           ggc_mark_tree (ld->decl_flags.u2.access);
          ggc_mark_tree (ld->decl_flags.context);
          if (TREE_CODE (t) != NAMESPACE_DECL)
            ggc_mark_tree (ld->decl_flags.u.template_info);
          ggc_mark_tree (ld->decl_flags.context);
          if (TREE_CODE (t) != NAMESPACE_DECL)
            ggc_mark_tree (ld->decl_flags.u.template_info);