[debug/88006] -fdebug-types-section gives undefined ref
authorNathan Sidwell <nathan@acm.org>
Wed, 14 Nov 2018 19:30:47 +0000 (19:30 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 14 Nov 2018 19:30:47 +0000 (19:30 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-11/msg01280.html
PR debug/88006
PR debug/87462
* dwarf2out.c (dwarf2out_finish): Apply resolve_addr to comdat
type list.

* g++.dg/debug/dwarf2/pr87462.C: New.
* g++.dg/debug/dwarf2/pr88006.C: New.

From-SVN: r266158

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/pr87462.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/pr88006.C [new file with mode: 0644]

index 568cdeef42ba6d8cfae348554ac435d63954b57d..0bb3b84439bddef84c668e5c962c9749692e8e23 100644 (file)
@@ -1,3 +1,10 @@
+2018-11-14  Nathan Sidwell  <nathan@acm.org>
+
+       PR debug/88006
+       PR debug/87462
+       * dwarf2out.c (dwarf2out_finish): Apply resolve_addr to comdat
+       type list.
+
 2018-11-14  David Malcolm  <dmalcolm@redhat.com>
 
        * Makefile.in (CFLAGS-optinfo-emit-json.o): Add $(ZLIBINC).
index 8b478aa265fd83f0d4faf8c0f360356734128ab5..aba8843498111fcc755d51005d9befc90a1e8e0c 100644 (file)
@@ -31182,6 +31182,8 @@ dwarf2out_finish (const char *filename)
     FOR_EACH_CHILD (die, c, gcc_assert (! c->die_mark));
   }
 #endif
+  for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
+    resolve_addr (ctnode->root_die);
   resolve_addr (comp_unit_die ());
   move_marked_base_types ();
 
index 524db2686170cc83fbf9f74c98a1a6530b7b9b43..9d52f14fc00e1b46f645e31a12c0916093c5cf07 100644 (file)
@@ -1,3 +1,10 @@
+2018-11-14  Nathan Sidwell  <nathan@acm.org>
+
+       PR debug/88006
+       PR debug/87462
+       * g++.dg/debug/dwarf2/pr87462.C: New.
+       * g++.dg/debug/dwarf2/pr88006.C: New.
+
 2018-11-14  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * g++.dg/cpp0x/nsdmi-union6.C: Test locations too.
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr87462.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr87462.C
new file mode 100644 (file)
index 0000000..bfbaad0
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-additional-options "-dA -std=gnu++17 -gdwarf-4 -O1 -fdebug-types-section" }
+// reject .pseudo label, but "label" is ok.
+// { dg-final { scan-assembler-not "\[^L\"\]_ZN5Test18testFuncEv" } }
+// undefined ref to _ZN5Test18testFuncEv
+
+class Test1 {
+public:
+  static int testFunc() { return 1; }
+};
+
+template <typename T,
+          T (*funcImpl)()>
+class TestWrapper {
+public:
+  static T func() __attribute((noinline)) { return (*funcImpl)(); } 
+};
+
+int main() {
+  return TestWrapper<int, &Test1::testFunc>::func();
+}
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr88006.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr88006.C
new file mode 100644 (file)
index 0000000..86584e1
--- /dev/null
@@ -0,0 +1,39 @@
+// { dg-additional-options "-dA -std=gnu++17 -gdwarf-4 -O1 -fdebug-types-section" }
+// reject .pseudo label, but "label" is ok.
+// { dg-final { scan-assembler-not "\[^\"\]_ZN3Foo4mfunEv" } }
+// undefined ref to _ZN3Foo4mfunEv
+
+struct Foo {
+  void mfun () {}
+};
+
+struct A { static constexpr bool Value = false; };
+
+template <bool> struct B { typedef int Type; };
+
+class Arg
+{
+  template <typename Unused> struct Local : A {};
+
+public:
+  template <typename Init, typename = typename B<Local<Init>::Value>::Type>
+  Arg (Init) {}
+};
+
+class Lambda {
+  static constexpr int Unused = 0;
+    
+public:
+  Lambda (Arg);
+};
+
+// Generated ref to Foo::mfun in the type die of an instantiation of this
+template <void (Foo::*unused)()> struct Callable {};
+
+class I {
+  I() : lamb ([this] {}) {}
+
+  Lambda lamb;
+
+  Callable<&Foo::mfun> bm;
+};