re PR c/47939 (Missing DW_TAG_typedef for qualified types)
authorRichard Guenther <rguenther@suse.de>
Mon, 21 Mar 2011 15:32:21 +0000 (15:32 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 21 Mar 2011 15:32:21 +0000 (15:32 +0000)
2011-03-21  Richard Guenther  <rguenther@suse.de>

PR c/47939
* c-decl.c (grokdeclarator): Drop to the main variant only
for array types.  Drop flag_gen_aux_info check.

* gcc.dg/debug/dwarf2/pr47939-1.c: New testcase.
* gcc.dg/debug/dwarf2/pr47939-2.c: Likewise.
* gcc.dg/debug/dwarf2/pr47939-3.c: Likewise.
* gcc.dg/debug/dwarf2/pr47939-4.c: Likewise.

From-SVN: r171245

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-4.c [new file with mode: 0644]

index 55e6e952b26f126f494f3ae588e9942fc731579e..30542ef287ad8180450ae3f7d8f4de1645a5074d 100644 (file)
@@ -1,3 +1,9 @@
+2011-03-21  Richard Guenther  <rguenther@suse.de>
+
+       PR c/47939
+       * c-decl.c (grokdeclarator): Drop to the main variant only
+       for array types.  Drop flag_gen_aux_info check.
+
 2011-03-21  Richard Guenther  <rguenther@suse.de>
 
        PR translation/47911
index 4e82f2844a8155c39cea36321510e54e06cf042f..1af3d23b6778d484c0ef6d3aec625dde5fa16ae2 100644 (file)
@@ -4888,6 +4888,7 @@ grokdeclarator (const struct c_declarator *declarator,
   const char *errmsg;
   tree expr_dummy;
   bool expr_const_operands_dummy;
+  enum c_declarator_kind first_non_attr_kind;
 
   if (TREE_CODE (type) == ERROR_MARK)
     return error_mark_node;
@@ -4907,6 +4908,7 @@ grokdeclarator (const struct c_declarator *declarator,
   {
     const struct c_declarator *decl = declarator;
 
+    first_non_attr_kind = cdk_attrs;
     while (decl)
       switch (decl->kind)
        {
@@ -4918,6 +4920,8 @@ grokdeclarator (const struct c_declarator *declarator,
        case cdk_pointer:
          funcdef_syntax = (decl->kind == cdk_function);
          decl = decl->declarator;
+         if (first_non_attr_kind == cdk_attrs)
+           first_non_attr_kind = decl->kind;
          break;
 
        case cdk_attrs:
@@ -4928,6 +4932,8 @@ grokdeclarator (const struct c_declarator *declarator,
          loc = decl->id_loc;
          if (decl->u.id)
            name = decl->u.id;
+         if (first_non_attr_kind == cdk_attrs)
+           first_non_attr_kind = decl->kind;
          decl = 0;
          break;
 
@@ -5034,7 +5040,9 @@ grokdeclarator (const struct c_declarator *declarator,
     error_at (loc, "conflicting named address spaces (%s vs %s)",
              c_addr_space_name (as1), c_addr_space_name (as2));
 
-  if (!flag_gen_aux_info && (TYPE_QUALS (element_type)))
+  if ((TREE_CODE (type) == ARRAY_TYPE
+       || first_non_attr_kind == cdk_array)
+      && TYPE_QUALS (element_type))
     type = TYPE_MAIN_VARIANT (type);
   type_quals = ((constp ? TYPE_QUAL_CONST : 0)
                | (restrictp ? TYPE_QUAL_RESTRICT : 0)
index 570ab6f7d8daedbb70463f59836e10a9ce47ec27..8bce5264b36df89ea547d6d2665b98b69aa7672f 100644 (file)
@@ -1,3 +1,11 @@
+2011-03-21  Richard Guenther  <rguenther@suse.de>
+
+       PR c/47939
+       * gcc.dg/debug/dwarf2/pr47939-1.c: New testcase.
+       * gcc.dg/debug/dwarf2/pr47939-2.c: Likewise.
+       * gcc.dg/debug/dwarf2/pr47939-3.c: Likewise.
+       * gcc.dg/debug/dwarf2/pr47939-4.c: Likewise.
+
 2011-03-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/48213
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-1.c
new file mode 100644 (file)
index 0000000..7854fdf
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-save-temps -g -dA" } */
+
+typedef struct _Harry { int dummy; } Harry_t;
+Harry_t harry;
+
+/* { dg-final { scan-assembler "DW_TAG_typedef\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_name: \"Harry_t\"" } } */
+/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-2.c
new file mode 100644 (file)
index 0000000..8b623ae
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-save-temps -g -dA" } */
+
+typedef const struct _Harry { int dummy; } Harry_t;
+Harry_t harry;
+
+/* { dg-final { scan-assembler "DW_TAG_typedef\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_name: \"Harry_t\"" } } */
+/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-3.c
new file mode 100644 (file)
index 0000000..374e6cc
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-save-temps -g -dA" } */
+
+typedef struct _Harry { int dummy; } Harry_t;
+const Harry_t harry[5];
+
+/* { dg-final { scan-assembler "DW_TAG_typedef\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_name: \"Harry_t\"" } } */
+/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-4.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr47939-4.c
new file mode 100644 (file)
index 0000000..57db399
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-save-temps -g -dA" } */
+
+typedef const struct _Harry { int dummy; } Harry_t;
+Harry_t harry[10];
+
+/* { dg-final { scan-assembler "DW_TAG_typedef\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_name: \"Harry_t\"" } } */
+/* { dg-final { cleanup-saved-temps } } */