This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA][PR 41063] ICE in output_die
>> + ? ? ? ? ?if (decl_function_context (TYPE_STUB_DECL (TREE_TYPE (type))))
>
> This doesn't seem like the right test; it will be true for a nested class
> within a local class, which I don't think is what we want.
Yes, I think you're right.
> Also, it seems like we should be handling this issue in the ENUMERAL_TYPE
> etc section, where we already have some code to adjust context_die, rather
> than in the POINTER_TYPE section. ?I guess we just need a function scope
> case; the current code seems to assume that a type has either class or
> namespace scope.
OK, here's another stab at it. This patch adds a check for the
function scope case (but only the immediate context) and calls
lookup_decl_die on the function decl to set context_die. If a DIE for
that function hasn't been created yet, it'll use NULL and do the right
thing later when the function DIE does get written.
This bootstraps on x86_64-linux. The test suite is still running, but
it looks good so far. Assuming it finishes clean, does this look OK?
-cary
gcc/ChangeLog:
PR debug/41063
* dwarf2out.c (gen_type_die_with_usage): Use proper context for
struct/union/enum types local to a function.
gcc/testsuite/ChangeLog:
PR debug/41063
* g++.dg/debug/dwarf2/pr41063.C: New test.
Index: testsuite/g++.dg/debug/dwarf2/pr41063.C
===================================================================
--- testsuite/g++.dg/debug/dwarf2/pr41063.C (revision 0)
+++ testsuite/g++.dg/debug/dwarf2/pr41063.C (revision 0)
@@ -0,0 +1,20 @@
+// Contributed by Cary Coutant <ccoutant@google.com>
+// Origin: PR debug/41063
+// { dg-do compile }
+
+struct A {
+ virtual void run();
+};
+
+void test() {
+ struct B : public A {
+ void run() {
+ struct C : public A {
+ C() { }
+ B *b_;
+ };
+ C c;
+ }
+ };
+ B b;
+}
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 150727)
+++ dwarf2out.c (working copy)
@@ -15553,6 +15553,15 @@ gen_type_die_with_usage (tree type, dw_d
context_die = lookup_type_die (TYPE_CONTEXT (type));
need_pop = 1;
}
+ else if (TYPE_CONTEXT (type) != NULL_TREE
+ && (TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL))
+ {
+ /* If this type is local to a function that hasn't been written
+ out yet, use a NULL context for now; it will be fixed up in
+ decls_for_scope. */
+ context_die = lookup_decl_die (TYPE_CONTEXT (type));
+ need_pop = 0;
+ }
else
{
context_die = declare_in_namespace (type, context_die);