DWARFv5 Emit DW_TAG_atomic_type for C11 _Atomic.
authorMark Wielaard <mjw@redhat.com>
Mon, 8 Dec 2014 22:32:23 +0000 (22:32 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Mon, 8 Dec 2014 22:32:23 +0000 (22:32 +0000)
This implements the DW_TAG_atomic_type for C11 _Atomic proposal as adopted
in the latest DWARF5 draft. http://dwarfstd.org/ShowIssue.php?issue=131112.1

gcc/ChangeLog

PR debug/60782
* dwarf2out.c (modified_type_die): Handle TYPE_QUAL_ATOMIC.

gcc/testsuite/ChangeLog

PR debug/60782
* gcc.dg/debug/dwarf2/atomic.c: New test.
* gcc.dg/debug/dwarf2/stacked-qualified-types-3.c: Likewise.

include/ChangeLog

PR debug/60782
* dwarf2.def: Add DWARFv5 DW_TAG_atomic_type.

From-SVN: r218496

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/dwarf2/atomic.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/dwarf2/stacked-qualified-types-3.c [new file with mode: 0644]
include/ChangeLog
include/dwarf2.def

index c44fce6bc914d1aa64ecc38ce0323264cc27b5d1..8e8de749a6abc89de80c8d51975f6c96d68a7b49 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-08  Mark Wielaard  <mjw@redhat.com>
+
+       PR debug/60782
+       * dwarf2out.c (modified_type_die): Handle TYPE_QUAL_ATOMIC.
+
 2014-11-15  David Wohlferd <dw@LimeGreenSocks.com>
 
         PR target/61692
index ca1e3ef63f019c1a85792d3fb736aa1f25ecdf76..34b327e7514610a70450cdbbb909cc16a17ef3bf 100644 (file)
@@ -10551,7 +10551,7 @@ modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
   dw_die_ref mod_scope;
   /* Only these cv-qualifiers are currently handled.  */
   const int cv_qual_mask = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE
-                           | TYPE_QUAL_RESTRICT);
+                           | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC);
 
   if (code == ERROR_MARK)
     return NULL;
@@ -10564,6 +10564,10 @@ modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
   if (dwarf_version < 3)
     cv_quals &= ~TYPE_QUAL_RESTRICT;
 
+  /* Likewise for DW_TAG_atomic_type for DWARFv5.  */
+  if (dwarf_version < 5)
+    cv_quals &= ~TYPE_QUAL_ATOMIC;
+
   /* See if we already have the appropriately qualified variant of
      this type.  */
   qualified_type = get_qualified_type (type, cv_quals);
@@ -10625,6 +10629,7 @@ modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
       struct qual_info { int q; enum dwarf_tag t; };
       static const struct qual_info qual_info[] =
        {
+         { TYPE_QUAL_ATOMIC, DW_TAG_atomic_type },
          { TYPE_QUAL_RESTRICT, DW_TAG_restrict_type },
          { TYPE_QUAL_VOLATILE, DW_TAG_volatile_type },
          { TYPE_QUAL_CONST, DW_TAG_const_type },
index 79963a7e3eaeb953c4c73e3cfd7d8665bfeb0b79..08ddd7b95181d69c71c7fa2a1ce11315a85b342a 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-08  Mark Wielaard  <mjw@redhat.com>
+
+       PR debug/60782
+       * gcc.dg/debug/dwarf2/atomic.c: New test.
+       * gcc.dg/debug/dwarf2/stacked-qualified-types-3.c: Likewise.
+
 2014-11-15  David Wohlferd <dw@LimeGreenSocks.com> 
 
        PR target/61692
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/atomic.c b/gcc/testsuite/gcc.dg/debug/dwarf2/atomic.c
new file mode 100644 (file)
index 0000000..187e695
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -gdwarf-5 -dA" } */
+
+struct Atomics
+{
+  _Atomic(int) counter;
+  struct Pointer
+  {
+    _Atomic volatile char *p;
+  } p;
+};
+
+struct Atomics a;
+
+/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_atomic_type" 2 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/stacked-qualified-types-3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/stacked-qualified-types-3.c
new file mode 100644 (file)
index 0000000..efa3fa0
--- /dev/null
@@ -0,0 +1,34 @@
+/* make sure we don't duplicate type qualifiers unneeded.  */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -gdwarf-5 -dA" } */
+
+/* This should give us:
+   - One const type pointing to a char
+   - One volatile type pointing to a char
+   - One atomic type pointing to a char
+   - Either one const type pointing to the volatile type pointing to a char
+     or one volatile type pointing to the const type pointing to a char.
+     But not both.
+   - Either one volatile type pointing to an atomic type pointing to a char
+     or one atomic type pointing to a volatile type pointing to a char.
+     But not both.
+   - One restrict type pointing to a char pointer.
+   - One atomic type pointing to a char pointer.
+   - Either one restrict type pointing to an atomic type pointing to a char
+     pointer or one atomic type pointing to a restrict type pointing to a
+     char pointer.
+     But not both.  */
+
+
+char a;
+const char b;
+volatile const char c;
+volatile char d;
+const volatile char e;
+_Atomic char f;
+_Atomic volatile char g;
+char * _Atomic restrict h;
+char * _Atomic i;
+char * restrict j;
+
+/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_(?:const|volatile|atomic|restrict)_type" 8 } } */
index e0baca9c10d91b351dbb25701290efd9bbfe7c5c..632420c7699eea77642a43d7becc6558231f6c4e 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-08  Mark Wielaard  <mjw@redhat.com>
+
+       PR debug/60782
+       * dwarf2.def: Add DWARFv5 DW_TAG_atomic_type.
+
 2014-11-21  Mark Wielaard  <mjw@redhat.com>
 
        * dwarf2.h: Add DW_LANG_C_plus_plus_11, DW_LANG_C11 and
index 8533a3edbd588f2d7f9ef36c028c25b5f2133bb0..ea8127c8b1d626dd3da88a0f6d5cbab2992d3bd4 100644 (file)
@@ -133,6 +133,8 @@ DW_TAG (DW_TAG_shared_type, 0x40)
 DW_TAG (DW_TAG_type_unit, 0x41)
 DW_TAG (DW_TAG_rvalue_reference_type, 0x42)
 DW_TAG (DW_TAG_template_alias, 0x43)
+/* DWARF 5.  */
+DW_TAG (DW_TAG_atomic_type, 0x47)
 
 DW_TAG_DUP (DW_TAG_lo_user, 0x4080)
 DW_TAG_DUP (DW_TAG_hi_user, 0xffff)