From patchwork Sat Oct 19 10:53:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 284864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 114D82C008A for ; Sat, 19 Oct 2013 21:57:38 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=uu533jlkz7L5A9/4 EvWZ1JJwFh9S2oGh+q02nlWObp9K7soqEk5NzExdwiDpBIviZdZKMwzuOD+INDaQ N26MnXA6ONIL+FNTp5v1cvGlPAepLkYJQuSnZxzmVErSJvy/mBAGfAdqBj2bOpDO FvrkX8t8wTm58WaYQig/RMY533M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=cMVxHm+lnhHTy3efCwLE3Q 7DXvw=; b=ChTeVQ7QDs7gs6Hcn0kr29Y2dpZFQl3BzA+K+ESiyhgfYVZomWSXEs f6dP2Grmeh6ZRdszFpd2zREWEeYTRJL6eQGcDGfA6oW6Borcj/ut4TvrCYfS/frT 1wvorjv+uk445GWBKTSlA+okL3dWCDFMjxqmYZ1R/0iYkQQaQFa3w= Received: (qmail 10603 invoked by alias); 19 Oct 2013 10:57:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10594 invoked by uid 89); 19 Oct 2013 10:57:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 19 Oct 2013 10:57:30 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 8B28B2686A63 for ; Sat, 19 Oct 2013 12:57:27 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2eEWL76gUG6D for ; Sat, 19 Oct 2013 12:57:27 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 6A809268691F for ; Sat, 19 Oct 2013 12:57:27 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix wrong scope for descriptive type in debug info Date: Sat, 19 Oct 2013 12:53:36 +0200 Message-ID: <1765068.1ApteRlr7U@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 This is a regression present on all active branches. The descriptive types emitted in the debug info by the Ada compiler can have a different scope than that of the type they are associated with, which goes against the spec. Tested on x86_64-suse-linux, applied on all active branches. 2013-10-19 Eric Botcazou * gcc-interface/utils.c (gnat_set_type_context): New function. (gnat_pushdecl): Use it to set the context of the type. Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 297217) +++ gcc-interface/utils.c (revision 297218) @@ -531,6 +531,22 @@ gnat_zaplevel (void) free_binding_level = level; } +/* Set the context of TYPE and its parallel types (if any) to CONTEXT. */ + +static void +gnat_set_type_context (tree type, tree context) +{ + tree decl = TYPE_STUB_DECL (type); + + TYPE_CONTEXT (type) = context; + + while (decl && DECL_PARALLEL_TYPE (decl)) + { + TYPE_CONTEXT (DECL_PARALLEL_TYPE (decl)) = context; + decl = TYPE_STUB_DECL (DECL_PARALLEL_TYPE (decl)); + } +} + /* Record DECL as belonging to the current lexical scope and use GNAT_NODE for location information and flag propagation. */ @@ -612,7 +628,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); + gnat_set_type_context (tt, DECL_CONTEXT (decl)); TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (t); DECL_ORIGINAL_TYPE (decl) = tt; } @@ -622,7 +638,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); + gnat_set_type_context (tt, DECL_CONTEXT (decl)); TREE_USED (tt) = TREE_USED (t); TREE_TYPE (decl) = tt; if (DECL_ORIGINAL_TYPE (TYPE_NAME (t))) @@ -644,7 +660,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_n if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)) { TYPE_NAME (t) = decl; - TYPE_CONTEXT (t) = DECL_CONTEXT (decl); + gnat_set_type_context (t, DECL_CONTEXT (decl)); } } }