OSDN Git Service

PR c++/43509
[pf3gnuchains/gcc-fork.git] / gcc / cp / decl2.c
index 29971ce..2fd6305 100644 (file)
@@ -1272,7 +1272,7 @@ cp_reconstruct_complex_type (tree type, tree bottom)
 
   if (TYPE_ATTRIBUTES (type))
     outer = cp_build_type_attribute_variant (outer, TYPE_ATTRIBUTES (type));
-  return cp_build_qualified_type (outer, TYPE_QUALS (type));
+  return cp_build_qualified_type (outer, cp_type_quals (type));
 }
 
 /* Like decl_attributes, but handle C++ complexity.  */
@@ -1808,6 +1808,7 @@ maybe_emit_vtables (tree ctype)
   tree vtbl;
   tree primary_vtbl;
   int needed = 0;
+  struct varpool_node *current = NULL, *last = NULL, *first = NULL;
 
   /* If the vtables for this class have already been emitted there is
      nothing more to do.  */
@@ -1865,8 +1866,20 @@ maybe_emit_vtables (tree ctype)
         actually marking the variable as written.  */
       if (flag_syntax_only)
        TREE_ASM_WRITTEN (vtbl) = 1;
+      else if (DECL_COMDAT (vtbl))
+       {
+         current = varpool_node (vtbl);
+         if (last)
+           last->same_comdat_group = current;
+         last = current;
+         if (!first)
+           first = current;
+       }
     }
 
+  if (first != last)
+    last->same_comdat_group = first;
+
   /* Since we're writing out the vtable here, also write the debug
      info.  */
   note_debug_info_needed (ctype);
@@ -3358,19 +3371,9 @@ cxx_callgraph_analyze_expr (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED)
        cgraph_mark_address_taken_node (cgraph_node (BASELINK_FUNCTIONS (t)));
       break;
     case VAR_DECL:
-      if (DECL_VTABLE_OR_VTT_P (t))
-       {
-         /* The ABI requires that all virtual tables be emitted
-            whenever one of them is.  */
-         tree vtbl;
-         for (vtbl = CLASSTYPE_VTABLES (DECL_CONTEXT (t));
-              vtbl;
-              vtbl = TREE_CHAIN (vtbl))
-           mark_decl_referenced (vtbl);
-       }
-      else if (DECL_CONTEXT (t)
-              && flag_use_repository
-              && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
+      if (DECL_CONTEXT (t)
+         && flag_use_repository
+         && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
        /* If we need a static variable in a function, then we
           need the containing function.  */
        mark_decl_referenced (DECL_CONTEXT (t));