This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Updated fix for debug/7081


As someone pointed out, i could also move CLASSTYPE_DECLARED_CLASS to
tree.h, and use that macro instead (making it use a different bit).

That would cut out the necessity for a cp/decl.c change, and is just fine
by me.

That version is below:


2003-06-15  Daniel Berlin  <dberlin@dberlin.org>

	* tree.h (CLASSTYPE_DECLARED_CLASS): New macro.
	(struct tree_type): Use one of the spare bits to record whether
	this is really a class or a struct.

	* dwarf2out.c (is_really_class): New function.
	(class_scope_p): DW_TAG_class_type is a class scope as well.
	(gen_inlined_structure_type_die): Use DW_TAG_class_type if
	approriate.
	(gen_struct_or_union_type_die): Ditto.
For cp/
2003-06-15  Daniel Berlin <dberlin@dberlin.org>

	* cp-tree.h: Remove CLASSTYPE_DECLARED_CLASS, update number
	of dummy bits.

Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.430
diff -u -3 -p -r1.430 dwarf2out.c
--- dwarf2out.c	12 Jun 2003 19:01:04 -0000	1.430
+++ dwarf2out.c	16 Jun 2003 03:20:55 -0000
@@ -3688,6 +3688,7 @@ static bool is_cxx			PARAMS ((void));
 static bool is_java			PARAMS ((void));
 static bool is_fortran			PARAMS ((void));
 static bool is_ada			PARAMS ((void));
+static bool is_really_class             PARAMS ((tree));
 static void remove_AT			PARAMS ((dw_die_ref,
 						 enum dwarf_attribute));
 static inline void free_die		PARAMS ((dw_die_ref));
@@ -5140,6 +5141,20 @@ is_ada ()
   return lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83;
 }

+
+/* Return true if TYPE is really a C++ class (IE not a struct ) */
+
+static inline bool
+is_really_class (type)
+     tree type;
+{
+  if (!is_cxx ())
+    return false;
+  if (CLASSTYPE_DECLARED_CLASS (type))
+    return true;
+  return false;
+}
+
 /* Free up the memory used by A.  */

 static inline void free_AT PARAMS ((dw_attr_ref));
@@ -10375,7 +10390,8 @@ class_scope_p (context_die)
 {
   return (context_die
 	  && (context_die->die_tag == DW_TAG_structure_type
-	      || context_die->die_tag == DW_TAG_union_type));
+	      || context_die->die_tag == DW_TAG_union_type
+	      || context_die->die_tag == DW_TAG_class_type));
 }

 /* Many forms of DIEs require a "type description" attribute.  This
@@ -10624,7 +10640,11 @@ gen_inlined_structure_type_die (type, co
      tree type;
      dw_die_ref context_die;
 {
-  dw_die_ref type_die = new_die (DW_TAG_structure_type, context_die, type);
+  dw_die_ref type_die;
+
+  type_die = new_die (is_really_class (type) ? DW_TAG_class_type
+		      : DW_TAG_structure_type,
+		      context_die, type);

   /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
      be incomplete and such types are not marked.  */
@@ -11657,6 +11677,7 @@ gen_struct_or_union_type_die (type, cont
 {
   dw_die_ref type_die = lookup_type_die (type);
   dw_die_ref scope_die = 0;
+  bool is_class = is_really_class (type);
   int nested = 0;
   int complete = (TYPE_SIZE (type)
 		  && (! TYPE_STUB_DECL (type)
@@ -11675,10 +11696,12 @@ gen_struct_or_union_type_die (type, cont
     /* First occurrence of type or toplevel definition of nested class.  */
     {
       dw_die_ref old_die = type_die;
+      if (TREE_CODE (type) == RECORD_TYPE)
+	type_die = new_die (is_class ? DW_TAG_class_type
+			    : DW_TAG_structure_type, scope_die, type);
+      else
+	type_die = new_die (DW_TAG_union_type, scope_die, type);

-      type_die = new_die (TREE_CODE (type) == RECORD_TYPE
-			  ? DW_TAG_structure_type : DW_TAG_union_type,
-			  scope_die, type);
       equate_type_number_to_die (type, type_die);
       if (old_die)
 	add_AT_die_ref (type_die, DW_AT_specification, old_die);
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.409
diff -u -3 -p -r1.409 tree.h
--- tree.h	15 Jun 2003 13:43:31 -0000	1.409
+++ tree.h	16 Jun 2003 03:20:55 -0000
@@ -1066,6 +1066,10 @@ struct tree_block GTY(())
    compact a way as possible.  */
 #define TYPE_PACKED(NODE) (TYPE_CHECK (NODE)->type.packed_flag)

+/* For a RECORD_TYPE, indicates that it was originally declared as
+   a class in the source code. */
+#define CLASSTYPE_DECLARED_CLASS(NODE) (TYPE_CHECK (NODE)->type.class_flag)
+
 struct die_struct;

 struct tree_type GTY(())
@@ -1086,7 +1090,8 @@ struct tree_type GTY(())
   unsigned transparent_union_flag : 1;
   unsigned packed_flag : 1;
   unsigned restrict_flag : 1;
-  unsigned spare : 2;
+  unsigned class_flag : 1;
+  unsigned spare : 1;

   unsigned lang_flag_0 : 1;
   unsigned lang_flag_1 : 1;


Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.851
diff -u -3 -p -r1.851 cp-tree.h
--- cp-tree.h	12 Jun 2003 00:10:24 -0000	1.851
+++ cp-tree.h	16 Jun 2003 14:44:14 -0000
@@ -1060,7 +1060,6 @@ struct lang_type_class GTY(())

   unsigned marks: 6;
   unsigned vec_new_uses_cookie : 1;
-  unsigned declared_class : 1;

   unsigned being_defined : 1;
   unsigned redefined : 1;
@@ -1090,7 +1089,7 @@ struct lang_type_class GTY(())
   /* There are some bits left to fill out a 32-bit word.  Keep track
      of this by updating the size of this bitfield whenever you add or
      remove a flag.  */
-  unsigned dummy : 5;
+  unsigned dummy : 6;

   tree primary_base;
   tree vfields;
@@ -1404,10 +1403,6 @@ struct lang_type GTY(())
 /* A list of the classes which grant friendship to this class.  */
 #define CLASSTYPE_BEFRIENDING_CLASSES(NODE) \
   (LANG_TYPE_CLASS_CHECK (NODE)->befriending_classes)
-
-/* Say whether this node was declared as a "class" or a "struct".  */
-#define CLASSTYPE_DECLARED_CLASS(NODE) \
-  (LANG_TYPE_CLASS_CHECK (NODE)->declared_class)

 /* Nonzero if this class has const members
    which have no specified initialization.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]