Revert "Fix PR c++/44188"
authorDodji Seketeli <dodji@redhat.com>
Fri, 28 May 2010 00:03:19 +0000 (00:03 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Fri, 28 May 2010 00:03:19 +0000 (02:03 +0200)
gcc/ChangeLog:
revert fix for PR c++/44188
* c-common.c (is_typedef_decl): Revert the moving of  this
definition ...
* tree.c (is_typedef_decl): ... here.
(typdef_variant_p): Revert the moving of this  definition
here from gcc/cp/tree.c.
* c-common.h (is_typedef_decl): Revert the moving of this
declaration ...
* tree.h (is_typedef_decl): ... here.
(typedef_variant_p): Revert the moving of this  declaration here
from gcc/cp/cp-tree.h
* dwarf2out.c (is_naming_typedef_decl): Revert this new function.
(gen_tagged_type_die): Revert the splitting out of ...
(gen_type_die_with_usage): ... this function. Revert the anonymous
tagged type handling.
(gen_typedef_die): Revert emitting DW_TAG_typedef  for
typedefs naming anonymous tagged types.

gcc/cp/ChangeLog:
Revert fix of PR c++/44188
* cp-tree.h (typedef_variant_p): Revert moving this declaration to
gcc/tree.h.
* tree.c (typedef_variant_p): Revert moving this definition to
gcc/tree.c.
* decl.c (grokdeclarator): Revert naming typedef handling.

gcc/testsuite/ChangeLog:
Revert fix for PR c++/44188
* g++.dg/debug/dwarf2/typedef3.C: Revert new test.

From-SVN: r159955

12 files changed:
gcc/ChangeLog
gcc/c-common.c
gcc/c-common.h
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/tree.c
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/typedef3.C [deleted file]
gcc/tree.c
gcc/tree.h

index 00238536a451e46068c8ba97f5ae5eae69bffc1a..608f0ad6c2ef22e325b91eb828b65ba0fd819bc0 100644 (file)
@@ -1,3 +1,24 @@
+2010-05-28  Dodji Seketeli  <dodji@redhat.com>
+
+       revert fix for PR c++/44188
+       * c-common.c (is_typedef_decl): Revert the moving of  this
+       definition ...
+       * tree.c (is_typedef_decl): ... here.
+       (typdef_variant_p): Revert the moving of this  definition
+       here from gcc/cp/tree.c.
+       * c-common.h (is_typedef_decl): Revert the moving of this
+       declaration ...
+       * tree.h (is_typedef_decl): ... here.
+       (typedef_variant_p): Revert the moving of this  declaration here
+       from gcc/cp/cp-tree.h
+       * dwarf2out.c (is_naming_typedef_decl): Revert this new function.
+       (gen_tagged_type_die): Revert the splitting out of ...
+       (gen_type_die_with_usage): ... this function. Revert the anonymous
+       tagged type handling.
+       (gen_typedef_die): Revert emitting DW_TAG_typedef  for
+       typedefs naming anonymous tagged types.
+
+
 2010-05-28  Segher Boessenkool  <segher@kernel.crashing.org>
 
        * config/rs6000/rs6000-modes.def (PSImode): Delete.
index e72aaf90101c3a41b263ae68b0328e0542507846..1fd11c50c64f7aa53f987b91e32e1f4c3f1d735b 100644 (file)
@@ -9387,6 +9387,15 @@ set_underlying_type (tree x)
     }
 }
 
