PR debug/45997
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Dec 2010 19:33:52 +0000 (19:33 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Dec 2010 19:33:52 +0000 (19:33 +0000)
* dwarf2out.c (modified_type_die): If both is_const_type and
is_volatile_type is set, start with DW_TAG_const_type or
DW_TAG_volatile_type depending on where we get qualified type
in the recursive call.

* g++.dg/debug/dwarf2/pr45997-1.C: New test.
* g++.dg/debug/dwarf2/pr45997-2.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167517 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/pr45997-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/pr45997-2.C [new file with mode: 0644]

index cc1d2c6..c2d40f1 100644 (file)
@@ -1,5 +1,11 @@
 2010-12-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/45997
+       * dwarf2out.c (modified_type_die): If both is_const_type and
+       is_volatile_type is set, start with DW_TAG_const_type or
+       DW_TAG_volatile_type depending on where we get qualified type
+       in the recursive call.
+
        PR target/43897
        * config/ia64/ia64.c (rtx_needs_barrier): Handle asm CLOBBER
        as a store into that register.
index acb70ed..c985527 100644 (file)
@@ -12907,7 +12907,12 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
       /* Else cv-qualified version of named type; fall through.  */
     }
 
-  if (is_const_type)
+  if (is_const_type
+      /* If both is_const_type and is_volatile_type, prefer the path
+        which leads to a qualified type.  */
+      && (!is_volatile_type
+         || get_qualified_type (type, TYPE_QUAL_CONST) == NULL_TREE
+         || get_qualified_type (type, TYPE_QUAL_VOLATILE) != NULL_TREE))
     {
       mod_type_die = new_die (DW_TAG_const_type, comp_unit_die (), type);
       sub_die = modified_type_die (type, 0, is_volatile_type, context_die);
@@ -12915,7 +12920,7 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
   else if (is_volatile_type)
     {
       mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die (), type);
-      sub_die = modified_type_die (type, 0, 0, context_die);
+      sub_die = modified_type_die (type, is_const_type, 0, context_die);
     }
   else if (code == POINTER_TYPE)
     {
index b0ed621..0aecee3 100644 (file)
@@ -1,5 +1,9 @@
 2010-12-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/45997
+       * g++.dg/debug/dwarf2/pr45997-1.C: New test.
+       * g++.dg/debug/dwarf2/pr45997-2.C: New test.
+
        PR target/43897
        * gcc.target/ia64/pr43897.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr45997-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr45997-1.C
new file mode 100644 (file)
index 0000000..72f24ad
--- /dev/null
@@ -0,0 +1,22 @@
+// PR debug/45997
+// { dg-do compile }
+// { dg-options "-gdwarf-2 -dA" }
+
+typedef int my_int;
+typedef const my_int const_my_int;
+typedef volatile const_my_int volatile_const_my_int;
+
+my_int v_my_int = 0;
+const_my_int v_const_my_int = 1;
+volatile_const_my_int v_volatile_const_my_int = 4;
+
+int
+main ()
+{
+  asm volatile ("" : : "r" (&v_my_int));
+  asm volatile ("" : : "r" (&v_const_my_int));
+  asm volatile ("" : : "r" (&v_volatile_const_my_int));
+  return 0;
+}
+
+// { dg-final { scan-assembler-times "DIE\[^\n\r\]*DW_TAG_base_type" 1 } }
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr45997-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr45997-2.C
new file mode 100644 (file)
index 0000000..ade5428
--- /dev/null
@@ -0,0 +1,22 @@
+// PR debug/45997
+// { dg-do compile }
+// { dg-options "-gdwarf-2 -dA" }
+
+typedef int my_int;
+typedef volatile my_int volatile_my_int;
+typedef const volatile_my_int const_volatile_my_int;
+
+my_int v_my_int = 0;
+volatile_my_int v_volatile_my_int = 1;
+const_volatile_my_int v_const_volatile_my_int = 4;
+
+int
+main ()
+{
+  asm volatile ("" : : "r" (&v_my_int));
+  asm volatile ("" : : "r" (&v_volatile_my_int));
+  asm volatile ("" : : "r" (&v_const_volatile_my_int));
+  return 0;
+}
+
+// { dg-final { scan-assembler-times "DIE\[^\n\r\]*DW_TAG_base_type" 1 } }