OSDN Git Service

* match.c (match_arithmetic_if): Remove gfc_ prefix and correct
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.c
index 5f1d631..6b08ab6 100644 (file)
@@ -10568,11 +10568,7 @@ add_abstract_origin_attribute (dw_die_ref die, tree origin)
       if (TYPE_P (fn))
        fn = TYPE_STUB_DECL (fn);
       
-      /* TYPE_STUB_DECL may have given us a NULL, which decl_function_context
-        won't like.  */
-      if (fn)  
-       fn = decl_function_context (fn);
-
+      fn = decl_function_context (fn);
       if (fn)
        dwarf2out_abstract_function (fn);
     }
@@ -11222,13 +11218,27 @@ gen_type_die_for_member (tree type, tree member, dw_die_ref context_die)
   if (TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type))
       && ! lookup_decl_die (member))
     {
+      dw_die_ref type_die;
       gcc_assert (!decl_ultimate_origin (member));
 
       push_decl_scope (type);
+      type_die = lookup_type_die (type);
       if (TREE_CODE (member) == FUNCTION_DECL)
-       gen_subprogram_die (member, lookup_type_die (type));
+       gen_subprogram_die (member, type_die);
+      else if (TREE_CODE (member) == FIELD_DECL)
+       {
+         /* Ignore the nameless fields that are used to skip bits but handle
+            C++ anonymous unions and structs.  */
+         if (DECL_NAME (member) != NULL_TREE
+             || TREE_CODE (TREE_TYPE (member)) == UNION_TYPE
+             || TREE_CODE (TREE_TYPE (member)) == RECORD_TYPE)
+           {
+             gen_type_die (member_declared_type (member), type_die);
+             gen_field_die (member, type_die);
+           }
+       }
       else
-       gen_variable_die (member, lookup_type_die (type));
+       gen_variable_die (member, type_die);
 
       pop_decl_scope ();
     }
@@ -12935,7 +12945,29 @@ dwarf2out_imported_module_or_decl (tree decl, tree context)
   if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == CONST_DECL)
     at_import_die = force_type_die (TREE_TYPE (decl));
   else
-    at_import_die = force_decl_die (decl);
+    {
+      at_import_die = lookup_decl_die (decl);
+      if (!at_import_die)
+       {
+         /* If we're trying to avoid duplicate debug info, we may not have
+            emitted the member decl for this field.  Emit it now.  */
+         if (TREE_CODE (decl) == FIELD_DECL)
+           {
+             tree type = DECL_CONTEXT (decl);
+             dw_die_ref type_context_die;
+
+             if (TYPE_CONTEXT (type))
+               if (TYPE_P (TYPE_CONTEXT (type)))
+                 type_context_die = force_type_die (TYPE_CONTEXT (type));
+             else
+               type_context_die = force_decl_die (TYPE_CONTEXT (type));
+             else
+               type_context_die = comp_unit_die;
+             gen_type_die_for_member (type, decl, type_context_die);
+           }
+         at_import_die = force_decl_die (decl);
+       }
+    }
 
   /* OK, now we have DIEs for decl as well as scope. Emit imported die.  */
   if (TREE_CODE (decl) == NAMESPACE_DECL)