+/* Returns true if X is a typedef decl.  */
+
+bool
+is_typedef_decl (tree x)
+{
+  return (x && TREE_CODE (x) == TYPE_DECL
+          && DECL_ORIGINAL_TYPE (x) != NULL_TREE);
+}
+
 /* Record the types used by the current global variable declaration
    being parsed, so that we can decide later to emit their debug info.
    Those types are in types_used_by_cur_var_decl, and we are going to
index ec63e0c41632a6379f42acaea31442257c4bcaf9..039edbee97441ff899a06af09aef85f820382ab3 100644 (file)
@@ -1055,6 +1055,7 @@ extern void warn_for_sign_compare (location_t,
                                   tree result_type,
                                   enum tree_code resultcode);
 extern void set_underlying_type (tree x);
+extern bool is_typedef_decl (tree x);
 extern VEC(tree,gc) *make_tree_vector (void);
 extern void release_tree_vector (VEC(tree,gc) *);
 extern VEC(tree,gc) *make_tree_vector_single (tree);
index 80d86c8e13930802d12efe84debdbc41fe4dbce8..cfab057a38f91d945933a5c452a572100323d177 100644 (file)
@@ -1,3 +1,12 @@
+2010-05-28  Dodji Seketeli  <dodji@redhat.com>
+
+       Revert fix of PR c++/44188
+       * cp-tree.h (typedef_variant_p): Revert moving this declaration to
+       gcc/tree.h.
+       * tree.c (typedef_variant_p): Revert moving this definition to
+       gcc/tree.c.
+       * decl.c (grokdeclarator): Revert naming typedef handling.
+
 2010-05-27  Joseph Myers  <joseph@codesourcery.com>
 
        * call.c: Include diagnostic-core.h instead of diagnostic.h.
index 4d3cf7dd90bbafebe99f65b222dfbddab70887bd..37a0f1e50ea3762f2a3d05a4feb9227c931398b2 100644 (file)
@@ -5256,6 +5256,7 @@ extern bool type_has_nontrivial_copy_init (const_tree);
 extern bool class_tmpl_impl_spec_p             (const_tree);
 extern int zero_init_p                         (const_tree);
 extern tree strip_typedefs                     (tree);
+extern bool typedef_variant_p                  (tree);
 extern void cp_set_underlying_type             (tree);
 extern tree copy_binfo                         (tree, tree, tree,
                                                 tree *, int);
index 533b56f48b9fa89e67c1e624ca741b8e7f4b83b8..0d30340358867d08c275b35c5d5462afadb35b2c 100644 (file)
@@ -9081,12 +9081,10 @@ grokdeclarator (const cp_declarator *declarator,
          for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
            {
              if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))
-               /* We do not rename the debug info representing the
-                  anonymous tagged type because the standard says in
-                  [dcl.typedef] that the naming applies only for
-                  linkage purposes.  */
-               /*debug_hooks->set_name (t, decl);*/
-               TYPE_NAME (t) = decl;
+               {
+                 debug_hooks->set_name (t, decl);
+                 TYPE_NAME (t) = decl;
+               }
            }
 
          if (TYPE_LANG_SPECIFIC (type))
index 5421980a05288ce9dd9ae2426a7cbd8f39ac6b66..d5ccd65a790031e9dbba9c743430ab5cafe04690 100644 (file)
@@ -1055,6 +1055,14 @@ strip_typedefs (tree t)
   return cp_build_qualified_type (result, cp_type_quals (t));
 }
 
+/* Returns true iff TYPE is a type variant created for a typedef. */
+
+bool
+typedef_variant_p (tree type)
+{
+  return is_typedef_decl (TYPE_NAME (type));
+}
+
 /* Setup a TYPE_DECL node as a typedef representation.
    See comments of set_underlying_type in c-common.c.  */
 
index 8cdb7aaaff61f44e4bf2fd5b84c5045d99ff7232..521a25fdcdf9a37aada60692b6694a1b44886196 100644 (file)
@@ -6202,7 +6202,6 @@ static void gen_type_die (tree, dw_die_ref);
 static void gen_block_die (tree, dw_die_ref, int);
 static void decls_for_scope (tree, dw_die_ref, int);
 static int is_redundant_typedef (const_tree);
