From patchwork Tue Jul 3 07:52:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Ada] Adjust to change in handling of local types with -g Date: Mon, 02 Jul 2012 21:52:05 -0000 From: Eric Botcazou X-Patchwork-Id: 168726 Message-Id: <201207030952.05932.ebotcazou@adacore.com> To: gcc-patches@gcc.gnu.org The fix for PR c++/52637 slightly broke the handling of local types in Ada. The attached patch restores correct generation of debug info for them. Tested on i586-suse-linux, applied on mainline and 4.7 branch. 2012-07-03 Eric Botcazou * gcc-interface/utils.c (gnat_pushdecl): Set TYPE_CONTEXT for types attached to a TYPE_DECL. Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 189034) +++ gcc-interface/utils.c (working copy) @@ -612,6 +612,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_n if (TREE_CODE (t) == POINTER_TYPE) TYPE_NEXT_PTR_TO (t) = tt; TYPE_NAME (tt) = DECL_NAME (decl); + TYPE_CONTEXT (tt) = DECL_CONTEXT (decl); TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (t); DECL_ORIGINAL_TYPE (decl) = tt; } @@ -621,6 +622,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_n /* We need a variant for the placeholder machinery to work. */ tree tt = build_variant_type_copy (t); TYPE_NAME (tt) = decl; + TYPE_CONTEXT (tt) = DECL_CONTEXT (decl); TREE_USED (tt) = TREE_USED (t); TREE_TYPE (decl) = tt; if (DECL_ORIGINAL_TYPE (TYPE_NAME (t))) @@ -640,7 +642,10 @@ gnat_pushdecl (tree decl, Node_Id gnat_n if (t) for (t = TYPE_MAIN_VARIANT (t); t; t = TYPE_NEXT_VARIANT (t)) if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)) - TYPE_NAME (t) = decl; + { + TYPE_NAME (t) = decl; + TYPE_CONTEXT (t) = DECL_CONTEXT (decl); + } } }