aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-04-08 22:00:48 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2009-04-08 22:00:48 +0200
commitce9ba79be25d021c2d0d25a6dd0ef03a54ae301b (patch)
tree51b6c54d2dfb926b1eeba7f599c2666e878d16f3 /gcc
parentd27f0ddc1ef8c08cacbda578966f9fa2a52e996e (diff)
downloadgcc-ce9ba79be25d021c2d0d25a6dd0ef03a54ae301b.zip
gcc-ce9ba79be25d021c2d0d25a6dd0ef03a54ae301b.tar.gz
gcc-ce9ba79be25d021c2d0d25a6dd0ef03a54ae301b.tar.bz2
dwarf2out.c (class_scope_p): New static inline.
* dwarf2out.c (class_scope_p): New static inline. (class_or_namespace_scope_p): Use it. (gen_variable_die): Use DW_TAG_member tag for static data member declarations instead of DW_TAG_variable. * g++.dg/debug/dwarf2/static-data-member1.C: New test. From-SVN: r145770
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/dwarf2out.c27
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/debug/dwarf2/static-data-member1.C12
4 files changed, 44 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5054bdc..5c09748 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2009-04-08 Jakub Jelinek <jakub@redhat.com>
+
+ * dwarf2out.c (class_scope_p): New static inline.
+ (class_or_namespace_scope_p): Use it.
+ (gen_variable_die): Use DW_TAG_member tag for static data member
+ declarations instead of DW_TAG_variable.
+
2009-04-08 Richard Guenther <rguenther@suse.de>
* tree-ssa-sccvn.c (valueize_refs): Do not continue to
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1bc1730..7d82c47 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -5136,6 +5136,7 @@ static void push_decl_scope (tree);
static void pop_decl_scope (void);
static dw_die_ref scope_die_for (tree, dw_die_ref);
static inline int local_scope_p (dw_die_ref);
+static inline int class_scope_p (dw_die_ref);
static inline int class_or_namespace_scope_p (dw_die_ref);
static void add_type_attribute (dw_die_ref, tree, int, int, dw_die_ref);
static void add_calling_convention_attribute (dw_die_ref, tree);
@@ -12679,18 +12680,26 @@ local_scope_p (dw_die_ref context_die)
return 0;
}
-/* Returns nonzero if CONTEXT_DIE is a class or namespace, for deciding
- whether or not to treat a DIE in this context as a declaration. */
+/* Returns nonzero if CONTEXT_DIE is a class. */
static inline int
-class_or_namespace_scope_p (dw_die_ref context_die)
+class_scope_p (dw_die_ref context_die)
{
return (context_die
&& (context_die->die_tag == DW_TAG_structure_type
|| context_die->die_tag == DW_TAG_class_type
|| context_die->die_tag == DW_TAG_interface_type
- || context_die->die_tag == DW_TAG_union_type
- || context_die->die_tag == DW_TAG_namespace));
+ || context_die->die_tag == DW_TAG_union_type));
+}
+
+/* Returns nonzero if CONTEXT_DIE is a class or namespace, for deciding
+ whether or not to treat a DIE in this context as a declaration. */
+
+static inline int
+class_or_namespace_scope_p (dw_die_ref context_die)
+{
+ return (class_scope_p (context_die)
+ || (context_die && context_die->die_tag == DW_TAG_namespace));
}
/* Many forms of DIEs require a "type description" attribute. This
@@ -13993,7 +14002,13 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
&& old_die->die_parent == context_die)
return;
- var_die = new_die (DW_TAG_variable, context_die, decl);
+ /* For static data members, the declaration in the class is supposed
+ to have DW_TAG_member tag; the specification should still be
+ DW_TAG_variable referencing the DW_TAG_member DIE. */
+ if (declaration && class_scope_p (context_die))
+ var_die = new_die (DW_TAG_member, context_die, decl);
+ else
+ var_die = new_die (DW_TAG_variable, context_die, decl);
origin_die = NULL;
if (origin != NULL)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 646ee1f..d843ba2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-04-08 Jakub Jelinek <jakub@redhat.com>
+
+ * g++.dg/debug/dwarf2/static-data-member1.C: New test.
+
2009-04-08 Jason Merrill <jason@redhat.com>
PR c++/25185
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/static-data-member1.C b/gcc/testsuite/g++.dg/debug/dwarf2/static-data-member1.C
new file mode 100644
index 0000000..dce279e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/static-data-member1.C
@@ -0,0 +1,12 @@
+// { dg-do compile }
+// { dg-options "-g -dA -fno-merge-debug-strings" }
+
+struct A
+{
+ static int staticdatamember;
+};
+
+int A::staticdatamember = 6;
+
+// { dg-final { scan-assembler "DW_TAG_member\[^\n\r\]*\[\n\r\]*\[^\n\r\]*staticdatamember\[^\n\r\]*DW_AT_name" } }
+// { dg-final { scan-assembler "DW_TAG_variable\[^\n\r\]*\[\n\r\]*\[^\n\r\]*DW_AT_specification" } }