-static bool is_naming_typedef_decl (const_tree);
 static inline dw_die_ref get_context_die (tree);
 static void gen_namespace_die (tree, dw_die_ref);
 static void gen_decl_die (tree, tree, dw_die_ref);
@@ -6214,8 +6213,6 @@ static struct dwarf_file_data * lookup_filename (const char *);
 static void retry_incomplete_types (void);
 static void gen_type_die_for_member (tree, tree, dw_die_ref);
 static void gen_generic_params_dies (tree);
-static void gen_tagged_type_die (tree, dw_die_ref, enum debug_info_usage);
-static void gen_type_die_with_usage (tree, dw_die_ref, enum debug_info_usage);
 static void splice_child_die (dw_die_ref, dw_die_ref);
 static int file_info_cmp (const void *, const void *);
 static dw_loc_list_ref new_loc_list (dw_loc_descr_ref, const char *,
@@ -19411,33 +19408,10 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
          equate_type_number_to_die (TREE_TYPE (decl), type_die);
        }
       else
-       {
-         /* Here, we are in the case of decl being a typedef naming
-            an anonymous type, e.g:
-               typedef struct {...} foo;
-            In that case TREE_TYPE (decl) is not a typedef variant
-            type and TYPE_NAME of the anonymous type is set to the
-            TYPE_DECL of the typedef. This construct is emitted by
-            the C++ FE.  */
-         type = TREE_TYPE (decl);
-
-         /* TYPE is the anonymous struct named by the typedef
-            DECL. As we need the DW_AT_type attribute of the
-            DW_TAG_typedef to point to the DIE of TYPE, let's
-            generate that DIE right away. add_type_attribute
-            called below will then pick (via lookup_type_die) that
-            anonymous struct DIE.  */
-         gen_tagged_type_die (type, context_die, DINFO_USAGE_DIR_USE);
-       }
+       type = TREE_TYPE (decl);
 
       add_type_attribute (type_die, type, TREE_READONLY (decl),
                          TREE_THIS_VOLATILE (decl), context_die);
-
-      if (is_naming_typedef_decl (decl))
-       /* We want that all subsequent calls to lookup_type_die with
-          TYPE in argument yield the DW_TAG_typedef we have just
-          created.  */
-       equate_type_number_to_die (type, type_die);
     }
 
   if (DECL_ABSTRACT (decl))
@@ -19447,74 +19421,13 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
     add_pubtype (decl, type_die);
 }
 
-/* Generate a DIE for a struct, class, enum or union type.  */
-
-static void
-gen_tagged_type_die (tree type,
-                    dw_die_ref context_die,
-                    enum debug_info_usage usage)
-{
-  int need_pop;
-
-  /* If this is a nested type whose containing class hasn't been written
-     out yet, writing it out will cover this one, too.  This does not apply
-     to instantiations of member class templates; they need to be added to
-     the containing class as they are generated.  FIXME: This hurts the
-     idea of combining type decls from multiple TUs, since we can't predict
-     what set of template instantiations we'll get.  */
-  if (TYPE_CONTEXT (type)
-      && AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
-      && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
-    {
-      gen_type_die_with_usage (TYPE_CONTEXT (type), context_die, usage);
-
-      if (TREE_ASM_WRITTEN (type))
-       return;
-
-      /* If that failed, attach ourselves to the stub.  */
-      push_decl_scope (TYPE_CONTEXT (type));
-      context_die = lookup_type_die (TYPE_CONTEXT (type));
-      need_pop = 1;
-    }
-  else if (TYPE_CONTEXT (type) != NULL_TREE
-          && (TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL))
-    {
-      /* If this type is local to a function that hasn't been written
-        out yet, use a NULL context for now; it will be fixed up in
-        decls_for_scope.  */
-      context_die = lookup_decl_die (TYPE_CONTEXT (type));
-      need_pop = 0;
-    }
-  else
-    {
-      context_die = declare_in_namespace (type, context_die);
-      need_pop = 0;
-    }
-
-  if (TREE_CODE (type) == ENUMERAL_TYPE)
-    {
-      /* This might have been written out by the call to
-        declare_in_namespace.  */
-      if (!TREE_ASM_WRITTEN (type))
-       gen_enumeration_type_die (type, context_die);
-    }
-  else
-    gen_struct_or_union_type_die (type, context_die, usage);
-
-  if (need_pop)
-    pop_decl_scope ();
-
-  /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
-     it up if it is ever completed.  gen_*_type_die will set it for us
-     when appropriate.  */
-}
-
 /* Generate a type description DIE.  */
 
 static void
 gen_type_die_with_usage (tree type, dw_die_ref context_die,
                                enum debug_info_usage usage)
 {
+  int need_pop;
   struct array_descr_info info;
 
   if (type == NULL_TREE || type == error_mark_node)
@@ -19522,7 +19435,8 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
 
   /* If TYPE is a typedef type variant, let's generate debug info
      for the parent typedef which TYPE is a type of.  */
-  if (typedef_variant_p (type))
+  if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+      && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
     {
       if (TREE_ASM_WRITTEN (type))
        return;
@@ -19537,21 +19451,6 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
        context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type)));
 
       TREE_ASM_WRITTEN (type) = 1;
