]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR debug/83550 (Bad location of DW_TAG_structure_type with forward decla...
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 17:08:02 +0000 (19:08 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 17:08:02 +0000 (19:08 +0200)
Backported from mainline
2017-12-22  Jakub Jelinek  <jakub@redhat.com>

PR debug/83550
* c-decl.c (finish_struct): Set DECL_SOURCE_LOCATION on
TYPE_STUB_DECL and call rest_of_type_compilation before processing
incomplete vars rather than after it.

* c-c++-common/dwarf2/pr83550.c: New test.

From-SVN: r262050

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/dwarf2/pr83550.c [new file with mode: 0644]

index 5c7fe67aa5834873eb786084be236a088a44ed14..494a470bb2f075faf6a5e77f571735aa9c828310 100644 (file)
@@ -1,6 +1,13 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-12-22  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/83550
+       * c-decl.c (finish_struct): Set DECL_SOURCE_LOCATION on
+       TYPE_STUB_DECL and call rest_of_type_compilation before processing
+       incomplete vars rather than after it.
+
        2017-09-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/82340
index ef2780c38746b7a49f2785576d83f2e8aed9480e..2747464b8e2477b748be62bf04daf04b190736c1 100644 (file)
@@ -7912,6 +7912,14 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
       warning_at (loc, 0, "union cannot be made transparent");
     }
 
+  /* Update type location to the one of the definition, instead of e.g.
+     a forward declaration.  */
+  if (TYPE_STUB_DECL (t))
+    DECL_SOURCE_LOCATION (TYPE_STUB_DECL (t)) = loc;
+
+  /* Finish debugging output for this type.  */
+  rest_of_type_compilation (t, toplevel);
+
   /* If this structure or union completes the type of any previous
      variable declaration, lay it out and output its rtl.  */
   for (x = incomplete_vars; x; x = TREE_CHAIN (x))
@@ -7928,14 +7936,6 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
        }
     }
 
-  /* Update type location to the one of the definition, instead of e.g.
-     a forward declaration.  */
-  if (TYPE_STUB_DECL (t))
-    DECL_SOURCE_LOCATION (TYPE_STUB_DECL (t)) = loc;
-
-  /* Finish debugging output for this type.  */
-  rest_of_type_compilation (t, toplevel);
-
   /* If we're inside a function proper, i.e. not file-scope and not still
      parsing parameters, then arrange for the size of a variable sized type
      to be bound now.  */
index 7b170172259db8a1d18ad544059faac1365a49fc..119a8a13787b99e442fcac9844df11ba505618d0 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-12-22  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/83550
+       * c-c++-common/dwarf2/pr83550.c: New test.
+
        2017-12-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/80747
diff --git a/gcc/testsuite/c-c++-common/dwarf2/pr83550.c b/gcc/testsuite/c-c++-common/dwarf2/pr83550.c
new file mode 100644 (file)
index 0000000..1d77e95
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR debug/83550 */
+/* { dg-do compile } */
+/* { dg-options "-gdwarf -dA -fno-merge-debug-strings" } */
+
+struct my_struct;
+extern struct my_struct s;
+struct my_struct { int a, b; };
+struct my_struct q;
+
+/* { dg-final { scan-assembler "DW_TAG_structure_type\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"my_struct\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0x)?7\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" } } */