re PR debug/83550 (Bad location of DW_TAG_structure_type with forward declaration...
authorJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Dec 2017 18:04:18 +0000 (19:04 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Dec 2017 18:04:18 +0000 (19:04 +0100)
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: r255981

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

index f4efa6818e85cc281cc29ca09f5fa2e4f4193a33..6dcababadda49254508cc45c35c884b1beb2d462 100644 (file)
 
 2016-08-22  Joseph Myers  <joseph@codesourcery.com>
 
-       * c-family/c-cppbuiltin.c (c_cpp_builtins): Check _FloatN and
+       * c-cppbuiltin.c (c_cpp_builtins): Check _FloatN and
        _FloatNx types for suffixes for built-in functions.
 
 2016-08-19  Joseph Myers  <joseph@codesourcery.com>
 2016-06-10  Martin Sebor  <msebor@redhat.com>
 
        PR c/71392
-       * gcc/c-family/c-common.c (handle_nonnull_attribute): Accept
+       * c-common.c (handle_nonnull_attribute): Accept
        the nonnull attribute in type-generic builtins.
 
 2016-06-09  Martin Sebor  <msebor@redhat.com>
index 581f7df149b18f1b456e63045165c117fa21164d..504205dc7de0316f0b5d2c33308f28086de9ebbd 100644 (file)
@@ -1,5 +1,10 @@
 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.
+
        PR debug/83547
        * c-typeck.c (c_finish_stmt_expr): Ignore !TREE_SIDE_EFFECTS as
        indicator of ({ }), instead skip all trailing DEBUG_BEGIN_STMTs first,
index e37ae17b9e1abae578416e99e3f73e5629d7b5f6..846098ea8367c1f9c31c9ef70578ba8d6670f19d 100644 (file)
@@ -8199,6 +8199,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))
@@ -8215,14 +8223,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 fbffe0c339041f0688ac86f694639011fd9cb561..20b0349b93579958533b58ee12b2eff02df7585b 100644 (file)
 2017-01-27  Adam Butcher  <adam@jessamine.co.uk>
 
        PR c++/64382
-       * cp/parser.c (parsing_default_capturing_generic_lambda_in_template):
+       * parser.c (parsing_default_capturing_generic_lambda_in_template):
        New function.
-       * cp/cp-tree.h: Declare it.
-       * cp/semantics.c (finish_id_expression): Resolve names within a default
+       * cp-tree.h: Declare it.
+       * semantics.c (finish_id_expression): Resolve names within a default
        capturing generic lambda defined within a template prior to
        instantiation to allow for captures to be added to the closure type.
 
index 0102564068cc99ffb9deef21bcb1e35f47733037..c736ca24258c4861aff08e199aec7cea4ca58df4 100644 (file)
@@ -1,5 +1,8 @@
 2017-12-22  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/83550
+       * c-c++-common/dwarf2/pr83550.c: New test.
+
        PR debug/83547
        * gcc.c-torture/compile/pr83547.c: New test.
 
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" } } */