-
-      gen_decl_die (TYPE_NAME (type), NULL, context_die);
-      return;
-    }
-
-  /* If type is an anonymous tagged type named by a typedef, let's
-     generate debug info for the typedef.  */
-  if (is_naming_typedef_decl (TYPE_NAME (type)))
-    {
-      /* Use the DIE of the containing namespace as the parent DIE of
-         the type description DIE we want to generate.  */
-      if (DECL_CONTEXT (TYPE_NAME (type))
-         && TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) == NAMESPACE_DECL)
-       context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type)));
-      
       gen_decl_die (TYPE_NAME (type), NULL, context_die);
       return;
     }
@@ -19639,7 +19538,57 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
     case RECORD_TYPE:
     case UNION_TYPE:
     case QUAL_UNION_TYPE:
-      gen_tagged_type_die (type, context_die, usage);
+      /* If this is a nested type whose containing class hasn't been written
+        out yet, writing it out will cover this one, too.  This does not apply
+        to instantiations of member class templates; they need to be added to
+        the containing class as they are generated.  FIXME: This hurts the
+        idea of combining type decls from multiple TUs, since we can't predict
+        what set of template instantiations we'll get.  */
+      if (TYPE_CONTEXT (type)
+         && AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
+         && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
+       {
+         gen_type_die_with_usage (TYPE_CONTEXT (type), context_die, usage);
+
+         if (TREE_ASM_WRITTEN (type))
+           return;
+
+         /* If that failed, attach ourselves to the stub.  */
+         push_decl_scope (TYPE_CONTEXT (type));
+         context_die = lookup_type_die (TYPE_CONTEXT (type));
+         need_pop = 1;
+       }
+      else if (TYPE_CONTEXT (type) != NULL_TREE
+              && (TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL))
+       {
+         /* If this type is local to a function that hasn't been written
+            out yet, use a NULL context for now; it will be fixed up in
+            decls_for_scope.  */
+         context_die = lookup_decl_die (TYPE_CONTEXT (type));
+         need_pop = 0;
+       }
+      else
+       {
+         context_die = declare_in_namespace (type, context_die);
+         need_pop = 0;
+       }
+
+      if (TREE_CODE (type) == ENUMERAL_TYPE)
+       {
+         /* This might have been written out by the call to
+            declare_in_namespace.  */
+         if (!TREE_ASM_WRITTEN (type))
+           gen_enumeration_type_die (type, context_die);
+       }
+      else
+       gen_struct_or_union_type_die (type, context_die, usage);
+
+      if (need_pop)
+       pop_decl_scope ();
+
+      /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
+        it up if it is ever completed.  gen_*_type_die will set it for us
+        when appropriate.  */
       return;
 
     case VOID_TYPE:
@@ -19847,31 +19796,6 @@ is_redundant_typedef (const_tree decl)
   return 0;
 }
 
-/* Return TRUE if TYPE is a typedef that names a type for linkage
-   purposes. This kind of typedefs is produced by the C++ FE for
-   constructs like:
-
-   typedef struct {...} foo;
-
-   In that case, there is no typedef variant type produced for foo.
-   Rather, the TREE_TYPE of the TYPE_DECL of foo is the anonymous
-   struct type.  */
-
-static bool
-is_naming_typedef_decl (const_tree decl)
-{
-  if (decl == NULL_TREE
-      || TREE_CODE (decl) != TYPE_DECL
-      || !is_tagged_type (TREE_TYPE (decl))
-      || is_redundant_typedef (decl))
-    return FALSE;
-
-  return (DECL_ORIGINAL_TYPE (decl) == NULL_TREE
-         && TYPE_NAME (TREE_TYPE (decl)) == decl
-         && (TYPE_STUB_DECL (TREE_TYPE (decl))
-             != TYPE_NAME (TREE_TYPE (decl))));
-}
-
 /* Returns the DIE for a context.  */
 
 static inline dw_die_ref
index e36bb0d1f85a570e1edfcb08fcbd18693ec2545a..eb52c55e577f438d55bbf4eb9a77d0e9ceb9c138 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-28  Dodji Seketeli  <dodji@redhat.com>
+
+       Revert patch for PR c++/44188
+       * g++.dg/debug/dwarf2/typedef3.C: Revert new test.
+
 2010-05-25  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/44188
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/typedef3.C b/gcc/testsuite/g++.dg/debug/dwarf2/typedef3.C
deleted file mode 100644 (file)
index ca70d9c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Origin: PR debug/44188
-// { dg-options "-g -dA" }
-// { dg-do compile }
-
-// { dg-final { scan-assembler-times "\[^\n\r\]*\\(DIE\[^\n\r\]*DW_TAG_typedef\\)" 1 } }
-
-// { dg-final { scan-assembler-times "\[^\n\r\]*\\(DIE\[^\n\r\]*DW_TAG_structure_type\\)" 1 } }
-
-typedef struct
-{
-  int i;
-} AAA;
-
-int
-main(void)
-{
-  AAA aa;
-  return 0;
-}
index 8b04c376594d22093d3a62058106a300959d489d..743293e288a55fa0e99632c7793c3120b87bd4f4 100644 (file)
@@ -10825,21 +10825,4 @@ get_binfo_at_offset (tree binfo, HOST_WIDE_INT offset, tree expected_type)
   return binfo;
 }
 
-/* Returns true if X is a typedef decl.  */
-
-bool
-is_typedef_decl (tree x)
-{
-  return (x && TREE_CODE (x) == TYPE_DECL
-          && DECL_ORIGINAL_TYPE (x) != NULL_TREE);
-}
-
-/* Returns true iff TYPE is a type variant created for a typedef. */
-
-bool
-typedef_variant_p (tree type)
-{
-  return is_typedef_decl (TYPE_NAME (type));
-}
-
 #include "gt-tree.h"
index 94379fe4dcfdf6ed32152978ef101470ff3e991f..5acadb499cb2a3d345e921c340c214b00ae56177 100644 (file)
@@ -4820,8 +4820,6 @@ extern tree create_artificial_label (location_t);
 extern const char *get_name (tree);
 extern bool stdarg_p (tree);
 extern bool prototype_p (tree);
-extern bool is_typedef_decl (tree x);
-extern bool typedef_variant_p (tree);
 extern bool auto_var_in_fn_p (const_tree, const_tree);
 extern tree build_low_bits_mask (tree, unsigned);
 extern tree tree_strip_nop_conversions (tree);